Merge tag 'block-5.9-2020-08-14' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / tools / perf / trace / beauty / perf_event_open.c
blob11d47dbe63bd1edc99e86c62e3e795321d50d0a1
1 // SPDX-License-Identifier: LGPL-2.1
2 #ifndef PERF_FLAG_FD_NO_GROUP
3 # define PERF_FLAG_FD_NO_GROUP (1UL << 0)
4 #endif
6 #ifndef PERF_FLAG_FD_OUTPUT
7 # define PERF_FLAG_FD_OUTPUT (1UL << 1)
8 #endif
10 #ifndef PERF_FLAG_PID_CGROUP
11 # define PERF_FLAG_PID_CGROUP (1UL << 2) /* pid=cgroup id, per-cpu mode only */
12 #endif
14 #ifndef PERF_FLAG_FD_CLOEXEC
15 # define PERF_FLAG_FD_CLOEXEC (1UL << 3) /* O_CLOEXEC */
16 #endif
18 static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size,
19 struct syscall_arg *arg)
21 bool show_prefix = arg->show_string_prefix;
22 const char *prefix = "PERF_";
23 int printed = 0, flags = arg->val;
25 if (flags == 0)
26 return 0;
28 #define P_FLAG(n) \
29 if (flags & PERF_FLAG_##n) { \
30 printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
31 flags &= ~PERF_FLAG_##n; \
34 P_FLAG(FD_NO_GROUP);
35 P_FLAG(FD_OUTPUT);
36 P_FLAG(PID_CGROUP);
37 P_FLAG(FD_CLOEXEC);
38 #undef P_FLAG
40 if (flags)
41 printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
43 return printed;
46 #define SCA_PERF_FLAGS syscall_arg__scnprintf_perf_flags