eventfd.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 file *eventfd_file_create(unsigned int count, int flags);
  25. struct eventfd_ctx *eventfd_ctx_get(struct eventfd_ctx *ctx);
  26. void eventfd_ctx_put(struct eventfd_ctx *ctx);
  27. struct file *eventfd_fget(int fd);
  28. struct eventfd_ctx *eventfd_ctx_fdget(int fd);
  29. struct eventfd_ctx *eventfd_ctx_fileget(struct file *file);
  30. int eventfd_signal(struct eventfd_ctx *ctx, int n);
  31. #else /* CONFIG_EVENTFD */
  32. /*
  33. * Ugly ugly ugly error layer to support modules that uses eventfd but
  34. * pretend to work in !CONFIG_EVENTFD configurations. Namely, AIO.
  35. */
  36. static inline struct file *eventfd_file_create(unsigned int count, int flags)
  37. {
  38. return ERR_PTR(-ENOSYS);
  39. }
  40. static inline struct eventfd_ctx *eventfd_ctx_fdget(int fd)
  41. {
  42. return ERR_PTR(-ENOSYS);
  43. }
  44. static inline int eventfd_signal(struct eventfd_ctx *ctx, int n)
  45. {
  46. return -ENOSYS;
  47. }
  48. static inline void eventfd_ctx_put(struct eventfd_ctx *ctx)
  49. {
  50. }
  51. #endif
  52. #endif /* _LINUX_EVENTFD_H */