8 #include <linux/compiler.h>
9 #include <linux/wait.h>
10 #include <linux/string.h>
12 #include <asm/uaccess.h>
14 struct poll_table_struct
;
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
;
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
)
37 * Structures and helpers for sys_poll/sys_poll
41 struct poll_table_page
* table
;
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.
53 unsigned long *in
, *out
, *ex
;
54 unsigned long *res_in
, *res_out
, *res_ex
;
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.
71 int get_fd_set(unsigned long nr
, void __user
*ufdset
, unsigned long *fdset
)
75 return copy_from_user(fdset
, ufdset
, nr
) ? -EFAULT
: 0;
81 static inline unsigned long __must_check
82 set_fd_set(unsigned long nr
, void __user
*ufdset
, unsigned long *fdset
)
85 return __copy_to_user(ufdset
, fdset
, FDS_BYTES(nr
));
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
);
99 #endif /* _LINUX_POLL_H */