8 #include <linux/wait.h>
9 #include <linux/string.h>
11 #include <asm/uaccess.h>
13 struct poll_table_struct;
16 * structures and helpers for f_op->poll implementations
18 typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *);
20 typedef struct poll_table_struct {
21 poll_queue_proc qproc;
24 static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
26 if (p && wait_address)
27 p->qproc(filp, wait_address, p);
30 static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc)
36 * Structures and helpers for sys_poll/sys_poll
40 struct poll_table_page * table;
44 extern void poll_initwait(struct poll_wqueues *pwq);
45 extern void poll_freewait(struct poll_wqueues *pwq);
48 * Scaleable version of the fd_set.
52 unsigned long *in, *out, *ex;
53 unsigned long *res_in, *res_out, *res_ex;
57 * How many longwords for "nr" bits?
59 #define FDS_BITPERLONG (8*sizeof(long))
60 #define FDS_LONGS(nr) (((nr)+FDS_BITPERLONG-1)/FDS_BITPERLONG)
61 #define FDS_BYTES(nr) (FDS_LONGS(nr)*sizeof(long))
64 * We do a VERIFY_WRITE here even though we are only reading this time:
65 * we'll write to it eventually..
67 * Use "unsigned long" accesses to let user-mode fd_set's be long-aligned.
70 int get_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset)
75 error = verify_area(VERIFY_WRITE, ufdset, nr);
76 if (!error && __copy_from_user(fdset, ufdset, nr))
85 void set_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset)
88 __copy_to_user(ufdset, fdset, FDS_BYTES(nr));
92 void zero_fd_set(unsigned long nr, unsigned long *fdset)
94 memset(fdset, 0, FDS_BYTES(nr));
97 extern int do_select(int n, fd_set_bits *fds, long *timeout);
101 #endif /* _LINUX_POLL_H */