Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 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
 
13
struct poll_table_struct;
14
 
15
/*
16
 * structures and helpers for f_op->poll implementations
17
 */
18
typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *);
19
 
20
typedef struct poll_table_struct {
21
        poll_queue_proc qproc;
22
} poll_table;
23
 
24
static 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
 
30
static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc)
31
{
32
        pt->qproc = qproc;
33
}
34
 
35
/*
36
 * Structures and helpers for sys_poll/sys_poll
37
 */
38
struct poll_wqueues {
39
        poll_table pt;
40
        struct poll_table_page * table;
41
        int error;
42
};
43
 
44
extern void poll_initwait(struct poll_wqueues *pwq);
45
extern void poll_freewait(struct poll_wqueues *pwq);
46
 
47
/*
48
 * Scaleable version of the fd_set.
49
 */
50
 
51
typedef struct {
52
        unsigned long *in, *out, *ex;
53
        unsigned long *res_in, *res_out, *res_ex;
54
} fd_set_bits;
55
 
56
/*
57
 * How many longwords for "nr" bits?
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
 * We do a VERIFY_WRITE here even though we are only reading this time:
65
 * we'll write to it eventually..
66
 *
67
 * Use "unsigned long" accesses to let user-mode fd_set's be long-aligned.
68
 */
69
static inline
70
int 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
 
84
static inline
85
void 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
 
91
static inline
92
void zero_fd_set(unsigned long nr, unsigned long *fdset)
93
{
94
        memset(fdset, 0, FDS_BYTES(nr));
95
}
96
 
97
extern int do_select(int n, fd_set_bits *fds, long *timeout);
98
 
99
#endif /* KERNEL */
100
 
101
#endif /* _LINUX_POLL_H */