diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /include/linux/poll.h |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'include/linux/poll.h')
-rw-r--r-- | include/linux/poll.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/include/linux/poll.h b/include/linux/poll.h new file mode 100644 index 000000000000..f6da702088f4 --- /dev/null +++ b/include/linux/poll.h | |||
@@ -0,0 +1,99 @@ | |||
1 | #ifndef _LINUX_POLL_H | ||
2 | #define _LINUX_POLL_H | ||
3 | |||
4 | #include <asm/poll.h> | ||
5 | |||
6 | #ifdef __KERNEL__ | ||
7 | |||
8 | #include <linux/compiler.h> | ||
9 | #include <linux/wait.h> | ||
10 | #include <linux/string.h> | ||
11 | #include <linux/mm.h> | ||
12 | #include <asm/uaccess.h> | ||
13 | |||
14 | struct poll_table_struct; | ||
15 | |||
16 | /* | ||
17 | * structures and helpers for f_op->poll implementations | ||
18 | */ | ||
19 | typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *); | ||
20 | |||
21 | typedef struct poll_table_struct { | ||
22 | poll_queue_proc qproc; | ||
23 | } poll_table; | ||
24 | |||
25 | static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p) | ||
26 | { | ||
27 | if (p && wait_address) | ||
28 | p->qproc(filp, wait_address, p); | ||
29 | } | ||
30 | |||
31 | static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc) | ||
32 | { | ||
33 | pt->qproc = qproc; | ||
34 | } | ||
35 | |||
36 | /* | ||
37 | * Structures and helpers for sys_poll/sys_poll | ||
38 | */ | ||
39 | struct poll_wqueues { | ||
40 | poll_table pt; | ||
41 | struct poll_table_page * table; | ||
42 | int error; | ||
43 | }; | ||
44 | |||
45 | extern void poll_initwait(struct poll_wqueues *pwq); | ||
46 | extern void poll_freewait(struct poll_wqueues *pwq); | ||
47 | |||
48 | /* | ||
49 | * Scaleable version of the fd_set. | ||
50 | */ | ||
51 | |||
52 | typedef struct { | ||
53 | unsigned long *in, *out, *ex; | ||
54 | unsigned long *res_in, *res_out, *res_ex; | ||
55 | } fd_set_bits; | ||
56 | |||
57 | /* | ||
58 | * How many longwords for "nr" bits? | ||
59 | */ | ||
60 | #define FDS_BITPERLONG (8*sizeof(long)) | ||
61 | #define FDS_LONGS(nr) (((nr)+FDS_BITPERLONG-1)/FDS_BITPERLONG) | ||
62 | #define FDS_BYTES(nr) (FDS_LONGS(nr)*sizeof(long)) | ||
63 | |||
64 | /* | ||
65 | * We do a VERIFY_WRITE here even though we are only reading this time: | ||
66 | * we'll write to it eventually.. | ||
67 | * | ||
68 | * Use "unsigned long" accesses to let user-mode fd_set's be long-aligned. | ||
69 | */ | ||
70 | static inline | ||
71 | int get_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset) | ||
72 | { | ||
73 | nr = FDS_BYTES(nr); | ||
74 | if (ufdset) | ||
75 | return copy_from_user(fdset, ufdset, nr) ? -EFAULT : 0; | ||
76 | |||
77 | memset(fdset, 0, nr); | ||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | static inline unsigned long __must_check | ||
82 | set_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset) | ||
83 | { | ||
84 | if (ufdset) | ||
85 | return __copy_to_user(ufdset, fdset, FDS_BYTES(nr)); | ||
86 | return 0; | ||
87 | } | ||
88 | |||
89 | static inline | ||
90 | void zero_fd_set(unsigned long nr, unsigned long *fdset) | ||
91 | { | ||
92 | memset(fdset, 0, FDS_BYTES(nr)); | ||
93 | } | ||
94 | |||
95 | extern int do_select(int n, fd_set_bits *fds, long *timeout); | ||
96 | |||
97 | #endif /* KERNEL */ | ||
98 | |||
99 | #endif /* _LINUX_POLL_H */ | ||