Blame view
include/linux/poll.h
3.62 KB
1da177e4c
|
1 2 3 4 5 6 7 8 |
#ifndef _LINUX_POLL_H #define _LINUX_POLL_H #include <asm/poll.h> #ifdef __KERNEL__ #include <linux/compiler.h> |
a99bbaf5e
|
9 |
#include <linux/ktime.h> |
1da177e4c
|
10 11 |
#include <linux/wait.h> #include <linux/string.h> |
f23f6e08c
|
12 |
#include <linux/fs.h> |
9ff993394
|
13 |
#include <linux/sysctl.h> |
1da177e4c
|
14 |
#include <asm/uaccess.h> |
9ff993394
|
15 |
extern struct ctl_table epoll_table[]; /* for sysctl */ |
70674f95c
|
16 17 18 19 20 21 22 23 |
/* ~832 bytes of stack space used max in sys_select/sys_poll before allocating additional memory. */ #define MAX_STACK_ALLOC 832 #define FRONTEND_STACK_ALLOC 256 #define SELECT_STACK_ALLOC FRONTEND_STACK_ALLOC #define POLL_STACK_ALLOC FRONTEND_STACK_ALLOC #define WQUEUES_STACK_ALLOC (MAX_STACK_ALLOC - FRONTEND_STACK_ALLOC) #define N_INLINE_POLL_ENTRIES (WQUEUES_STACK_ALLOC / sizeof(struct poll_table_entry)) |
dd23aae4f
|
24 |
#define DEFAULT_POLLMASK (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM) |
1da177e4c
|
25 26 27 28 29 30 31 32 33 |
struct poll_table_struct; /* * structures and helpers for f_op->poll implementations */ typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *); typedef struct poll_table_struct { poll_queue_proc qproc; |
4938d7e02
|
34 |
unsigned long key; |
1da177e4c
|
35 36 37 38 39 40 41 42 43 44 45 |
} poll_table; static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p) { if (p && wait_address) p->qproc(filp, wait_address, p); } static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc) { pt->qproc = qproc; |
4938d7e02
|
46 |
pt->key = ~0UL; /* all events enabled */ |
1da177e4c
|
47 |
} |
70674f95c
|
48 |
struct poll_table_entry { |
5f820f648
|
49 |
struct file *filp; |
4938d7e02
|
50 |
unsigned long key; |
70674f95c
|
51 |
wait_queue_t wait; |
5f820f648
|
52 |
wait_queue_head_t *wait_address; |
70674f95c
|
53 |
}; |
1da177e4c
|
54 55 56 57 58 |
/* * Structures and helpers for sys_poll/sys_poll */ struct poll_wqueues { poll_table pt; |
5f820f648
|
59 60 61 |
struct poll_table_page *table; struct task_struct *polling_task; int triggered; |
1da177e4c
|
62 |
int error; |
70674f95c
|
63 64 |
int inline_index; struct poll_table_entry inline_entries[N_INLINE_POLL_ENTRIES]; |
1da177e4c
|
65 66 67 68 |
}; extern void poll_initwait(struct poll_wqueues *pwq); extern void poll_freewait(struct poll_wqueues *pwq); |
5f820f648
|
69 70 71 72 73 74 75 |
extern int poll_schedule_timeout(struct poll_wqueues *pwq, int state, ktime_t *expires, unsigned long slack); static inline int poll_schedule(struct poll_wqueues *pwq, int state) { return poll_schedule_timeout(pwq, state, NULL, 0); } |
1da177e4c
|
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
/* * Scaleable version of the fd_set. */ typedef struct { unsigned long *in, *out, *ex; unsigned long *res_in, *res_out, *res_ex; } fd_set_bits; /* * How many longwords for "nr" bits? */ #define FDS_BITPERLONG (8*sizeof(long)) #define FDS_LONGS(nr) (((nr)+FDS_BITPERLONG-1)/FDS_BITPERLONG) #define FDS_BYTES(nr) (FDS_LONGS(nr)*sizeof(long)) /* * We do a VERIFY_WRITE here even though we are only reading this time: * we'll write to it eventually.. * * Use "unsigned long" accesses to let user-mode fd_set's be long-aligned. */ static inline int get_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset) { nr = FDS_BYTES(nr); if (ufdset) return copy_from_user(fdset, ufdset, nr) ? -EFAULT : 0; memset(fdset, 0, nr); return 0; } static inline unsigned long __must_check set_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset) { if (ufdset) return __copy_to_user(ufdset, fdset, FDS_BYTES(nr)); return 0; } static inline void zero_fd_set(unsigned long nr, unsigned long *fdset) { memset(fdset, 0, FDS_BYTES(nr)); } |
9f72949f6
|
123 |
#define MAX_INT64_SECONDS (((s64)(~((u64)0)>>1)/HZ)-1) |
8ff3e8e85
|
124 |
extern int do_select(int n, fd_set_bits *fds, struct timespec *end_time); |
9f72949f6
|
125 |
extern int do_sys_poll(struct pollfd __user * ufds, unsigned int nfds, |
8ff3e8e85
|
126 |
struct timespec *end_time); |
a2dcb44c3
|
127 |
extern int core_sys_select(int n, fd_set __user *inp, fd_set __user *outp, |
8ff3e8e85
|
128 |
fd_set __user *exp, struct timespec *end_time); |
1da177e4c
|
129 |
|
b773ad40a
|
130 |
extern int poll_select_set_timeout(struct timespec *to, long sec, long nsec); |
1da177e4c
|
131 132 133 |
#endif /* KERNEL */ #endif /* _LINUX_POLL_H */ |