static int do_poll(unsigned int nfds, unsigned int nchunks, unsigned int nleft, struct pollfd *fds[], poll_table *wait, long timeout) { int count; poll_table* pt = wait; for (;;) { unsigned int i; set_current_state(TASK_INTERRUPTIBLE); count = 0; for (i=0; i < nchunks; i++) do_pollfd(POLLFD_PER_PAGE, fds[i], &pt, &count); if (nleft) do_pollfd(nleft, fds[nchunks], &pt, &count); pt = NULL; if (count || !timeout || signal_pending(current)) break; count = wait->error; if (count) break; timeout = schedule_timeout(timeout); } current->state = TASK_RUNNING; return count; }
static int do_poll(unsigned int nfds, struct poll_list *list, struct poll_wqueues *wait, long timeout) { int count = 0; poll_table* pt = &wait->pt; if (!timeout) pt = NULL; for (;;) { struct poll_list *walk; set_current_state(TASK_INTERRUPTIBLE); walk = list; while(walk != NULL) { do_pollfd( walk->len, walk->entries, &pt, &count); walk = walk->next; } pt = NULL; if (count || !timeout || signal_pending(current)) break; count = wait->error; if (count) break; timeout = schedule_timeout(timeout); } __set_current_state(TASK_RUNNING); return count; }