syscall_emul.hh (13629:0b83d5382336) syscall_emul.hh (13642:253cda14088e)
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * Copyright (c) 2015 Advanced Micro Devices, Inc.
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating

--- 389 unchanged lines hidden (view full) ---

398 ThreadContext *tc)
399{
400 using namespace std;
401
402 int index = 0;
403 Addr uaddr = process->getSyscallArg(tc, index);
404 int op = process->getSyscallArg(tc, index);
405 int val = process->getSyscallArg(tc, index);
1/*
2 * Copyright (c) 2012-2013, 2015 ARM Limited
3 * Copyright (c) 2015 Advanced Micro Devices, Inc.
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating

--- 389 unchanged lines hidden (view full) ---

398 ThreadContext *tc)
399{
400 using namespace std;
401
402 int index = 0;
403 Addr uaddr = process->getSyscallArg(tc, index);
404 int op = process->getSyscallArg(tc, index);
405 int val = process->getSyscallArg(tc, index);
406 int timeout M5_VAR_USED = process->getSyscallArg(tc, index);
407 Addr uaddr2 M5_VAR_USED = process->getSyscallArg(tc, index);
408 int val3 = process->getSyscallArg(tc, index);
406
407 /*
408 * Unsupported option that does not affect the correctness of the
409 * application. This is a performance optimization utilized by Linux.
410 */
411 op &= ~OS::TGT_FUTEX_PRIVATE_FLAG;
409
410 /*
411 * Unsupported option that does not affect the correctness of the
412 * application. This is a performance optimization utilized by Linux.
413 */
414 op &= ~OS::TGT_FUTEX_PRIVATE_FLAG;
415 op &= ~OS::TGT_FUTEX_CLOCK_REALTIME_FLAG;
412
413 FutexMap &futex_map = tc->getSystemPtr()->futexMap;
414
416
417 FutexMap &futex_map = tc->getSystemPtr()->futexMap;
418
415 if (OS::TGT_FUTEX_WAIT == op) {
419 if (OS::TGT_FUTEX_WAIT == op || OS::TGT_FUTEX_WAIT_BITSET == op) {
416 // Ensure futex system call accessed atomically.
417 BufferArg buf(uaddr, sizeof(int));
418 buf.copyIn(tc->getMemProxy());
419 int mem_val = *(int*)buf.bufferPtr();
420
421 /*
422 * The value in memory at uaddr is not equal with the expected val
423 * (a different thread must have changed it before the system call was
424 * invoked). In this case, we need to throw an error.
425 */
426 if (val != mem_val)
427 return -OS::TGT_EWOULDBLOCK;
428
420 // Ensure futex system call accessed atomically.
421 BufferArg buf(uaddr, sizeof(int));
422 buf.copyIn(tc->getMemProxy());
423 int mem_val = *(int*)buf.bufferPtr();
424
425 /*
426 * The value in memory at uaddr is not equal with the expected val
427 * (a different thread must have changed it before the system call was
428 * invoked). In this case, we need to throw an error.
429 */
430 if (val != mem_val)
431 return -OS::TGT_EWOULDBLOCK;
432
429 futex_map.suspend(uaddr, process->tgid(), tc);
433 if (OS::TGT_FUTEX_WAIT) {
434 futex_map.suspend(uaddr, process->tgid(), tc);
435 } else {
436 futex_map.suspend_bitset(uaddr, process->tgid(), tc, val3);
437 }
430
431 return 0;
432 } else if (OS::TGT_FUTEX_WAKE == op) {
433 return futex_map.wakeup(uaddr, process->tgid(), val);
438
439 return 0;
440 } else if (OS::TGT_FUTEX_WAKE == op) {
441 return futex_map.wakeup(uaddr, process->tgid(), val);
442 } else if (OS::TGT_FUTEX_WAKE_BITSET == op) {
443 return futex_map.wakeup_bitset(uaddr, process->tgid(), val3);
434 }
435
436 warn("futex: op %d not implemented; ignoring.", op);
437 return -ENOSYS;
438}
439
440
441/// Pseudo Funcs - These functions use a different return convension,

--- 2239 unchanged lines hidden ---
444 }
445
446 warn("futex: op %d not implemented; ignoring.", op);
447 return -ENOSYS;
448}
449
450
451/// Pseudo Funcs - These functions use a different return convension,

--- 2239 unchanged lines hidden ---