8 #include <linux/wait.h>
9 #include <linux/string.h>
11 #include <asm/uaccess.h>
14 struct poll_table_entry
{
17 wait_queue_head_t
* wait_address
;
20 typedef struct poll_table_struct
{
21 struct poll_table_struct
* next
;
23 struct poll_table_entry
* entry
;
26 #define __MAX_POLL_TABLE_ENTRIES ((PAGE_SIZE - sizeof (poll_table)) / sizeof (struct poll_table_entry))
28 extern void __pollwait(struct file
* filp
, wait_queue_head_t
* wait_address
, poll_table
*p
);
30 extern inline void poll_wait(struct file
* filp
, wait_queue_head_t
* wait_address
, poll_table
*p
)
32 if (p
&& wait_address
)
33 __pollwait(filp
, wait_address
, p
);
37 * For the kernel fd_set we use a fixed set-size for allocation purposes.
38 * This set-size doesn't necessarily bear any relation to the size the user
39 * uses, but should preferably obviously be larger than any possible user
40 * size (NR_OPEN bits).
42 * We need 6 bitmaps (in/out/ex for both incoming and outgoing), and we
43 * allocate one page for all the bitmaps. Thus we have 8*PAGE_SIZE bits,
44 * to be divided by 6. And we'd better make sure we round to a full
45 * long-word (in fact, we'll round to 64 bytes).
49 #define KFDS_64BLOCK ((PAGE_SIZE/(6*64))*64)
50 #define KFDS_NR (KFDS_64BLOCK*8 > NR_OPEN ? NR_OPEN : KFDS_64BLOCK*8)
51 typedef unsigned long kernel_fd_set
[KFDS_NR
/__NFDBITS
];
54 * Scaleable version of the fd_set.
58 unsigned long *in
, *out
, *ex
;
59 unsigned long *res_in
, *res_out
, *res_ex
;
63 * How many longwords for "nr" bits?
65 #define FDS_BITPERLONG (8*sizeof(long))
66 #define FDS_LONGS(nr) (((nr)+FDS_BITPERLONG-1)/FDS_BITPERLONG)
67 #define FDS_BYTES(nr) (FDS_LONGS(nr)*sizeof(long))
70 * We do a VERIFY_WRITE here even though we are only reading this time:
71 * we'll write to it eventually..
73 * Use "unsigned long" accesses to let user-mode fd_set's be long-aligned.
76 int get_fd_set(unsigned long nr
, void *ufdset
, unsigned long *fdset
)
81 error
= verify_area(VERIFY_WRITE
, ufdset
, nr
);
82 if (!error
&& __copy_from_user(fdset
, ufdset
, nr
))
91 void set_fd_set(unsigned long nr
, void *ufdset
, unsigned long *fdset
)
94 __copy_to_user(ufdset
, fdset
, FDS_BYTES(nr
));
98 void zero_fd_set(unsigned long nr
, unsigned long *fdset
)
100 memset(fdset
, 0, FDS_BYTES(nr
));
103 extern int do_select(int n
, fd_set_bits
*fds
, long *timeout
);
107 #endif /* _LINUX_POLL_H */