patch-2.2.0-pre8 linux/include/linux/poll.h
Next file: linux/include/linux/ppp_defs.h
Previous file: linux/include/linux/pci.h
Back to the patch index
Back to the overall index
- Lines: 109
- Date:
Mon Jan 18 17:35:44 1999
- Orig file:
v2.2.0-pre7/linux/include/linux/poll.h
- Orig date:
Sun Nov 8 14:03:11 1998
diff -u --recursive --new-file v2.2.0-pre7/linux/include/linux/poll.h linux/include/linux/poll.h
@@ -7,6 +7,7 @@
#include <linux/wait.h>
#include <linux/string.h>
+#include <linux/mm.h>
#include <asm/uaccess.h>
@@ -17,11 +18,12 @@
};
typedef struct poll_table_struct {
+ struct poll_table_struct * next;
unsigned int nr;
struct poll_table_entry * entry;
} poll_table;
-#define __MAX_POLL_TABLE_ENTRIES (PAGE_SIZE / sizeof (struct poll_table_entry))
+#define __MAX_POLL_TABLE_ENTRIES ((PAGE_SIZE - sizeof (poll_table)) / sizeof (struct poll_table_entry))
extern inline void poll_wait(struct file * filp, struct wait_queue ** wait_address, poll_table *p)
{
@@ -29,8 +31,18 @@
if (!p || !wait_address)
return;
- if (p->nr >= __MAX_POLL_TABLE_ENTRIES)
- return;
+ while (p->nr >= __MAX_POLL_TABLE_ENTRIES && p->next != NULL)
+ p = p->next;
+ if (p->nr >= __MAX_POLL_TABLE_ENTRIES) {
+ poll_table *tmp = (poll_table *) __get_free_page(GFP_KERNEL);
+ if (!tmp)
+ return;
+ tmp->nr = 0;
+ tmp->entry = (struct poll_table_entry *)(tmp + 1);
+ tmp->next = NULL;
+ p->next = tmp;
+ p = tmp;
+ }
entry = p->entry + p->nr;
entry->filp = filp;
filp->f_count++;
@@ -59,11 +71,30 @@
#define KFDS_NR (KFDS_64BLOCK*8 > NR_OPEN ? NR_OPEN : KFDS_64BLOCK*8)
typedef unsigned long kernel_fd_set[KFDS_NR/__NFDBITS];
+/*
+ * XXX - still used by alpha osf and sparc32 compatiblity.
+ */
+
typedef struct {
kernel_fd_set in, out, ex;
kernel_fd_set res_in, res_out, res_ex;
} fd_set_buffer;
+/*
+ * 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:
@@ -74,8 +105,7 @@
static inline
int get_fd_set(unsigned long nr, void *ufdset, unsigned long *fdset)
{
- /* round up nr to nearest "unsigned long" */
- nr = (nr + 8*sizeof(long) - 1) / (8*sizeof(long)) * sizeof(long);
+ nr = FDS_BYTES(nr);
if (ufdset) {
int error;
error = verify_area(VERIFY_WRITE, ufdset, nr);
@@ -90,20 +120,17 @@
static inline
void set_fd_set(unsigned long nr, void *ufdset, unsigned long *fdset)
{
- if (ufdset) {
- nr = (nr + 8*sizeof(long) - 1) / (8*sizeof(long))*sizeof(long);
- __copy_to_user(ufdset, fdset, nr);
- }
+ if (ufdset)
+ __copy_to_user(ufdset, fdset, FDS_BYTES(nr));
}
static inline
void zero_fd_set(unsigned long nr, unsigned long *fdset)
{
- nr = (nr + 8*sizeof(long) - 1) / (8*sizeof(long)) * sizeof(long);
- memset(fdset, 0, nr);
+ memset(fdset, 0, FDS_BYTES(nr));
}
-extern int do_select(int n, fd_set_buffer *fds, long *timeout);
+extern int do_select(int n, fd_set_bits *fds, long *timeout);
#endif /* KERNEL */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov