18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: LGPL-2.1 28c2ecf20Sopenharmony_ci#include <sys/types.h> 38c2ecf20Sopenharmony_ci#include <sys/wait.h> 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_cistatic size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size, 68c2ecf20Sopenharmony_ci struct syscall_arg *arg) 78c2ecf20Sopenharmony_ci{ 88c2ecf20Sopenharmony_ci bool show_prefix = arg->show_string_prefix; 98c2ecf20Sopenharmony_ci const char *prefix = "W"; 108c2ecf20Sopenharmony_ci int printed = 0, options = arg->val; 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#define P_OPTION(n) \ 138c2ecf20Sopenharmony_ci if (options & W##n) { \ 148c2ecf20Sopenharmony_ci printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \ 158c2ecf20Sopenharmony_ci options &= ~W##n; \ 168c2ecf20Sopenharmony_ci } 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci P_OPTION(NOHANG); 198c2ecf20Sopenharmony_ci P_OPTION(UNTRACED); 208c2ecf20Sopenharmony_ci P_OPTION(CONTINUED); 218c2ecf20Sopenharmony_ci#undef P_OPTION 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci if (options) 248c2ecf20Sopenharmony_ci printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", options); 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci return printed; 278c2ecf20Sopenharmony_ci} 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define SCA_WAITID_OPTIONS syscall_arg__scnprintf_waitid_options 30