| 1 | /* $Id: poll.h,v 1.1.1.1 2003/07/02 13:57:00 eleph Exp $ */ | 
|---|
| 2 |  | 
|---|
| 3 | #ifndef _LINUX_POLL_H | 
|---|
| 4 | #define _LINUX_POLL_H | 
|---|
| 5 |  | 
|---|
| 6 | #include <asm/poll.h> | 
|---|
| 7 | #include <linux/mm.h> | 
|---|
| 8 | #include <asm/uaccess.h> | 
|---|
| 9 | #include <linux/wait.h> | 
|---|
| 10 | #include <linux/fs.h> | 
|---|
| 11 |  | 
|---|
| 12 | #ifdef __KERNEL__ | 
|---|
| 13 |  | 
|---|
| 14 | struct poll_table_entry { | 
|---|
| 15 | struct file * filp; | 
|---|
| 16 | wait_queue_t wait; | 
|---|
| 17 | wait_queue_head_t * wait_address; | 
|---|
| 18 | }; | 
|---|
| 19 |  | 
|---|
| 20 | typedef struct poll_table_struct { | 
|---|
| 21 | struct poll_table_struct * next; | 
|---|
| 22 | unsigned int nr; | 
|---|
| 23 | struct poll_table_entry * entry; | 
|---|
| 24 | } poll_table; | 
|---|
| 25 |  | 
|---|
| 26 | #define __MAX_POLL_TABLE_ENTRIES ((PAGE_SIZE - sizeof (poll_table)) / sizeof (struct poll_table_entry)) | 
|---|
| 27 |  | 
|---|
| 28 | void init_waitqueue_head(wait_queue_head_t *q); | 
|---|
| 29 |  | 
|---|
| 30 | extern void __pollwait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p); | 
|---|
| 31 |  | 
|---|
| 32 | extern void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p); | 
|---|
| 33 |  | 
|---|
| 34 | /* | 
|---|
| 35 | * For the kernel fd_set we use a fixed set-size for allocation purposes. | 
|---|
| 36 | * This set-size doesn't necessarily bear any relation to the size the user | 
|---|
| 37 | * uses, but should preferably obviously be larger than any possible user | 
|---|
| 38 | * size (NR_OPEN bits). | 
|---|
| 39 | * | 
|---|
| 40 | * We need 6 bitmaps (in/out/ex for both incoming and outgoing), and we | 
|---|
| 41 | * allocate one page for all the bitmaps. Thus we have 8*PAGE_SIZE bits, | 
|---|
| 42 | * to be divided by 6. And we'd better make sure we round to a full | 
|---|
| 43 | * long-word (in fact, we'll round to 64 bytes). | 
|---|
| 44 | */ | 
|---|
| 45 |  | 
|---|
| 46 |  | 
|---|
| 47 | #define KFDS_64BLOCK ((PAGE_SIZE/(6*64))*64) | 
|---|
| 48 | #define KFDS_NR (KFDS_64BLOCK*8 > NR_OPEN ? NR_OPEN : KFDS_64BLOCK*8) | 
|---|
| 49 | typedef unsigned long kernel_fd_set[KFDS_NR/__NFDBITS]; | 
|---|
| 50 |  | 
|---|
| 51 | /* | 
|---|
| 52 | * Scaleable version of the fd_set. | 
|---|
| 53 | */ | 
|---|
| 54 |  | 
|---|
| 55 | typedef struct { | 
|---|
| 56 | unsigned long *in, *out, *ex; | 
|---|
| 57 | unsigned long *res_in, *res_out, *res_ex; | 
|---|
| 58 | } fd_set_bits; | 
|---|
| 59 |  | 
|---|
| 60 | /* | 
|---|
| 61 | * How many longwords for "nr" bits? | 
|---|
| 62 | */ | 
|---|
| 63 | #define FDS_BITPERLONG  (8*sizeof(long)) | 
|---|
| 64 | #define FDS_LONGS(nr)   (((nr)+FDS_BITPERLONG-1)/FDS_BITPERLONG) | 
|---|
| 65 | #define FDS_BYTES(nr)   (FDS_LONGS(nr)*sizeof(long)) | 
|---|
| 66 |  | 
|---|
| 67 | /* | 
|---|
| 68 | * We do a VERIFY_WRITE here even though we are only reading this time: | 
|---|
| 69 | * we'll write to it eventually.. | 
|---|
| 70 | * | 
|---|
| 71 | * Use "unsigned long" accesses to let user-mode fd_set's be long-aligned. | 
|---|
| 72 | */ | 
|---|
| 73 | static int get_fd_set(unsigned long nr, void *ufdset, unsigned long *fdset); | 
|---|
| 74 |  | 
|---|
| 75 | static void set_fd_set(unsigned long nr, void *ufdset, unsigned long *fdset); | 
|---|
| 76 |  | 
|---|
| 77 | static void zero_fd_set(unsigned long nr, unsigned long *fdset); | 
|---|
| 78 |  | 
|---|
| 79 | extern int do_select(int n, fd_set_bits *fds, long *timeout); | 
|---|
| 80 |  | 
|---|
| 81 | #endif /* KERNEL */ | 
|---|
| 82 |  | 
|---|
| 83 | #endif /* _LINUX_POLL_H */ | 
|---|