]> Zhao Yanbai Git Server - minix.git/commitdiff
Use size-dependant no. of words, with OPEN_MAX as default for fd_set size.
authorBen Gras <ben@minix3.org>
Fri, 6 Oct 2006 15:45:13 +0000 (15:45 +0000)
committerBen Gras <ben@minix3.org>
Fri, 6 Oct 2006 15:45:13 +0000 (15:45 +0000)
include/sys/select.h

index b06fcbbe947efe1baef5877b3a3daacb0edd25bb..f93d39dd084aa94394bb0346433da8ca7565209b 100755 (executable)
@@ -26,15 +26,15 @@ typedef u32_t fd_mask;
 #endif
 
 /* We want to store FD_SETSIZE bits. */
-#define _FDSETWORDS    ((FD_SETSIZE+_FDSETBITSPERWORD-1)/_FDSETBITSPERWORD)
+#define _FDSETWORDS(b) (((b)+_FDSETBITSPERWORD-1)/_FDSETBITSPERWORD)
 
 typedef struct {
-       fd_mask fds_bits[_FDSETWORDS];
+       fd_mask fds_bits[_FDSETWORDS(FD_SETSIZE)];
 } fd_set;
 
 _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_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))