4 /* We don't define fd_set and friends if we are compiling POSIX
5 source, or if we have included (or may include as indicated
6 by __USE_W32_SOCKETS) the W32api winsock[2].h header which
7 defines Windows versions of them. Note that a program which
8 includes the W32api winsock[2].h header must know what it is doing;
9 it must not call the Cygwin select function.
11 # if !(defined (_WINSOCK_H) || defined (_WINSOCKAPI_) || defined (__USE_W32_SOCKETS))
13 #include <sys/cdefs.h>
14 #include <sys/_sigset.h>
15 #include <sys/_timeval.h>
16 #include <sys/timespec.h>
18 #if !defined(_SIGSET_T_DECLARED)
19 #define _SIGSET_T_DECLARED
20 typedef __sigset_t sigset_t
;
23 # define _SYS_TYPES_FD_SET
25 * Select uses bit masks of file descriptors in longs.
26 * These macros manipulate such bit fields (the filesystem macros use chars).
27 * FD_SETSIZE may be defined by the user, but the default here
28 * should be enough for most uses.
32 # define FD_SETSIZE 1024
33 # elif defined(__rtems__)
34 # define FD_SETSIZE 256
36 # define FD_SETSIZE 64
40 typedef unsigned long __fd_mask
;
42 typedef __fd_mask fd_mask
;
45 #define _NFDBITS ((int)sizeof(__fd_mask) * 8) /* bits per mask */
47 #define NFDBITS _NFDBITS
51 #define _howmany(x,y) (((x) + ((y) - 1)) / (y))
54 typedef struct fd_set
{
55 __fd_mask __fds_bits
[_howmany(FD_SETSIZE
, _NFDBITS
)];
58 #define fds_bits __fds_bits
61 #define __fdset_mask(n) ((__fd_mask)1 << ((n) % _NFDBITS))
62 #define FD_CLR(n, p) ((p)->__fds_bits[(n)/_NFDBITS] &= ~__fdset_mask(n))
64 #define FD_COPY(f, t) (void)(*(t) = *(f))
66 #define FD_ISSET(n, p) (((p)->__fds_bits[(n)/_NFDBITS] & __fdset_mask(n)) != 0)
67 #define FD_SET(n, p) ((p)->__fds_bits[(n)/_NFDBITS] |= __fdset_mask(n))
68 #define FD_ZERO(p) do { \
73 _n = _howmany(FD_SETSIZE, _NFDBITS); \
75 _p->__fds_bits[--_n] = 0; \
78 #if !defined (__INSIDE_CYGWIN_NET__)
82 int select
__P ((int __n
, fd_set
*__readfds
, fd_set
*__writefds
,
83 fd_set
*__exceptfds
, struct timeval
*__timeout
));
84 #if __POSIX_VISIBLE >= 200112
85 int pselect
__P ((int __n
, fd_set
*__readfds
, fd_set
*__writefds
,
86 fd_set
*__exceptfds
, const struct timespec
*__timeout
,
87 const sigset_t
*__set
));
92 #endif /* !__INSIDE_CYGWIN_NET__ */
94 #endif /* !(_WINSOCK_H || _WINSOCKAPI_ || __USE_W32_SOCKETS) */
96 #endif /* sys/select.h */