eventfd.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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/wait.h>
  11. /*
  12. * CAREFUL: Check include/uapi/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. struct file;
  24. #ifdef CONFIG_EVENTFD
  25. struct file *eventfd_file_create(unsigned int count, int flags);
  26. struct eventfd_ctx *eventfd_ctx_get(struct eventfd_ctx *ctx);
  27. void eventfd_ctx_put(struct eventfd_ctx *ctx);
  28. struct file *eventfd_fget(int fd);
  29. struct eventfd_ctx *eventfd_ctx_fdget(int fd);
  30. struct eventfd_ctx *eventfd_ctx_fileget(struct file *file);
  31. __u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n);
  32. ssize_t eventfd_ctx_read(struct eventfd_ctx *ctx, int no_wait, __u64 *cnt);
  33. int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_t *wait,
  34. __u64 *cnt);
  35. #else /* CONFIG_EVENTFD */
  36. /*
  37. * Ugly ugly ugly error layer to support modules that uses eventfd but
  38. * pretend to work in !CONFIG_EVENTFD configurations. Namely, AIO.
  39. */
  40. static inline struct file *eventfd_file_create(unsigned int count, int flags)
  41. {
  42. return ERR_PTR(-ENOSYS);
  43. }
  44. static inline struct eventfd_ctx *eventfd_ctx_fdget(int fd)
  45. {
  46. return ERR_PTR(-ENOSYS);
  47. }
  48. static inline int eventfd_signal(struct eventfd_ctx *ctx, int n)
  49. {
  50. return -ENOSYS;
  51. }
  52. static inline void eventfd_ctx_put(struct eventfd_ctx *ctx)
  53. {
  54. }
  55. static inline ssize_t eventfd_ctx_read(struct eventfd_ctx *ctx, int no_wait,
  56. __u64 *cnt)
  57. {
  58. return -ENOSYS;
  59. }
  60. static inline int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx,
  61. wait_queue_t *wait, __u64 *cnt)
  62. {
  63. return -ENOSYS;
  64. }
  65. #endif
  66. #endif /* _LINUX_EVENTFD_H */