home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / select.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  1.4 KB  |  49 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ifndef _SYS_SELECT_H
  11. #define _SYS_SELECT_H
  12.  
  13. #ident    "@(#)/usr/include/sys/select.h.sl 1.1 4.0 12/08/90 49577 AT&T-USL"
  14.  
  15. /*
  16.  * Select uses bit masks of file descriptors in longs.
  17.  * These macros manipulate such bit fields.
  18.  * FD_SETSIZE may be defined by the user, but the default here
  19.  * should be >= NOFILE (param.h).
  20.  */
  21. #ifndef    FD_SETSIZE
  22. #define    FD_SETSIZE    1024
  23. #endif
  24.  
  25. #ifndef NBBY        /* number of bits per byte */
  26. #define NBBY 8
  27. #endif
  28.  
  29. typedef    long    fd_mask;
  30. #define    NFDBITS    (sizeof(fd_mask) * NBBY)    /* bits per mask */
  31. #ifndef    howmany
  32. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  33. #endif
  34.  
  35. typedef    struct fd_set {
  36.     fd_mask    fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  37. } fd_set;
  38.  
  39. #define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  40. #define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  41. #define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  42. #ifdef _KERNEL
  43. #define    FD_ZERO(p)    bzero((char *)(p), sizeof(*(p)))
  44. #else
  45. #define    FD_ZERO(p)    memset((char *)(p), 0, sizeof(*(p)))
  46. #endif /* _KERNEL */
  47.  
  48. #endif    /* _SYS_SELECT_H */
  49.