aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/0005-add-NFDBITS-in-sys-select.h-with-appropriate-feature.patch
blob: caf5ea390ca7380df5455c91d2e7a6e3b82bd2c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
From 9b9dc74b67b9ecd30db9f3266a5ce309b0ffbfef Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Sat, 6 Jul 2013 01:12:28 -0400
Subject: [PATCH 05/10] add NFDBITS in sys/select.h with appropriate feature
 tests

the main use for this macro seems to be knowing the correct allocation
granularity for dynamic-sized fd_set objects. such usage is
non-conforming and results in undefined behavior, but it is widespread
in applications.
---
 include/sys/select.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/sys/select.h b/include/sys/select.h
index c5a2877..e25257d 100644
--- a/include/sys/select.h
+++ b/include/sys/select.h
@@ -32,6 +32,9 @@ typedef struct
 int select (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, struct timeval *__restrict);
 int pselect (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict);
 
+#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#define NFDBITS (8*(int)sizeof(long))
+#endif
 
 #ifdef __cplusplus
 }
-- 
1.8.3.2