162306a36Sopenharmony_ci// SPDX-License-Identifier: LGPL-2.1 262306a36Sopenharmony_ci#include <sys/types.h> 362306a36Sopenharmony_ci#include <sys/wait.h> 462306a36Sopenharmony_ci 562306a36Sopenharmony_cistatic size_t syscall_arg__scnprintf_waitid_options(char *bf, size_t size, 662306a36Sopenharmony_ci struct syscall_arg *arg) 762306a36Sopenharmony_ci{ 862306a36Sopenharmony_ci bool show_prefix = arg->show_string_prefix; 962306a36Sopenharmony_ci const char *prefix = "W"; 1062306a36Sopenharmony_ci int printed = 0, options = arg->val; 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#define P_OPTION(n) \ 1362306a36Sopenharmony_ci if (options & W##n) { \ 1462306a36Sopenharmony_ci printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \ 1562306a36Sopenharmony_ci options &= ~W##n; \ 1662306a36Sopenharmony_ci } 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci P_OPTION(NOHANG); 1962306a36Sopenharmony_ci P_OPTION(UNTRACED); 2062306a36Sopenharmony_ci P_OPTION(CONTINUED); 2162306a36Sopenharmony_ci#undef P_OPTION 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci if (options) 2462306a36Sopenharmony_ci printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", options); 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci return printed; 2762306a36Sopenharmony_ci} 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#define SCA_WAITID_OPTIONS syscall_arg__scnprintf_waitid_options 30