xref: /linux/tools/perf/trace/beauty/waitid_options.c (revision 537609924c43715e39a41762d3e3d3c7c534bb71)
1 // SPDX-License-Identifier: LGPL-2.1
2 #include "trace/beauty/beauty.h"
3 
4 #include <sys/types.h>
5 #include <sys/wait.h>
6 
7 size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size,
8 					     struct syscall_arg *arg)
9 {
10 	bool show_prefix = arg->show_string_prefix;
11 	const char *prefix = "W";
12 	int printed = 0, options = arg->val;
13 
14 #define	P_OPTION(n) \
15 	if (options & W##n) { \
16 		printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "",  #n); \
17 		options &= ~W##n; \
18 	}
19 
20 	P_OPTION(NOHANG);
21 	P_OPTION(UNTRACED);
22 	P_OPTION(CONTINUED);
23 #undef P_OPTION
24 
25 	if (options)
26 		printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", options);
27 
28 	return printed;
29 }
30