summaryrefslogtreecommitdiff
path: root/tools/include/nolibc
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2022-02-13 11:53:01 +0300
committerPaul E. McKenney <paulmck@kernel.org>2022-04-21 03:05:43 +0300
commit306c9fd4c686eebf4e0487bc4ad5dca8e68c19be (patch)
treef3df8c393368e53bd6a4a9b6929818702beb6c56 /tools/include/nolibc
parent8cb98b3fce152e8ba46d1e25515deab08d7ec271 (diff)
downloadlinux-306c9fd4c686eebf4e0487bc4ad5dca8e68c19be.tar.xz
tools/nolibc/types: make FD_SETSIZE configurable
The macro was hard-coded to 256 but it's common to see it redefined. Let's support this and make sure we always allocate enough entries for the cases where it wouldn't be multiple of 32. Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'tools/include/nolibc')
-rw-r--r--tools/include/nolibc/types.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h
index a4dda0a22fc2..563dbbad0496 100644
--- a/tools/include/nolibc/types.h
+++ b/tools/include/nolibc/types.h
@@ -45,7 +45,9 @@
#define DT_SOCK 0xc
/* commonly an fd_set represents 256 FDs */
+#ifndef FD_SETSIZE
#define FD_SETSIZE 256
+#endif
/* Special FD used by all the *at functions */
#ifndef AT_FDCWD
@@ -72,7 +74,7 @@
/* for select() */
typedef struct {
- uint32_t fd32[FD_SETSIZE / 32];
+ uint32_t fd32[(FD_SETSIZE + 31) / 32];
} fd_set;
#define FD_CLR(fd, set) do { \
@@ -101,7 +103,7 @@ typedef struct {
#define FD_ZERO(set) do { \
fd_set *__set = (set); \
int __idx; \
- for (__idx = 0; __idx < FD_SETSIZE / 32; __idx ++) \
+ for (__idx = 0; __idx < (FD_SETSIZE+31) / 32; __idx ++) \
__set->fd32[__idx] = 0; \
} while (0)