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_struct;
14
15
16
17
18typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *);
19
20typedef struct poll_table_struct {
21 poll_queue_proc qproc;
22} poll_table;
23
24static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
25{
26 if (p && wait_address)
27 p->qproc(filp, wait_address, p);
28}
29
30static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc)
31{
32 pt->qproc = qproc;
33}
34
35
36
37
38struct poll_wqueues {
39 poll_table pt;
40 struct poll_table_page * table;
41 int error;
42};
43
44extern void poll_initwait(struct poll_wqueues *pwq);
45extern void poll_freewait(struct poll_wqueues *pwq);
46
47
48
49
50
51typedef struct {
52 unsigned long *in, *out, *ex;
53 unsigned long *res_in, *res_out, *res_ex;
54} fd_set_bits;
55
56
57
58
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))
62
63
64
65
66
67
68
69static inline
70int get_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset)
71{
72 nr = FDS_BYTES(nr);
73 if (ufdset) {
74 int error;
75 error = verify_area(VERIFY_WRITE, ufdset, nr);
76 if (!error && __copy_from_user(fdset, ufdset, nr))
77 error = -EFAULT;
78 return error;
79 }
80 memset(fdset, 0, nr);
81 return 0;
82}
83
84static inline
85void set_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset)
86{
87 if (ufdset)
88 __copy_to_user(ufdset, fdset, FDS_BYTES(nr));
89}
90
91static inline
92void zero_fd_set(unsigned long nr, unsigned long *fdset)
93{
94 memset(fdset, 0, FDS_BYTES(nr));
95}
96
97extern int do_select(int n, fd_set_bits *fds, long *timeout);
98
99#endif
100
101#endif
102