eventfd.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * include/linux/eventfd.h
  3. *
  4. * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org>
  5. *
  6. */
  7. #ifndef _LINUX_EVENTFD_H
  8. #define _LINUX_EVENTFD_H
  9. #include <linux/fcntl.h>
  10. #include <linux/file.h>
  11. /*
  12. * CAREFUL: Check include/asm-generic/fcntl.h when defining
  13. * new flags, since they might collide with O_* ones. We want
  14. * to re-use O_* flags that couldn't possibly have a meaning
  15. * from eventfd, in order to leave a free define-space for
  16. * shared O_* flags.
  17. */
  18. #define EFD_SEMAPHORE (1 << 0)
  19. #define EFD_CLOEXEC O_CLOEXEC
  20. #define EFD_NONBLOCK O_NONBLOCK
  21. #define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK)
  22. #define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE)
  23. #ifdef CONFIG_EVENTFD
  24. struct eventfd_ctx *eventfd_ctx_get(struct eventfd_ctx *ctx);
  25. void eventfd_ctx_put(struct eventfd_ctx *ctx);
  26. struct file *eventfd_fget(int fd);
  27. struct eventfd_ctx *eventfd_ctx_fdget(int fd);
  28. struct eventfd_ctx *eventfd_ctx_fileget(struct file *file);
  29. int eventfd_signal(struct eventfd_ctx *ctx, int n);
  30. #else /* CONFIG_EVENTFD */
  31. /*
  32. * Ugly ugly ugly error layer to support modules that uses eventfd but
  33. * pretend to work in !CONFIG_EVENTFD configurations. Namely, AIO.
  34. */
  35. static inline struct eventfd_ctx *eventfd_ctx_fdget(int fd)
  36. {
  37. return ERR_PTR(-ENOSYS);
  38. }
  39. static inline int eventfd_signal(struct eventfd_ctx *ctx, int n)
  40. {
  41. return -ENOSYS;
  42. }
  43. static inline void eventfd_ctx_put(struct eventfd_ctx *ctx)
  44. {
  45. }
  46. #endif
  47. #endif /* _LINUX_EVENTFD_H */