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