Davide Libenzi | e1ad746 | 2007-05-10 22:23:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * include/linux/eventfd.h |
| 3 | * |
| 4 | * Copyright (C) 2007 Davide Libenzi <davidel@xmailserver.org> |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef _LINUX_EVENTFD_H |
| 9 | #define _LINUX_EVENTFD_H |
| 10 | |
Davide Libenzi | e1ad746 | 2007-05-10 22:23:19 -0700 | [diff] [blame] | 11 | #ifdef CONFIG_EVENTFD |
| 12 | |
Ulrich Drepper | e7d476d | 2008-07-23 21:29:38 -0700 | [diff] [blame] | 13 | /* For O_CLOEXEC and O_NONBLOCK */ |
Ulrich Drepper | b087498e | 2008-07-23 21:29:25 -0700 | [diff] [blame] | 14 | #include <linux/fcntl.h> |
| 15 | |
Davide Libenzi | bcd0b23 | 2009-03-31 15:24:18 -0700 | [diff] [blame] | 16 | /* |
| 17 | * CAREFUL: Check include/asm-generic/fcntl.h when defining |
| 18 | * new flags, since they might collide with O_* ones. We want |
| 19 | * to re-use O_* flags that couldn't possibly have a meaning |
| 20 | * from eventfd, in order to leave a free define-space for |
| 21 | * shared O_* flags. |
| 22 | */ |
| 23 | #define EFD_SEMAPHORE (1 << 0) |
Ulrich Drepper | b087498e | 2008-07-23 21:29:25 -0700 | [diff] [blame] | 24 | #define EFD_CLOEXEC O_CLOEXEC |
Ulrich Drepper | e7d476d | 2008-07-23 21:29:38 -0700 | [diff] [blame] | 25 | #define EFD_NONBLOCK O_NONBLOCK |
Ulrich Drepper | b087498e | 2008-07-23 21:29:25 -0700 | [diff] [blame] | 26 | |
Davide Libenzi | bcd0b23 | 2009-03-31 15:24:18 -0700 | [diff] [blame] | 27 | #define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK) |
| 28 | #define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE) |
| 29 | |
Davide Libenzi | e1ad746 | 2007-05-10 22:23:19 -0700 | [diff] [blame] | 30 | struct file *eventfd_fget(int fd); |
| 31 | int eventfd_signal(struct file *file, int n); |
| 32 | |
| 33 | #else /* CONFIG_EVENTFD */ |
| 34 | |
| 35 | #define eventfd_fget(fd) ERR_PTR(-ENOSYS) |
Randy Dunlap | d2fd899 | 2007-06-27 14:09:48 -0700 | [diff] [blame] | 36 | static inline int eventfd_signal(struct file *file, int n) |
| 37 | { return 0; } |
Davide Libenzi | e1ad746 | 2007-05-10 22:23:19 -0700 | [diff] [blame] | 38 | |
| 39 | #endif /* CONFIG_EVENTFD */ |
| 40 | |
Davide Libenzi | e1ad746 | 2007-05-10 22:23:19 -0700 | [diff] [blame] | 41 | #endif /* _LINUX_EVENTFD_H */ |
| 42 | |