home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !gcc / include / unixlib / sys / h / select < prev    next >
Encoding:
Text File  |  2006-09-17  |  3.0 KB  |  105 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/sys/select.h,v $
  4.  * $Date: 2005/04/13 19:20:06 $
  5.  * $Revision: 1.8 $
  6.  * $State: Exp $
  7.  * $Author: nick $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. /* POSIX 1003.1g: 6.2 Select from File Descriptor Sets */
  12.  
  13. #ifndef __SYS_SELECT_H
  14. #define __SYS_SELECT_H
  15.  
  16. #ifndef __UNIXLIB_FEATURES_H
  17. #include <features.h>
  18. #endif
  19.  
  20. #ifndef __UNIXLIB_TYPES_H
  21. #include <unixlib/types.h>
  22. #endif
  23.  
  24. #define __need_time_t
  25. #define __need_timespec
  26. #include <time.h>
  27.  
  28. #define __need_timeval
  29. #include <sys/time.h>
  30.  
  31. #ifndef __suseconds_t_defined
  32. typedef __suseconds_t suseconds_t;
  33. #define __suseconds_t_defined
  34. #endif
  35.  
  36. __BEGIN_DECLS
  37.  
  38. /* Number of descriptors that can fit in an `fd_set'.  */
  39. #define    FD_SETSIZE    256
  40.  
  41. typedef long int __fd_mask;
  42.  
  43. /* It's easier to assume 8-bit bytes than to get CHAR_BIT.  */
  44. #define    __NFDBITS    (sizeof (__fd_mask) * 8)
  45. #define    __FDELT(d)    ((d) / __NFDBITS)
  46. #define    __FDMASK(d)    (1 << ((d) % __NFDBITS))
  47.  
  48. typedef struct
  49.   {
  50.     /* Some braindead old software uses this member name.  */
  51.     __fd_mask fds_bits[(FD_SETSIZE + (__NFDBITS - 1)) / __NFDBITS];
  52.   } __fd_set;
  53.  
  54. #define    FD_ZERO(set) ((void) memset (set, 0, sizeof (*(set))))
  55. #define    FD_SET(d, set)    ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
  56. #define    FD_CLR(d, set)    ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
  57. #define    FD_ISSET(d, set)    ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))
  58.  
  59. #ifdef __USE_MISC
  60. /* Sometimes the fd_set member is assumed to have this type.  */
  61. typedef __fd_mask fd_mask;
  62.  
  63. /* Number of bits per word of `fd_set' (some code assumes this is 32).  */
  64. # define NFDBITS        __NFDBITS
  65. #endif
  66.  
  67. typedef __fd_set fd_set;
  68.  
  69. /* This contains the prototype for select */
  70. #define howmany(x, y) (((x)+((y)-1))/(y))
  71.  
  72. /* Check the first NFDS descriptors each in READFDS (if not NULL) for read
  73.    readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS
  74.    (if not NULL) for exceptional conditions.  If TIMEOUT is not NULL, time out
  75.    after waiting the interval specified therein.  Returns the number of ready
  76.    descriptors, or -1 for errors.
  77.  
  78.    This function is a cancellation point.  */
  79. extern int select (int __nfds, __fd_set *__restrict __readfds,
  80.            fd_set *__restrict __writefds,
  81.            fd_set *__restrict __exceptfds,
  82.            struct timeval *__restrict __timeout);
  83.  
  84. /* Same as pselect but with higher resolution for the timeout.
  85.    This function is a cancellation point.  */
  86. extern int pselect (int __nfds,
  87.             fd_set *__restrict __readfds,
  88.             fd_set *__restrict __writefds,
  89.             fd_set *__restrict __exceptfds,
  90.             const struct timespec *__restrict __timeout,
  91.             const __sigset_t *__restrict __sigmask);
  92.  
  93. #ifdef __UNIXLIB_INTERNALS
  94. /* SWI veneer. Do not use directly.  */
  95. extern int _select (int __nfds,
  96.             fd_set *__restrict __readfds,
  97.             fd_set *__restrict __writefds,
  98.             fd_set *__restrict __exceptfds,
  99.             const struct timeval *__restrict __timeout);
  100. #endif  /* __UNIXLIB_INTERNALS */
  101.  
  102. __END_DECLS
  103.  
  104. #endif
  105.