Arnaldo Carvalho de Melo | d5d71e8 | 2016-05-06 12:45:25 -0300 | [diff] [blame^] | 1 | #include <linux/futex.h> |
| 2 | |
| 3 | static size_t syscall_arg__scnprintf_futex_op(char *bf, size_t size, struct syscall_arg *arg) |
| 4 | { |
| 5 | enum syscall_futex_args { |
| 6 | SCF_UADDR = (1 << 0), |
| 7 | SCF_OP = (1 << 1), |
| 8 | SCF_VAL = (1 << 2), |
| 9 | SCF_TIMEOUT = (1 << 3), |
| 10 | SCF_UADDR2 = (1 << 4), |
| 11 | SCF_VAL3 = (1 << 5), |
| 12 | }; |
| 13 | int op = arg->val; |
| 14 | int cmd = op & FUTEX_CMD_MASK; |
| 15 | size_t printed = 0; |
| 16 | |
| 17 | switch (cmd) { |
| 18 | #define P_FUTEX_OP(n) case FUTEX_##n: printed = scnprintf(bf, size, #n); |
| 19 | P_FUTEX_OP(WAIT); arg->mask |= SCF_VAL3|SCF_UADDR2; break; |
| 20 | P_FUTEX_OP(WAKE); arg->mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break; |
| 21 | P_FUTEX_OP(FD); arg->mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break; |
| 22 | P_FUTEX_OP(REQUEUE); arg->mask |= SCF_VAL3|SCF_TIMEOUT; break; |
| 23 | P_FUTEX_OP(CMP_REQUEUE); arg->mask |= SCF_TIMEOUT; break; |
| 24 | P_FUTEX_OP(CMP_REQUEUE_PI); arg->mask |= SCF_TIMEOUT; break; |
| 25 | P_FUTEX_OP(WAKE_OP); break; |
| 26 | P_FUTEX_OP(LOCK_PI); arg->mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break; |
| 27 | P_FUTEX_OP(UNLOCK_PI); arg->mask |= SCF_VAL3|SCF_UADDR2|SCF_TIMEOUT; break; |
| 28 | P_FUTEX_OP(TRYLOCK_PI); arg->mask |= SCF_VAL3|SCF_UADDR2; break; |
| 29 | P_FUTEX_OP(WAIT_BITSET); arg->mask |= SCF_UADDR2; break; |
| 30 | P_FUTEX_OP(WAKE_BITSET); arg->mask |= SCF_UADDR2; break; |
| 31 | P_FUTEX_OP(WAIT_REQUEUE_PI); break; |
| 32 | default: printed = scnprintf(bf, size, "%#x", cmd); break; |
| 33 | } |
| 34 | |
| 35 | if (op & FUTEX_PRIVATE_FLAG) |
| 36 | printed += scnprintf(bf + printed, size - printed, "|PRIV"); |
| 37 | |
| 38 | if (op & FUTEX_CLOCK_REALTIME) |
| 39 | printed += scnprintf(bf + printed, size - printed, "|CLKRT"); |
| 40 | |
| 41 | return printed; |
| 42 | } |
| 43 | |
| 44 | #define SCA_FUTEX_OP syscall_arg__scnprintf_futex_op |