Dmitry V. Levin | e314f80 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 1 | #include "defs.h" |
| 2 | |
| 3 | #ifdef HAVE_LINUX_FUTEX_H |
| 4 | # include <linux/futex.h> |
| 5 | #endif |
| 6 | |
Dmitry V. Levin | e314f80 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 7 | #ifndef FUTEX_PRIVATE_FLAG |
| 8 | # define FUTEX_PRIVATE_FLAG 128 |
| 9 | #endif |
| 10 | #ifndef FUTEX_CLOCK_REALTIME |
| 11 | # define FUTEX_CLOCK_REALTIME 256 |
| 12 | #endif |
Dmitry V. Levin | 003cc9f | 2015-06-17 19:00:17 +0000 | [diff] [blame] | 13 | |
Dmitry V. Levin | e314f80 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 14 | #include "xlat/futexops.h" |
Dmitry V. Levin | e314f80 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 15 | #include "xlat/futexwakeops.h" |
| 16 | #include "xlat/futexwakecmps.h" |
| 17 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 18 | SYS_FUNC(futex) |
Dmitry V. Levin | e314f80 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 19 | { |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 20 | const long uaddr = tcp->u_arg[0]; |
| 21 | const int op = tcp->u_arg[1]; |
| 22 | const int cmd = op & 127; |
| 23 | const long timeout = tcp->u_arg[3]; |
| 24 | const long uaddr2 = tcp->u_arg[4]; |
| 25 | const unsigned int val = tcp->u_arg[2]; |
| 26 | const unsigned int val2 = tcp->u_arg[3]; |
| 27 | const unsigned int val3 = tcp->u_arg[5]; |
| 28 | |
| 29 | printaddr(uaddr); |
| 30 | tprints(", "); |
| 31 | printxval(futexops, op, "FUTEX_???"); |
| 32 | tprintf(", %u", val); |
| 33 | switch (cmd) { |
| 34 | case FUTEX_WAIT: |
| 35 | case FUTEX_LOCK_PI: |
| 36 | tprints(", "); |
Dmitry V. Levin | 5938526 | 2015-09-18 15:16:11 +0000 | [diff] [blame^] | 37 | print_timespec(tcp, timeout); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 38 | break; |
| 39 | case FUTEX_WAIT_BITSET: |
| 40 | tprints(", "); |
Dmitry V. Levin | 5938526 | 2015-09-18 15:16:11 +0000 | [diff] [blame^] | 41 | print_timespec(tcp, timeout); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 42 | tprintf(", %x", val3); |
| 43 | break; |
| 44 | case FUTEX_WAKE_BITSET: |
| 45 | tprintf(", %x", val3); |
| 46 | break; |
| 47 | case FUTEX_REQUEUE: |
| 48 | tprintf(", %u, ", val2); |
| 49 | printaddr(uaddr2); |
| 50 | break; |
| 51 | case FUTEX_CMP_REQUEUE: |
| 52 | case FUTEX_CMP_REQUEUE_PI: |
| 53 | tprintf(", %u, ", val2); |
| 54 | printaddr(uaddr2); |
| 55 | tprintf(", %u", val3); |
| 56 | break; |
| 57 | case FUTEX_WAKE_OP: |
| 58 | tprintf(", %u, ", val2); |
| 59 | printaddr(uaddr2); |
| 60 | tprints(", {"); |
| 61 | if ((val3 >> 28) & 8) |
| 62 | tprints("FUTEX_OP_OPARG_SHIFT|"); |
| 63 | printxval(futexwakeops, (val3 >> 28) & 0x7, "FUTEX_OP_???"); |
| 64 | tprintf(", %u, ", (val3 >> 12) & 0xfff); |
| 65 | if ((val3 >> 24) & 8) |
| 66 | tprints("FUTEX_OP_OPARG_SHIFT|"); |
| 67 | printxval(futexwakecmps, (val3 >> 24) & 0x7, "FUTEX_OP_CMP_???"); |
| 68 | tprintf(", %u}", val3 & 0xfff); |
| 69 | break; |
| 70 | case FUTEX_WAIT_REQUEUE_PI: |
| 71 | tprints(", "); |
Dmitry V. Levin | 5938526 | 2015-09-18 15:16:11 +0000 | [diff] [blame^] | 72 | print_timespec(tcp, timeout); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 73 | tprints(", "); |
| 74 | printaddr(uaddr2); |
| 75 | break; |
| 76 | case FUTEX_WAKE: |
| 77 | case FUTEX_UNLOCK_PI: |
| 78 | case FUTEX_TRYLOCK_PI: |
| 79 | break; |
| 80 | default: |
| 81 | tprintf(", %lx, %lx, %x", timeout, uaddr2, val3); |
| 82 | break; |
Dmitry V. Levin | e314f80 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 83 | } |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 84 | |
| 85 | return RVAL_DECODED; |
Dmitry V. Levin | e314f80 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 86 | } |