xref: /freebsd/contrib/ntp/include/ntp_select.h (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 /*
2  * Not all machines define FD_SET in sys/types.h
3  */
4 #ifndef NTP_SELECT_H
5 #define NTP_SELECT_H	/* note: tested by include/l_stdlib.h */
6 
7 /* Was: (defined(RS6000)||defined(SYS_PTX))&&!defined(_BSD) */
8 /* Could say: !defined(FD_SET) && defined(HAVE_SYS_SELECT_H) */
9 /* except FD_SET can legitimately be a typedef... */
10 #if defined(HAVE_SYS_SELECT_H) && !defined(_BSD)
11 # ifndef SYS_VXWORKS
12 #  include <sys/select.h>
13 # else
14 #  include <sockLib.h>
15 extern	int	select(int width, fd_set *pReadFds, fd_set *pWriteFds,
16 		       fd_set *pExceptFds, struct timeval *pTimeOut);
17 # endif
18 #endif
19 
20 #if !defined(FD_SET)
21 # define NFDBITS	32
22 # define FD_SETSIZE	32
23 # define FD_SET(n, p)	((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
24 # define FD_CLR(n, p)	((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
25 # define FD_ISSET(n, p)	((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
26 # define FD_ZERO(p)	memset((p), 0, sizeof(*(p)))
27 #endif
28 
29 #if defined(VMS)
30 typedef struct {
31 	unsigned int fds_bits[1];
32 } fd_set;
33 #endif
34 
35 #endif	/* NTP_SELECT_H */
36