blob: f45a8ae5f8281bc51348b942a36899b8355f13d9 [file] [log] [blame]
Davide Libenzie1ad7462007-05-10 22:23:19 -07001/*
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 Libenzie1ad7462007-05-10 22:23:19 -070011#ifdef CONFIG_EVENTFD
12
Ulrich Dreppere7d476d2008-07-23 21:29:38 -070013/* For O_CLOEXEC and O_NONBLOCK */
Ulrich Drepperb087498e2008-07-23 21:29:25 -070014#include <linux/fcntl.h>
15
Davide Libenzibcd0b232009-03-31 15:24:18 -070016/*
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 Drepperb087498e2008-07-23 21:29:25 -070024#define EFD_CLOEXEC O_CLOEXEC
Ulrich Dreppere7d476d2008-07-23 21:29:38 -070025#define EFD_NONBLOCK O_NONBLOCK
Ulrich Drepperb087498e2008-07-23 21:29:25 -070026
Davide Libenzibcd0b232009-03-31 15:24:18 -070027#define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK)
28#define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE)
29
Davide Libenzie1ad7462007-05-10 22:23:19 -070030struct file *eventfd_fget(int fd);
31int eventfd_signal(struct file *file, int n);
32
33#else /* CONFIG_EVENTFD */
34
35#define eventfd_fget(fd) ERR_PTR(-ENOSYS)
Randy Dunlapd2fd8992007-06-27 14:09:48 -070036static inline int eventfd_signal(struct file *file, int n)
37{ return 0; }
Davide Libenzie1ad7462007-05-10 22:23:19 -070038
39#endif /* CONFIG_EVENTFD */
40
Davide Libenzie1ad7462007-05-10 22:23:19 -070041#endif /* _LINUX_EVENTFD_H */
42