-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrfutexcmd.c
44 lines (42 loc) · 961 Bytes
/
strfutexcmd.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <linux/futex.h>
#include <stdio.h>
#include <stdlib.h>
static const char*
strfutex(unsigned long cmd)
{
switch (cmd) {
#define CASE(_c) case FUTEX_ ## _c: return #_c
CASE(WAIT);
CASE(WAKE);
CASE(FD);
CASE(REQUEUE);
CASE(CMP_REQUEUE);
CASE(WAKE_OP);
CASE(LOCK_PI);
CASE(UNLOCK_PI);
CASE(TRYLOCK_PI);
CASE(WAIT_BITSET);
CASE(WAKE_BITSET);
CASE(WAIT_REQUEUE_PI);
CASE(CMP_REQUEUE_PI);
#undef CASE
default:
return "???";
}
}
int
main(int argc, char** argv)
{
int i;
for (i = 1; i < argc; ++i) {
unsigned long cmd = strtoul(argv[i], NULL, 0);
int private = (cmd & FUTEX_PRIVATE_FLAG);
int clock_realtime = (cmd & FUTEX_CLOCK_REALTIME);
printf("0x%lx = %s%s%s\n",
cmd,
strfutex(cmd & FUTEX_CMD_MASK),
private ? " (private)" : "",
clock_realtime ? " (clock_realtime)" : "");
}
return 0;
}