Use size-dependant no. of words, with OPEN_MAX as default for fd_set size.
This commit is contained in:
parent
1f3560229d
commit
140afcfb7d
1 changed files with 3 additions and 3 deletions
|
@ -26,15 +26,15 @@ typedef u32_t fd_mask;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* We want to store FD_SETSIZE bits. */
|
/* We want to store FD_SETSIZE bits. */
|
||||||
#define _FDSETWORDS ((FD_SETSIZE+_FDSETBITSPERWORD-1)/_FDSETBITSPERWORD)
|
#define _FDSETWORDS(b) (((b)+_FDSETBITSPERWORD-1)/_FDSETBITSPERWORD)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
fd_mask fds_bits[_FDSETWORDS];
|
fd_mask fds_bits[_FDSETWORDS(FD_SETSIZE)];
|
||||||
} fd_set;
|
} fd_set;
|
||||||
|
|
||||||
_PROTOTYPE( int select, (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout) );
|
_PROTOTYPE( int select, (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout) );
|
||||||
|
|
||||||
#define FD_ZERO(s) do { int _i; for(_i = 0; _i < _FDSETWORDS; _i++) { (s)->fds_bits[_i] = 0; } } while(0)
|
#define FD_ZERO(s) do { int _i; for(_i = 0; _i < _FDSETWORDS(FD_SETSIZE); _i++) { (s)->fds_bits[_i] = 0; } } while(0)
|
||||||
#define FD_SET(f, s) do { (s)->fds_bits[_FD_BITWORD(f)] |= _FD_BITMASK(f); } while(0)
|
#define FD_SET(f, s) do { (s)->fds_bits[_FD_BITWORD(f)] |= _FD_BITMASK(f); } while(0)
|
||||||
#define FD_CLR(f, s) do { (s)->fds_bits[_FD_BITWORD(f)] &= ~(_FD_BITMASK(f)); } while(0)
|
#define FD_CLR(f, s) do { (s)->fds_bits[_FD_BITWORD(f)] &= ~(_FD_BITMASK(f)); } while(0)
|
||||||
#define FD_ISSET(f, s) ((s)->fds_bits[_FD_BITWORD(f)] & _FD_BITMASK(f))
|
#define FD_ISSET(f, s) ((s)->fds_bits[_FD_BITWORD(f)] & _FD_BITMASK(f))
|
||||||
|
|
Loading…
Reference in a new issue