home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / py2s152.zip / Include / myselect.h < prev    next >
C/C++ Source or Header  |  1999-06-27  |  3KB  |  94 lines

  1. #ifndef Py_MYSELECT_H
  2. #define Py_MYSELECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /***********************************************************
  8. Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
  9. The Netherlands.
  10.  
  11.                         All Rights Reserved
  12.  
  13. Permission to use, copy, modify, and distribute this software and its
  14. documentation for any purpose and without fee is hereby granted,
  15. provided that the above copyright notice appear in all copies and that
  16. both that copyright notice and this permission notice appear in
  17. supporting documentation, and that the names of Stichting Mathematisch
  18. Centrum or CWI or Corporation for National Research Initiatives or
  19. CNRI not be used in advertising or publicity pertaining to
  20. distribution of the software without specific, written prior
  21. permission.
  22.  
  23. While CWI is the initial source for this software, a modified version
  24. is made available by the Corporation for National Research Initiatives
  25. (CNRI) at the Internet address ftp://ftp.python.org.
  26.  
  27. STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
  28. REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  29. MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
  30. CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  31. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  32. PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  33. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  34. PERFORMANCE OF THIS SOFTWARE.
  35.  
  36. ******************************************************************/
  37.  
  38. /* Include file for users of select() */
  39.  
  40. /* NB caller must include <sys/types.h> */
  41.  
  42. #ifdef HAVE_SYS_SELECT_H
  43.  
  44. #ifdef SYS_SELECT_WITH_SYS_TIME
  45. #include "mytime.h"
  46. #else /* !SYS_SELECT_WITH_SYS_TIME */
  47. #include <time.h>
  48. #endif /* !SYS_SELECT_WITH_SYS_TIME */
  49.  
  50. #include <sys/select.h>
  51.  
  52. #else /* !HAVE_SYS_SELECT_H */
  53.  
  54. #ifdef USE_GUSI
  55. /* If we don't have sys/select the definition may be in unistd.h */
  56. #include <GUSI.h>
  57. #endif
  58.  
  59. #include "mytime.h"
  60.  
  61. #endif /* !HAVE_SYS_SELECT_H */
  62.  
  63. /* If the fd manipulation macros aren't defined,
  64.    here is a set that should do the job */
  65.  
  66. #ifndef    FD_SETSIZE
  67. #define    FD_SETSIZE    256
  68. #endif
  69.  
  70. #ifndef FD_SET
  71.  
  72. typedef long fd_mask;
  73.  
  74. #define NFDBITS    (sizeof(fd_mask) * NBBY)    /* bits per mask */
  75. #ifndef howmany
  76. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  77. #endif /* howmany */
  78.  
  79. typedef    struct fd_set {
  80.     fd_mask    fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  81. } fd_set;
  82.  
  83. #define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  84. #define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  85. #define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  86. #define FD_ZERO(p)    memset((char *)(p), '\0', sizeof(*(p)))
  87.  
  88. #endif /* FD_SET */
  89.  
  90. #ifdef __cplusplus
  91. }
  92. #endif
  93. #endif /* !Py_MYSELECT_H */
  94.