Automatic merge of rsync://rsync.kernel.org/pub/scm/linux/kernel/git/gregkh/driver...
[linux-2.6/verdex.git] / include / linux / poll.h
blobf6da702088f413b3d73c381f2b758c84f487691d
1 #ifndef _LINUX_POLL_H
2 #define _LINUX_POLL_H
4 #include <asm/poll.h>
6 #ifdef __KERNEL__
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>
14 struct poll_table_struct;
16 /*
17 * structures and helpers for f_op->poll implementations
19 typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *);
21 typedef struct poll_table_struct {
22 poll_queue_proc qproc;
23 } poll_table;
25 static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
27 if (p && wait_address)
28 p->qproc(filp, wait_address, p);
31 static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc)
33 pt->qproc = qproc;
37 * Structures and helpers for sys_poll/sys_poll
39 struct poll_wqueues {
40 poll_table pt;
41 struct poll_table_page * table;
42 int error;
45 extern void poll_initwait(struct poll_wqueues *pwq);
46 extern void poll_freewait(struct poll_wqueues *pwq);
49 * Scaleable version of the fd_set.
52 typedef struct {
53 unsigned long *in, *out, *ex;
54 unsigned long *res_in, *res_out, *res_ex;
55 } fd_set_bits;
58 * How many longwords for "nr" bits?
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))
65 * We do a VERIFY_WRITE here even though we are only reading this time:
66 * we'll write to it eventually..
68 * Use "unsigned long" accesses to let user-mode fd_set's be long-aligned.
70 static inline
71 int get_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset)
73 nr = FDS_BYTES(nr);
74 if (ufdset)
75 return copy_from_user(fdset, ufdset, nr) ? -EFAULT : 0;
77 memset(fdset, 0, nr);
78 return 0;
81 static inline unsigned long __must_check
82 set_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset)
84 if (ufdset)
85 return __copy_to_user(ufdset, fdset, FDS_BYTES(nr));
86 return 0;
89 static inline
90 void zero_fd_set(unsigned long nr, unsigned long *fdset)
92 memset(fdset, 0, FDS_BYTES(nr));
95 extern int do_select(int n, fd_set_bits *fds, long *timeout);
97 #endif /* KERNEL */
99 #endif /* _LINUX_POLL_H */