18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: LGPL-2.1 28c2ecf20Sopenharmony_ci#ifndef EFD_SEMAPHORE 38c2ecf20Sopenharmony_ci#define EFD_SEMAPHORE 1 48c2ecf20Sopenharmony_ci#endif 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef EFD_NONBLOCK 78c2ecf20Sopenharmony_ci#define EFD_NONBLOCK 00004000 88c2ecf20Sopenharmony_ci#endif 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef EFD_CLOEXEC 118c2ecf20Sopenharmony_ci#define EFD_CLOEXEC 02000000 128c2ecf20Sopenharmony_ci#endif 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistatic size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct syscall_arg *arg) 158c2ecf20Sopenharmony_ci{ 168c2ecf20Sopenharmony_ci bool show_prefix = arg->show_string_prefix; 178c2ecf20Sopenharmony_ci const char *prefix = "EFD_"; 188c2ecf20Sopenharmony_ci int printed = 0, flags = arg->val; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci if (flags == 0) 218c2ecf20Sopenharmony_ci return scnprintf(bf, size, "NONE"); 228c2ecf20Sopenharmony_ci#define P_FLAG(n) \ 238c2ecf20Sopenharmony_ci if (flags & EFD_##n) { \ 248c2ecf20Sopenharmony_ci printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \ 258c2ecf20Sopenharmony_ci flags &= ~EFD_##n; \ 268c2ecf20Sopenharmony_ci } 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci P_FLAG(SEMAPHORE); 298c2ecf20Sopenharmony_ci P_FLAG(CLOEXEC); 308c2ecf20Sopenharmony_ci P_FLAG(NONBLOCK); 318c2ecf20Sopenharmony_ci#undef P_FLAG 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci if (flags) 348c2ecf20Sopenharmony_ci printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags); 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci return printed; 378c2ecf20Sopenharmony_ci} 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci#define SCA_EFD_FLAGS syscall_arg__scnprintf_eventfd_flags 40