more stack for boot
[minix.git] / include / sys / select.h
blob3132d718f3a2356dcd2026180505b36193f65e76
1 #ifndef _SYS_SELECT_H
2 #define _SYS_SELECT_H 1
4 #ifndef _POSIX_SOURCE
5 #define _POSIX_SOURCE 1
6 #endif
8 #include <sys/time.h>
9 #include <minix/types.h>
10 #include <limits.h>
11 #include <string.h>
13 /* Use this datatype as basic storage unit in fd_set */
14 typedef u32_t fd_mask;
16 /* This many bits fit in an fd_set word. */
17 #define _FDSETBITSPERWORD (sizeof(fd_mask)*8)
19 /* Bit manipulation macros */
20 #define _FD_BITMASK(b) (1L << ((b) % _FDSETBITSPERWORD))
21 #define _FD_BITWORD(b) ((b)/_FDSETBITSPERWORD)
23 /* Default FD_SETSIZE is OPEN_MAX. */
24 #ifndef FD_SETSIZE
25 #define FD_SETSIZE OPEN_MAX
26 #endif
28 /* We want to store FD_SETSIZE bits. */
29 #define _FDSETWORDS(b) (((b)+_FDSETBITSPERWORD-1)/_FDSETBITSPERWORD)
31 typedef struct {
32 fd_mask fds_bits[_FDSETWORDS(FD_SETSIZE)];
33 } fd_set;
35 _PROTOTYPE( int select, (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout) );
37 #define FD_ZERO(s) do { int _i; for(_i = 0; _i < _FDSETWORDS(FD_SETSIZE); _i++) { (s)->fds_bits[_i] = 0; } } while(0)
38 #define FD_SET(f, s) do { (s)->fds_bits[_FD_BITWORD(f)] |= _FD_BITMASK(f); } while(0)
39 #define FD_CLR(f, s) do { (s)->fds_bits[_FD_BITWORD(f)] &= ~(_FD_BITMASK(f)); } while(0)
40 #define FD_ISSET(f, s) ((s)->fds_bits[_FD_BITWORD(f)] & _FD_BITMASK(f))
42 /* possible select() operation types; read, write, errors */
43 /* (FS/driver internal use only) */
44 #define SEL_RD (1 << 0)
45 #define SEL_WR (1 << 1)
46 #define SEL_ERR (1 << 2)
47 #define SEL_NOTIFY (1 << 3) /* not a real select operation */
49 #endif /* _SYS_SELECT_H */