1 // SPDX-License-Identifier: GPL-2.0
2 #ifndef PERF_FLAG_FD_NO_GROUP
3 # define PERF_FLAG_FD_NO_GROUP		(1UL << 0)
4 #endif
5 
6 #ifndef PERF_FLAG_FD_OUTPUT
7 # define PERF_FLAG_FD_OUTPUT		(1UL << 1)
8 #endif
9 
10 #ifndef PERF_FLAG_PID_CGROUP
11 # define PERF_FLAG_PID_CGROUP		(1UL << 2) /* pid=cgroup id, per-cpu mode only */
12 #endif
13 
14 #ifndef PERF_FLAG_FD_CLOEXEC
15 # define PERF_FLAG_FD_CLOEXEC		(1UL << 3) /* O_CLOEXEC */
16 #endif
17 
18 static size_t syscall_arg__scnprintf_perf_flags(char *bf, size_t size,
19 						struct syscall_arg *arg)
20 {
21 	int printed = 0, flags = arg->val;
22 
23 	if (flags == 0)
24 		return 0;
25 
26 #define	P_FLAG(n) \
27 	if (flags & PERF_FLAG_##n) { \
28 		printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
29 		flags &= ~PERF_FLAG_##n; \
30 	}
31 
32 	P_FLAG(FD_NO_GROUP);
33 	P_FLAG(FD_OUTPUT);
34 	P_FLAG(PID_CGROUP);
35 	P_FLAG(FD_CLOEXEC);
36 #undef P_FLAG
37 
38 	if (flags)
39 		printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
40 
41 	return printed;
42 }
43 
44 #define SCA_PERF_FLAGS syscall_arg__scnprintf_perf_flags
45