fix broken FD_* macros on 64-bit targets
authorRich Felker <dalias@aerifal.cx>
Sat, 27 Aug 2011 23:42:13 +0000 (19:42 -0400)
committerRich Felker <dalias@aerifal.cx>
Sat, 27 Aug 2011 23:42:13 +0000 (19:42 -0400)
1 is too small if int is 32-bit but unsigned long is 64-bit. be
explicit and use 1UL.

include/sys/select.h

index 7cb0af43de44a036d1b6e057a4e0827a37ecc18c..cbe35a4f96603d20e9dd607c24bd7f5a316aca59 100644 (file)
@@ -23,9 +23,9 @@ typedef struct
 } fd_set;
 
 #define FD_ZERO(s) do { int __i; unsigned long *__b=(s)->fds_bits; for(__i=sizeof (fd_set)/sizeof (long); __i; __i--) *__b++=0; } while(0)
-#define FD_SET(d, s)   ((s)->fds_bits[(d)/(8*sizeof(long))] |= (1<<((d)%(8*sizeof(long)))))
-#define FD_CLR(d, s)   ((s)->fds_bits[(d)/(8*sizeof(long))] &= ~(1<<((d)%(8*sizeof(long)))))
-#define FD_ISSET(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] & (1<<((d)%(8*sizeof(long)))))
+#define FD_SET(d, s)   ((s)->fds_bits[(d)/(8*sizeof(long))] |= (1UL<<((d)%(8*sizeof(long)))))
+#define FD_CLR(d, s)   ((s)->fds_bits[(d)/(8*sizeof(long))] &= ~(1UL<<((d)%(8*sizeof(long)))))
+#define FD_ISSET(d, s) ((s)->fds_bits[(d)/(8*sizeof(long))] & (1UL<<((d)%(8*sizeof(long)))))
 
 int select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
 int pselect (int, fd_set *, fd_set *, fd_set *, const struct timespec *, const sigset_t *);