Linux Perf
msg_flags.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0
2 #include <sys/types.h>
3 #include <sys/socket.h>
4 
5 #ifndef MSG_PROBE
6 #define MSG_PROBE 0x10
7 #endif
8 #ifndef MSG_WAITFORONE
9 #define MSG_WAITFORONE 0x10000
10 #endif
11 #ifndef MSG_SENDPAGE_NOTLAST
12 #define MSG_SENDPAGE_NOTLAST 0x20000
13 #endif
14 #ifndef MSG_FASTOPEN
15 #define MSG_FASTOPEN 0x20000000
16 #endif
17 #ifndef MSG_CMSG_CLOEXEC
18 # define MSG_CMSG_CLOEXEC 0x40000000
19 #endif
20 
21 static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size,
22  struct syscall_arg *arg)
23 {
24  int printed = 0, flags = arg->val;
25 
26  if (flags == 0)
27  return scnprintf(bf, size, "NONE");
28 #define P_MSG_FLAG(n) \
29  if (flags & MSG_##n) { \
30  printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
31  flags &= ~MSG_##n; \
32  }
33 
34  P_MSG_FLAG(OOB);
35  P_MSG_FLAG(PEEK);
36  P_MSG_FLAG(DONTROUTE);
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
size_t size
Definition: evsel.c:60
#define P_MSG_FLAG(n)
static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, struct syscall_arg *arg)
Definition: msg_flags.c:21
unsigned long val
Definition: beauty.h:44
u32 flags