The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/include/sys/select.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #ifndef _SYS_SELECT_H
    2 #define _SYS_SELECT_H 1
    3 
    4 #ifndef _POSIX_SOURCE
    5 #define _POSIX_SOURCE 1
    6 #endif
    7 
    8 #include <sys/time.h>
    9 #include <sys/types.h>
   10 #include <limits.h>
   11 #include <string.h>
   12 
   13 /* Use this datatype as basic storage unit in fd_set */
   14 typedef u32_t fd_mask;  
   15 
   16 /* This many bits fit in an fd_set word. */
   17 #define _FDSETBITSPERWORD       (sizeof(fd_mask)*8)
   18 
   19 /* Bit manipulation macros */
   20 #define _FD_BITMASK(b)  (1L << ((b) % _FDSETBITSPERWORD))
   21 #define _FD_BITWORD(b)  ((b)/_FDSETBITSPERWORD)
   22 
   23 /* Default FD_SETSIZE is OPEN_MAX. */
   24 #ifndef FD_SETSIZE
   25 #define FD_SETSIZE              OPEN_MAX
   26 #endif
   27 
   28 /* We want to store FD_SETSIZE bits. */
   29 #define _FDSETWORDS     ((FD_SETSIZE+_FDSETBITSPERWORD-1)/_FDSETBITSPERWORD)
   30 
   31 typedef struct {
   32         fd_mask fds_bits[_FDSETWORDS];
   33 } fd_set;
   34 
   35 _PROTOTYPE( int select, (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout) );
   36 
   37 #define FD_ZERO(s) do { int _i; for(_i = 0; _i < _FDSETWORDS; _i++) { (s)->fds_bits[_i] = 0; } } while(0)
   38 #define FD_SET(f, s) do { (s)->fds_bits[_FD_BITWORD(f)] |= _FD_BITMASK(f); } while(0)
   39 #define FD_CLR(f, s) do { (s)->fds_bits[_FD_BITWORD(f)] &= ~(_FD_BITMASK(f)); } while(0)
   40 #define FD_ISSET(f, s) ((s)->fds_bits[_FD_BITWORD(f)] & _FD_BITMASK(f))
   41 
   42 /* possible select() operation types; read, write, errors */
   43 /* (FS/driver internal use only) */
   44 #define SEL_RD          (1 << 0)
   45 #define SEL_WR          (1 << 1)
   46 #define SEL_ERR         (1 << 2)
   47 #define SEL_NOTIFY      (1 << 3) /* not a real select operation */
   48 
   49 #endif /* _SYS_SELECT_H */
   50 

Cache object: 8b1fd164c2dd101453f6c27ae6e9de0c


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.