linux-bk/include/linux/poll.h
<<
>>
Prefs
   1#ifndef _LINUX_POLL_H
   2#define _LINUX_POLL_H
   3
   4#include <asm/poll.h>
   5
   6#ifdef __KERNEL__
   7
   8#include <linux/wait.h>
   9#include <linux/string.h>
  10#include <linux/mm.h>
  11#include <asm/uaccess.h>
  12
  13struct poll_table_struct;
  14
  15/* 
  16 * structures and helpers for f_op->poll implementations
  17 */
  18typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *);
  19
  20typedef struct poll_table_struct {
  21        poll_queue_proc qproc;
  22} poll_table;
  23
  24static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
  25{
  26        if (p && wait_address)
  27                p->qproc(filp, wait_address, p);
  28}
  29
  30static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc)
  31{
  32        pt->qproc = qproc;
  33}
  34
  35/*
  36 * Structures and helpers for sys_poll/sys_poll
  37 */
  38struct poll_wqueues {
  39        poll_table pt;
  40        struct poll_table_page * table;
  41        int error;
  42};
  43
  44extern void poll_initwait(struct poll_wqueues *pwq);
  45extern void poll_freewait(struct poll_wqueues *pwq);
  46
  47/*
  48 * Scaleable version of the fd_set.
  49 */
  50
  51typedef struct {
  52        unsigned long *in, *out, *ex;
  53        unsigned long *res_in, *res_out, *res_ex;
  54} fd_set_bits;
  55
  56/*
  57 * How many longwords for "nr" bits?
  58 */
  59#define FDS_BITPERLONG  (8*sizeof(long))
  60#define FDS_LONGS(nr)   (((nr)+FDS_BITPERLONG-1)/FDS_BITPERLONG)
  61#define FDS_BYTES(nr)   (FDS_LONGS(nr)*sizeof(long))
  62
  63/*
  64 * We do a VERIFY_WRITE here even though we are only reading this time:
  65 * we'll write to it eventually..
  66 *
  67 * Use "unsigned long" accesses to let user-mode fd_set's be long-aligned.
  68 */
  69static inline
  70int get_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset)
  71{
  72        nr = FDS_BYTES(nr);
  73        if (ufdset) {
  74                int error;
  75                error = verify_area(VERIFY_WRITE, ufdset, nr);
  76                if (!error && __copy_from_user(fdset, ufdset, nr))
  77                        error = -EFAULT;
  78                return error;
  79        }
  80        memset(fdset, 0, nr);
  81        return 0;
  82}
  83
  84static inline
  85void set_fd_set(unsigned long nr, void __user *ufdset, unsigned long *fdset)
  86{
  87        if (ufdset)
  88                __copy_to_user(ufdset, fdset, FDS_BYTES(nr));
  89}
  90
  91static inline
  92void zero_fd_set(unsigned long nr, unsigned long *fdset)
  93{
  94        memset(fdset, 0, FDS_BYTES(nr));
  95}
  96
  97extern int do_select(int n, fd_set_bits *fds, long *timeout);
  98
  99#endif /* KERNEL */
 100
 101#endif /* _LINUX_POLL_H */
 102
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.