xref: /linux/tools/perf/trace/beauty/eventfd.c (revision 537609924c43715e39a41762d3e3d3c7c534bb71)
1 // SPDX-License-Identifier: LGPL-2.1
2 #include "trace/beauty/beauty.h"
3 
4 #ifndef EFD_SEMAPHORE
5 #define EFD_SEMAPHORE		1
6 #endif
7 
8 #ifndef EFD_NONBLOCK
9 #define EFD_NONBLOCK		00004000
10 #endif
11 
12 #ifndef EFD_CLOEXEC
13 #define EFD_CLOEXEC		02000000
14 #endif
15 
16 size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct syscall_arg *arg)
17 {
18 	bool show_prefix = arg->show_string_prefix;
19 	const char *prefix = "EFD_";
20 	int printed = 0, flags = arg->val;
21 
22 	if (flags == 0)
23 		return scnprintf(bf, size, "NONE");
24 #define	P_FLAG(n) \
25 	if (flags & EFD_##n) { \
26 		printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \
27 		flags &= ~EFD_##n; \
28 	}
29 
30 	P_FLAG(SEMAPHORE);
31 	P_FLAG(CLOEXEC);
32 	P_FLAG(NONBLOCK);
33 #undef P_FLAG
34 
35 	if (flags)
36 		printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
37 
38 	return printed;
39 }
40