0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LINUX_EVENTFD_H
0010 #define _LINUX_EVENTFD_H
0011
0012 #include <linux/fcntl.h>
0013 #include <linux/wait.h>
0014 #include <linux/err.h>
0015 #include <linux/percpu-defs.h>
0016 #include <linux/percpu.h>
0017 #include <linux/sched.h>
0018
0019
0020
0021
0022
0023
0024
0025
0026 #define EFD_SEMAPHORE (1 << 0)
0027 #define EFD_CLOEXEC O_CLOEXEC
0028 #define EFD_NONBLOCK O_NONBLOCK
0029
0030 #define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK)
0031 #define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE)
0032
0033 struct eventfd_ctx;
0034 struct file;
0035
0036 #ifdef CONFIG_EVENTFD
0037
0038 void eventfd_ctx_put(struct eventfd_ctx *ctx);
0039 struct file *eventfd_fget(int fd);
0040 struct eventfd_ctx *eventfd_ctx_fdget(int fd);
0041 struct eventfd_ctx *eventfd_ctx_fileget(struct file *file);
0042 __u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n);
0043 int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_entry_t *wait,
0044 __u64 *cnt);
0045 void eventfd_ctx_do_read(struct eventfd_ctx *ctx, __u64 *cnt);
0046
0047 static inline bool eventfd_signal_allowed(void)
0048 {
0049 return !current->in_eventfd_signal;
0050 }
0051
0052 #else
0053
0054
0055
0056
0057
0058
0059 static inline struct eventfd_ctx *eventfd_ctx_fdget(int fd)
0060 {
0061 return ERR_PTR(-ENOSYS);
0062 }
0063
0064 static inline int eventfd_signal(struct eventfd_ctx *ctx, int n)
0065 {
0066 return -ENOSYS;
0067 }
0068
0069 static inline void eventfd_ctx_put(struct eventfd_ctx *ctx)
0070 {
0071
0072 }
0073
0074 static inline int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx,
0075 wait_queue_entry_t *wait, __u64 *cnt)
0076 {
0077 return -ENOSYS;
0078 }
0079
0080 static inline bool eventfd_signal_allowed(void)
0081 {
0082 return true;
0083 }
0084
0085 static inline void eventfd_ctx_do_read(struct eventfd_ctx *ctx, __u64 *cnt)
0086 {
0087
0088 }
0089
0090 #endif
0091
0092 #endif
0093