ACPI / EC: Work around method reentrancy limit in ACPICA for _Qxx
[cascardo/linux.git] / tools / perf / trace / beauty / msg_flags.c
1 #include <sys/types.h>
2 #include <sys/socket.h>
3
4 #ifndef MSG_PROBE
5 #define MSG_PROBE                    0x10
6 #endif
7 #ifndef MSG_WAITFORONE
8 #define MSG_WAITFORONE             0x10000
9 #endif
10 #ifndef MSG_SENDPAGE_NOTLAST
11 #define MSG_SENDPAGE_NOTLAST       0x20000
12 #endif
13 #ifndef MSG_FASTOPEN
14 #define MSG_FASTOPEN            0x20000000
15 #endif
16 #ifndef MSG_CMSG_CLOEXEC
17 # define MSG_CMSG_CLOEXEC       0x40000000
18 #endif
19
20 static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size,
21                                                struct syscall_arg *arg)
22 {
23         int printed = 0, flags = arg->val;
24
25         if (flags == 0)
26                 return scnprintf(bf, size, "NONE");
27 #define P_MSG_FLAG(n) \
28         if (flags & MSG_##n) { \
29                 printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
30                 flags &= ~MSG_##n; \
31         }
32
33         P_MSG_FLAG(OOB);
34         P_MSG_FLAG(PEEK);
35         P_MSG_FLAG(DONTROUTE);
36         P_MSG_FLAG(TRYHARD);
37         P_MSG_FLAG(CTRUNC);
38         P_MSG_FLAG(PROBE);
39         P_MSG_FLAG(TRUNC);
40         P_MSG_FLAG(DONTWAIT);
41         P_MSG_FLAG(EOR);
42         P_MSG_FLAG(WAITALL);
43         P_MSG_FLAG(FIN);
44         P_MSG_FLAG(SYN);
45         P_MSG_FLAG(CONFIRM);
46         P_MSG_FLAG(RST);
47         P_MSG_FLAG(ERRQUEUE);
48         P_MSG_FLAG(NOSIGNAL);
49         P_MSG_FLAG(MORE);
50         P_MSG_FLAG(WAITFORONE);
51         P_MSG_FLAG(SENDPAGE_NOTLAST);
52         P_MSG_FLAG(FASTOPEN);
53         P_MSG_FLAG(CMSG_CLOEXEC);
54 #undef P_MSG_FLAG
55
56         if (flags)
57                 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
58
59         return printed;
60 }
61
62 #define SCA_MSG_FLAGS syscall_arg__scnprintf_msg_flags