eventfd.c 817 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // SPDX-License-Identifier: GPL-2.0
  2. #ifndef EFD_SEMAPHORE
  3. #define EFD_SEMAPHORE 1
  4. #endif
  5. #ifndef EFD_NONBLOCK
  6. #define EFD_NONBLOCK 00004000
  7. #endif
  8. #ifndef EFD_CLOEXEC
  9. #define EFD_CLOEXEC 02000000
  10. #endif
  11. static size_t syscall_arg__scnprintf_eventfd_flags(char *bf, size_t size, struct syscall_arg *arg)
  12. {
  13. int printed = 0, flags = arg->val;
  14. if (flags == 0)
  15. return scnprintf(bf, size, "NONE");
  16. #define P_FLAG(n) \
  17. if (flags & EFD_##n) { \
  18. printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", #n); \
  19. flags &= ~EFD_##n; \
  20. }
  21. P_FLAG(SEMAPHORE);
  22. P_FLAG(CLOEXEC);
  23. P_FLAG(NONBLOCK);
  24. #undef P_FLAG
  25. if (flags)
  26. printed += scnprintf(bf + printed, size - printed, "%s%#x", printed ? "|" : "", flags);
  27. return printed;
  28. }
  29. #define SCA_EFD_FLAGS syscall_arg__scnprintf_eventfd_flags