Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cris-mirror.git] / tools / perf / trace / beauty / flock.c
blob74613703a14eba783f405a3fe655a5c0645d94e2
1 #include <fcntl.h>
3 #ifndef LOCK_MAND
4 #define LOCK_MAND 32
5 #endif
7 #ifndef LOCK_READ
8 #define LOCK_READ 64
9 #endif
11 #ifndef LOCK_WRITE
12 #define LOCK_WRITE 128
13 #endif
15 #ifndef LOCK_RW
16 #define LOCK_RW 192
17 #endif
19 static size_t syscall_arg__scnprintf_flock(char *bf, size_t size,
20 struct syscall_arg *arg)
22 int printed = 0, op = arg->val;
24 if (op == 0)
25 return scnprintf(bf, size, "NONE");
26 #define P_CMD(cmd) \
27 if ((op & LOCK_##cmd) == LOCK_##cmd) { \
28 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #cmd); \
29 op &= ~LOCK_##cmd; \
32 P_CMD(SH);
33 P_CMD(EX);
34 P_CMD(NB);
35 P_CMD(UN);
36 P_CMD(MAND);
37 P_CMD(RW);
38 P_CMD(READ);
39 P_CMD(WRITE);
40 #undef P_OP
42 if (op)
43 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", op);
45 return printed;
48 #define SCA_FLOCK syscall_arg__scnprintf_flock