home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / Xt / fd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-05  |  2.5 KB  |  76 lines

  1. /*
  2. * $XConsortium: fd.h,v 1.14 89/10/05 13:32:53 swick Exp $
  3. * $oHeader: fd.h,v 1.4 88/08/26 14:49:54 asente Exp $
  4. */
  5.  
  6. /***********************************************************
  7. Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  8. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  9.  
  10.                         All Rights Reserved
  11.  
  12. Permission to use, copy, modify, and distribute this software and its 
  13. documentation for any purpose and without fee is hereby granted, 
  14. provided that the above copyright notice appear in all copies and that
  15. both that copyright notice and this permission notice appear in 
  16. supporting documentation, and that the names of Digital or MIT not be
  17. used in advertising or publicity pertaining to distribution of the
  18. software without specific, written prior permission.  
  19.  
  20. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  21. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  22. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  23. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  24. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  25. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  26. SOFTWARE.
  27.  
  28. ******************************************************************/
  29.  
  30. #ifndef _Xt_fd_set
  31. #define _Xt_fd_set
  32.  
  33. #if defined(CRAY) && !defined(FD_SETSIZE)
  34. #include <sys/select.h>        /* defines FD stuff except howmany() */
  35. #endif
  36.  
  37. #ifndef NBBY
  38. #define    NBBY    8        /* number of bits in a byte */
  39. #endif
  40. /*
  41.  * Select uses bit masks of file descriptors in longs.
  42.  * These macros manipulate such bit fields (the filesystem macros use chars).
  43.  * FD_SETSIZE may be defined by the user, but the default here
  44.  * should be >= NOFILE (param.h).
  45.  */
  46. #ifndef    FD_SETSIZE
  47. #define    FD_SETSIZE    256
  48. #endif
  49.  
  50. typedef long Fd_mask;
  51. #ifndef NFDBITS
  52. #define NFDBITS    (sizeof(Fd_mask) * NBBY)    /* bits per mask */
  53. #endif
  54. #ifndef howmany
  55. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  56. #endif
  57.  
  58. typedef    struct Fd_set {
  59.     Fd_mask    fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  60. } Fd_set;
  61.  
  62. #ifndef FD_SET
  63. #define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  64. #endif
  65. #ifndef FD_CLR
  66. #define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  67. #endif
  68. #ifndef FD_ISSET
  69. #define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  70. #endif
  71. #ifndef FD_ZERO
  72. #define FD_ZERO(p)    bzero((char *)(p), sizeof(*(p)))
  73. #endif
  74.  
  75. #endif /*_Xt_fd_set*/
  76.