1#ifndef _LINUX_POLL_H
2#define _LINUX_POLL_H
3
4#include <asm/poll.h>
5
6#ifdef __KERNEL__
7
8#include <linux/wait.h>
9#include <linux/string.h>
10#include <linux/mm.h>
11#include <asm/uaccess.h>
12
13struct poll_table_page;
14
15typedef struct poll_table_struct {
16 int error;
17 struct poll_table_page * table;
18} poll_table;
19
20extern void __pollwait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p);
21
22static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
23{
24 if (p && wait_address)
25 __pollwait(filp, wait_address, p);
26}
27
28static inline void poll_initwait(poll_table* pt)
29{
30 pt->error = 0;
31 pt->table = NULL;
32}
33extern void poll_freewait(poll_table* pt);
34
35
36
37
38
39
40typedef struct {
41 unsigned long *in, *out, *ex;
42 unsigned long *res_in, *res_out, *res_ex;
43} fd_set_bits;
44
45
46
47
48#define FDS_BITPERLONG (8*sizeof(long))
49#define FDS_LONGS(nr) (((nr)+FDS_BITPERLONG-1)/FDS_BITPERLONG)
50#define FDS_BYTES(nr) (FDS_LONGS(nr)*sizeof(long))
51
52
53
54
55
56
57
58static inline
59int get_fd_set(unsigned long nr, void *ufdset, unsigned long *fdset)
60{
61 nr = FDS_BYTES(nr);
62 if (ufdset) {
63 int error;
64 error = verify_area(VERIFY_WRITE, ufdset, nr);
65 if (!error && __copy_from_user(fdset, ufdset, nr))
66 error = -EFAULT;
67 return error;
68 }
69 memset(fdset, 0, nr);
70 return 0;
71}
72
73static inline
74void set_fd_set(unsigned long nr, void *ufdset, unsigned long *fdset)
75{
76 if (ufdset)
77 __copy_to_user(ufdset, fdset, FDS_BYTES(nr));
78}
79
80static inline
81void zero_fd_set(unsigned long nr, unsigned long *fdset)
82{
83 memset(fdset, 0, FDS_BYTES(nr));
84}
85
86extern int do_select(int n, fd_set_bits *fds, long *timeout);
87
88#endif
89
90#endif
91