blob: f492186a9a98f1f874e23a19218ee051b5c7a556 [file] [log] [blame]
Dmitry V. Levine314f802014-12-11 19:25:02 +00001#include "defs.h"
2
3#ifdef HAVE_LINUX_FUTEX_H
4# include <linux/futex.h>
5#endif
6
Dmitry V. Levine314f802014-12-11 19:25:02 +00007#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. Levin003cc9f2015-06-17 19:00:17 +000013
Dmitry V. Levine314f802014-12-11 19:25:02 +000014#include "xlat/futexops.h"
Dmitry V. Levine314f802014-12-11 19:25:02 +000015#include "xlat/futexwakeops.h"
16#include "xlat/futexwakecmps.h"
17
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000018SYS_FUNC(futex)
Dmitry V. Levine314f802014-12-11 19:25:02 +000019{
Dmitry V. Levinb5821092015-07-20 13:15:51 +000020 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. Levin59385262015-09-18 15:16:11 +000037 print_timespec(tcp, timeout);
Dmitry V. Levinb5821092015-07-20 13:15:51 +000038 break;
39 case FUTEX_WAIT_BITSET:
40 tprints(", ");
Dmitry V. Levin59385262015-09-18 15:16:11 +000041 print_timespec(tcp, timeout);
Dmitry V. Levinb5821092015-07-20 13:15:51 +000042 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. Levin59385262015-09-18 15:16:11 +000072 print_timespec(tcp, timeout);
Dmitry V. Levinb5821092015-07-20 13:15:51 +000073 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. Levine314f802014-12-11 19:25:02 +000083 }
Dmitry V. Levinb5821092015-07-20 13:15:51 +000084
85 return RVAL_DECODED;
Dmitry V. Levine314f802014-12-11 19:25:02 +000086}