public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/zack/no-nested-includes] Don’t include sys/select.h from sys/types.h.
@ 2019-05-26 16:36 Zack Weinberg
0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2019-05-26 16:36 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 6337 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4bfa3065977721c2b6a4bbef569618e481750286
commit 4bfa3065977721c2b6a4bbef569618e481750286
Author: Zack Weinberg <zackw@panix.com>
Date: Sat Mar 16 12:35:25 2019 -0400
Donât include sys/select.h from sys/types.h.
This is supposedly present for BSD compatibility, but the current
generation of BSDs is not consistent about it: FreeBSD does, OpenBSD
doesnât, NetBSD exposes only fd_set and the FD_* macros. Programs
that need to wait for any of multiple I/O events have several
alternatives to select nowadays, so I think it makes sense to expose
select only to programs that specifically want it.
Only a few places within our own code are affected. A few test
programs need to include sys/select.h explicitly, as does rpc/svc.h.
sysdeps/nptl/thread_db.h needs to declare sigset_t, and
sysdeps/unix/sysv/linux/pselect.c was including sys/poll.h instead of
sys/select.h, which is probably a copy-and-paste error. sys/socket.h
needs to forward-declare struct timespec under __USE_GNU, because
recvmmsg has a struct timespec * argument; Iâm open to the possibility
of having it fully declare struct timespec.
I considered taking sys/select.h out of sys/time.h as well, but POSIX
not only explicitly allows this inclusion, it requires sys/time.h to
declare almost everything that sys/select.h declares. It doesnât seem
worth creating another bits header just to prevent sys/time.h from
declaring pselect, sigset_t, and struct timespec.
* posix/sys/types.h: Donât include sys/select.h.
* scripts/check-obsolete-constructs.py: Remove whitelist entry
for sys/types.h -> sys/select.h. Adjust commentary re
sys/time.h -> sys/select.h.
* socket/sys/socket.h: When __USE_GNU, forward-declare struct timespec.
* misc/tst-fdset.c, nptl/tst-cancel4.c, scripts/check-c++-types.sh
* sunrpc/rpc/svc.h: Include sys/select.h.
* sysdeps/nptl/thread_db.h: Include bits/types/sigset_t.h.
* sysdeps/unix/sysv/linux/pselect.c: Include sys/select.h,
not sys/poll.h.
Diff:
---
misc/tst-fdset.c | 2 +-
nptl/tst-cancel4.c | 1 +
posix/sys/types.h | 3 ---
scripts/check-c++-types.sh | 1 +
scripts/check-obsolete-constructs.py | 6 +++---
socket/sys/socket.h | 4 ++++
sunrpc/rpc/svc.h | 1 +
sysdeps/nptl/thread_db.h | 2 +-
sysdeps/unix/sysv/linux/pselect.c | 2 +-
9 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/misc/tst-fdset.c b/misc/tst-fdset.c
index 70b7028..956e371 100644
--- a/misc/tst-fdset.c
+++ b/misc/tst-fdset.c
@@ -18,7 +18,7 @@
<http://www.gnu.org/licenses/>. */
#include <stdio.h>
-#include <sys/types.h>
+#include <sys/select.h>
static int
do_test (void)
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index 60a965d..dce93dc 100644
--- a/nptl/tst-cancel4.c
+++ b/nptl/tst-cancel4.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/select.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/ipc.h>
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 8f6d328..3f29307 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -95,9 +95,6 @@ __BEGIN_DECLS
/* In BSD <sys/types.h> is expected to define BYTE_ORDER. */
# include <endian.h>
-
-/* It also defines `fd_set' and the FD_* macros for `select'. */
-# include <sys/select.h>
#endif /* Use misc. */
__END_DECLS
diff --git a/scripts/check-c++-types.sh b/scripts/check-c++-types.sh
index a8f3cff..141ddf7 100755
--- a/scripts/check-c++-types.sh
+++ b/scripts/check-c++-types.sh
@@ -46,6 +46,7 @@ while read t; do
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/resource.h>
+#include <sys/select.h>
#include <unistd.h>
void foo ($t) { }
EOF
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index fb63fe5..36d8746 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -538,13 +538,13 @@ HEADER_ALLOWED_INCLUDES = {
# mandated: sys/msg.h -> sys/ipc.h
# sys/sem.h -> sys/ipc.h
# sys/shm.h -> sys/ipc.h
- # allowed: sys/time.h -> sys/select.h
- # sys/wait.h -> signal.h
+ # sys/time.h -> sys/select.h (effectively)
+ # allowed: sys/wait.h -> signal.h
"sys/msg.h": [ "sys/ipc.h" ],
"sys/sem.h": [ "sys/ipc.h" ],
"sys/shm.h": [ "sys/ipc.h" ],
"sys/time.h": [ "sys/select.h" ],
- "sys/types.h": [ "endian.h", "sys/select.h" ],
+ "sys/types.h": [ "endian.h" ],
"sys/uio.h": [ "sys/types.h" ],
"sys/un.h": [ "string.h" ],
"sys/wait.h": [ "signal.h" ],
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index 6f242d0..eebc9b5 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -36,6 +36,10 @@ __BEGIN_DECLS
# include <bits/types/struct_osockaddr.h>
#endif
+#ifdef __USE_GNU
+struct timespec;
+#endif
+
/* The following constants should be used for the second parameter of
`shutdown'. */
enum
diff --git a/sunrpc/rpc/svc.h b/sunrpc/rpc/svc.h
index 85d0183..c77dcf0 100644
--- a/sunrpc/rpc/svc.h
+++ b/sunrpc/rpc/svc.h
@@ -53,6 +53,7 @@
#include <features.h>
#include <rpc/rpc_msg.h>
+#include <sys/select.h>
__BEGIN_DECLS
diff --git a/sysdeps/nptl/thread_db.h b/sysdeps/nptl/thread_db.h
index d134aca..4d949b0 100644
--- a/sysdeps/nptl/thread_db.h
+++ b/sysdeps/nptl/thread_db.h
@@ -26,7 +26,7 @@
#include <stdint.h>
#include <sys/types.h>
#include <sys/procfs.h>
-
+#include <bits/types/sigset_t.h>
/* Error codes of the library. */
typedef enum
diff --git a/sysdeps/unix/sysv/linux/pselect.c b/sysdeps/unix/sysv/linux/pselect.c
index c9406ca..d1106e9 100644
--- a/sysdeps/unix/sysv/linux/pselect.c
+++ b/sysdeps/unix/sysv/linux/pselect.c
@@ -19,7 +19,7 @@
#include <errno.h>
#include <signal.h>
#include <time.h>
-#include <sys/poll.h>
+#include <sys/select.h>
#include <kernel-features.h>
#include <sysdep-cancel.h>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [glibc/zack/no-nested-includes] Don’t include sys/select.h from sys/types.h.
@ 2020-01-08 19:20 Zack Weinberg
0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2020-01-08 19:20 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 6659 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ff9bae2f92e83e9655abd8b32021b0d6407ef560
commit ff9bae2f92e83e9655abd8b32021b0d6407ef560
Author: Zack Weinberg <zackw@panix.com>
Date: Sat Mar 16 12:35:25 2019 -0400
Donât include sys/select.h from sys/types.h.
This is supposedly present for BSD compatibility, but the current
generation of BSDs is not consistent about it: FreeBSD does, OpenBSD
doesnât, NetBSD exposes only fd_set and the FD_* macros. Programs
that need to wait for any of multiple I/O events have several
alternatives to select nowadays, so I think it makes sense to expose
select only to programs that specifically want it.
Only a few places within our own code are affected. A few test
programs need to include sys/select.h explicitly, as does rpc/svc.h.
sysdeps/nptl/thread_db.h needs to declare sigset_t, and
sysdeps/unix/sysv/linux/pselect.c was including sys/poll.h instead of
sys/select.h, which is probably a copy-and-paste error. sys/socket.h
needs to forward-declare struct timespec under __USE_GNU, because
recvmmsg has a struct timespec * argument; Iâm open to the possibility
of having it fully declare struct timespec.
I considered taking sys/select.h out of sys/time.h as well, but POSIX
not only explicitly allows this inclusion, it requires sys/time.h to
declare almost everything that sys/select.h declares. It doesnât seem
worth creating another bits header just to prevent sys/time.h from
declaring pselect, sigset_t, and struct timespec.
Not including sys/select.h from sys/types.h means that sys/types.h
also no longer defines anything from sys/time.h, and a couple of files
were relying on that. (pthread_join_common.c should be using
clock_gettime instead of gettimeofday, but that's out of scope for
this patch series.)
* posix/sys/types.h: Donât include sys/select.h.
* scripts/check-obsolete-constructs.py: Remove whitelist entry
for sys/types.h -> sys/select.h. Adjust commentary re
sys/time.h -> sys/select.h.
* socket/sys/socket.h: When __USE_GNU, forward-declare struct timespec.
* misc/tst-fdset.c, nptl/tst-cancel4.c, scripts/check-c++-types.sh
* sunrpc/rpc/svc.h: Include sys/select.h.
* sysdeps/nptl/thread_db.h: Include bits/types/sigset_t.h.
* sysdeps/unix/sysv/linux/pselect.c: Include sys/select.h,
not sys/poll.h.
* nptl/pthread_join_common.c, sysdeps/unix/sysv/linux/dl-vdso.h:
Include sys/time.h.
Diff:
---
misc/tst-fdset.c | 2 +-
nptl/pthread_join_common.c | 2 ++
nptl/tst-cancel4.c | 1 +
posix/sys/types.h | 3 ---
scripts/check-c++-types.sh | 1 +
scripts/check-obsolete-constructs.py | 6 +++---
socket/sys/socket.h | 4 ++++
sunrpc/rpc/svc.h | 1 +
sysdeps/nptl/thread_db.h | 2 +-
9 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/misc/tst-fdset.c b/misc/tst-fdset.c
index eace688..62ac4c2 100644
--- a/misc/tst-fdset.c
+++ b/misc/tst-fdset.c
@@ -18,7 +18,7 @@
<https://www.gnu.org/licenses/>. */
#include <stdio.h>
-#include <sys/types.h>
+#include <sys/select.h>
static int
do_test (void)
diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c
index a96ceaf..29af4d2 100644
--- a/nptl/pthread_join_common.c
+++ b/nptl/pthread_join_common.c
@@ -21,6 +21,8 @@
#include <stap-probe.h>
#include <time.h>
+#include <sys/time.h>
+
static void
cleanup (void *arg)
{
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index 6526685..5ede8a0 100644
--- a/nptl/tst-cancel4.c
+++ b/nptl/tst-cancel4.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/select.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/ipc.h>
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 64fa010..f7ce0c6 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -93,9 +93,6 @@ __BEGIN_DECLS
/* In BSD <sys/types.h> is expected to define BYTE_ORDER. */
# include <endian.h>
-
-/* It also defines `fd_set' and the FD_* macros for `select'. */
-# include <sys/select.h>
#endif /* Use misc. */
__END_DECLS
diff --git a/scripts/check-c++-types.sh b/scripts/check-c++-types.sh
index d868204..ebf4fd1 100755
--- a/scripts/check-c++-types.sh
+++ b/scripts/check-c++-types.sh
@@ -46,6 +46,7 @@ while read t; do
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/resource.h>
+#include <sys/select.h>
#include <unistd.h>
void foo ($t) { }
EOF
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index dfe0d0f..77999d8 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -530,13 +530,13 @@ HEADER_ALLOWED_INCLUDES = {
# mandated: sys/msg.h -> sys/ipc.h
# sys/sem.h -> sys/ipc.h
# sys/shm.h -> sys/ipc.h
- # allowed: sys/time.h -> sys/select.h
- # sys/wait.h -> signal.h
+ # sys/time.h -> sys/select.h (effectively)
+ # allowed: sys/wait.h -> signal.h
"sys/msg.h": [ "sys/ipc.h" ],
"sys/sem.h": [ "sys/ipc.h" ],
"sys/shm.h": [ "sys/ipc.h" ],
"sys/time.h": [ "sys/select.h" ],
- "sys/types.h": [ "endian.h", "sys/select.h" ],
+ "sys/types.h": [ "endian.h" ],
"sys/uio.h": [ "sys/types.h" ],
"sys/un.h": [ "string.h" ],
"sys/wait.h": [ "signal.h" ],
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index 0c158d1..305e620 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -35,6 +35,10 @@ __BEGIN_DECLS
# include <bits/types/struct_osockaddr.h>
#endif
+#ifdef __USE_GNU
+struct timespec;
+#endif
+
/* The following constants should be used for the second parameter of
`shutdown'. */
enum
diff --git a/sunrpc/rpc/svc.h b/sunrpc/rpc/svc.h
index ea2ba71..2dd9d87 100644
--- a/sunrpc/rpc/svc.h
+++ b/sunrpc/rpc/svc.h
@@ -53,6 +53,7 @@
#include <features.h>
#include <rpc/rpc_msg.h>
+#include <sys/select.h>
__BEGIN_DECLS
diff --git a/sysdeps/nptl/thread_db.h b/sysdeps/nptl/thread_db.h
index 7418344..bf073b7 100644
--- a/sysdeps/nptl/thread_db.h
+++ b/sysdeps/nptl/thread_db.h
@@ -26,7 +26,7 @@
#include <stdint.h>
#include <sys/types.h>
#include <sys/procfs.h>
-
+#include <bits/types/sigset_t.h>
/* Error codes of the library. */
typedef enum
^ permalink raw reply [flat|nested] 7+ messages in thread
* [glibc/zack/no-nested-includes] Don’t include sys/select.h from sys/types.h.
@ 2019-06-26 15:50 Zack Weinberg
0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2019-06-26 15:50 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 7790 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7dab6ebb6ce7d8841a3213da56177b112e1d7548
commit 7dab6ebb6ce7d8841a3213da56177b112e1d7548
Author: Zack Weinberg <zackw@panix.com>
Date: Sat Mar 16 12:35:25 2019 -0400
Donât include sys/select.h from sys/types.h.
This is supposedly present for BSD compatibility, but the current
generation of BSDs is not consistent about it: FreeBSD does, OpenBSD
doesnât, NetBSD exposes only fd_set and the FD_* macros. Programs
that need to wait for any of multiple I/O events have several
alternatives to select nowadays, so I think it makes sense to expose
select only to programs that specifically want it.
Only a few places within our own code are affected. A few test
programs need to include sys/select.h explicitly, as does rpc/svc.h.
sysdeps/nptl/thread_db.h needs to declare sigset_t, and
sysdeps/unix/sysv/linux/pselect.c was including sys/poll.h instead of
sys/select.h, which is probably a copy-and-paste error. sys/socket.h
needs to forward-declare struct timespec under __USE_GNU, because
recvmmsg has a struct timespec * argument; Iâm open to the possibility
of having it fully declare struct timespec.
I considered taking sys/select.h out of sys/time.h as well, but POSIX
not only explicitly allows this inclusion, it requires sys/time.h to
declare almost everything that sys/select.h declares. It doesnât seem
worth creating another bits header just to prevent sys/time.h from
declaring pselect, sigset_t, and struct timespec.
Not including sys/select.h from sys/types.h means that sys/types.h
also no longer defines anything from sys/time.h, and a couple of files
were relying on that. (pthread_join_common.c should be using
clock_gettime instead of gettimeofday, but that's out of scope for
this patch series.)
* posix/sys/types.h: Donât include sys/select.h.
* scripts/check-obsolete-constructs.py: Remove whitelist entry
for sys/types.h -> sys/select.h. Adjust commentary re
sys/time.h -> sys/select.h.
* socket/sys/socket.h: When __USE_GNU, forward-declare struct timespec.
* misc/tst-fdset.c, nptl/tst-cancel4.c, scripts/check-c++-types.sh
* sunrpc/rpc/svc.h: Include sys/select.h.
* sysdeps/nptl/thread_db.h: Include bits/types/sigset_t.h.
* sysdeps/unix/sysv/linux/pselect.c: Include sys/select.h,
not sys/poll.h.
* nptl/pthread_join_common.c, sysdeps/unix/sysv/linux/dl-vdso.h:
Include sys/time.h.
Diff:
---
misc/tst-fdset.c | 2 +-
nptl/pthread_join_common.c | 2 ++
nptl/tst-cancel4.c | 1 +
posix/sys/types.h | 3 ---
scripts/check-c++-types.sh | 1 +
scripts/check-obsolete-constructs.py | 6 +++---
socket/sys/socket.h | 4 ++++
sunrpc/rpc/svc.h | 1 +
sysdeps/nptl/thread_db.h | 2 +-
sysdeps/unix/sysv/linux/dl-vdso.h | 6 ++++++
sysdeps/unix/sysv/linux/pselect.c | 2 +-
11 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/misc/tst-fdset.c b/misc/tst-fdset.c
index 70b7028..956e371 100644
--- a/misc/tst-fdset.c
+++ b/misc/tst-fdset.c
@@ -18,7 +18,7 @@
<http://www.gnu.org/licenses/>. */
#include <stdio.h>
-#include <sys/types.h>
+#include <sys/select.h>
static int
do_test (void)
diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c
index 5224ee2..b8b016c 100644
--- a/nptl/pthread_join_common.c
+++ b/nptl/pthread_join_common.c
@@ -20,6 +20,8 @@
#include <atomic.h>
#include <stap-probe.h>
+#include <sys/time.h>
+
static void
cleanup (void *arg)
{
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index 60a965d..dce93dc 100644
--- a/nptl/tst-cancel4.c
+++ b/nptl/tst-cancel4.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/select.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/ipc.h>
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 08305cf..9381695 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -93,9 +93,6 @@ __BEGIN_DECLS
/* In BSD <sys/types.h> is expected to define BYTE_ORDER. */
# include <endian.h>
-
-/* It also defines `fd_set' and the FD_* macros for `select'. */
-# include <sys/select.h>
#endif /* Use misc. */
__END_DECLS
diff --git a/scripts/check-c++-types.sh b/scripts/check-c++-types.sh
index a8f3cff..141ddf7 100755
--- a/scripts/check-c++-types.sh
+++ b/scripts/check-c++-types.sh
@@ -46,6 +46,7 @@ while read t; do
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/resource.h>
+#include <sys/select.h>
#include <unistd.h>
void foo ($t) { }
EOF
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index bd5a97f..a051d4e 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -530,13 +530,13 @@ HEADER_ALLOWED_INCLUDES = {
# mandated: sys/msg.h -> sys/ipc.h
# sys/sem.h -> sys/ipc.h
# sys/shm.h -> sys/ipc.h
- # allowed: sys/time.h -> sys/select.h
- # sys/wait.h -> signal.h
+ # sys/time.h -> sys/select.h (effectively)
+ # allowed: sys/wait.h -> signal.h
"sys/msg.h": [ "sys/ipc.h" ],
"sys/sem.h": [ "sys/ipc.h" ],
"sys/shm.h": [ "sys/ipc.h" ],
"sys/time.h": [ "sys/select.h" ],
- "sys/types.h": [ "endian.h", "sys/select.h" ],
+ "sys/types.h": [ "endian.h" ],
"sys/uio.h": [ "sys/types.h" ],
"sys/un.h": [ "string.h" ],
"sys/wait.h": [ "signal.h" ],
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index 1bb90ed..ce793dc 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -35,6 +35,10 @@ __BEGIN_DECLS
# include <bits/types/struct_osockaddr.h>
#endif
+#ifdef __USE_GNU
+struct timespec;
+#endif
+
/* The following constants should be used for the second parameter of
`shutdown'. */
enum
diff --git a/sunrpc/rpc/svc.h b/sunrpc/rpc/svc.h
index 85d0183..c77dcf0 100644
--- a/sunrpc/rpc/svc.h
+++ b/sunrpc/rpc/svc.h
@@ -53,6 +53,7 @@
#include <features.h>
#include <rpc/rpc_msg.h>
+#include <sys/select.h>
__BEGIN_DECLS
diff --git a/sysdeps/nptl/thread_db.h b/sysdeps/nptl/thread_db.h
index d134aca..4d949b0 100644
--- a/sysdeps/nptl/thread_db.h
+++ b/sysdeps/nptl/thread_db.h
@@ -26,7 +26,7 @@
#include <stdint.h>
#include <sys/types.h>
#include <sys/procfs.h>
-
+#include <bits/types/sigset_t.h>
/* Error codes of the library. */
typedef enum
diff --git a/sysdeps/unix/sysv/linux/dl-vdso.h b/sysdeps/unix/sysv/linux/dl-vdso.h
index 9e61ca7..edecf5f 100644
--- a/sysdeps/unix/sysv/linux/dl-vdso.h
+++ b/sysdeps/unix/sysv/linux/dl-vdso.h
@@ -23,6 +23,12 @@
#include <ldsodefs.h>
#include <dl-hash.h>
+/* This header must declare all functions that might be looked up
+ in the vDSO by code fragments generated by make-syscalls.sh.
+ At present the only such function that isn't covered by the above
+ headers is gettimeofday. */
+#include <sys/time.h>
+
/* Create version number record for lookup. */
#define PREPARE_VERSION(var, vname, vhash) \
struct r_found_version var; \
diff --git a/sysdeps/unix/sysv/linux/pselect.c b/sysdeps/unix/sysv/linux/pselect.c
index c9406ca..d1106e9 100644
--- a/sysdeps/unix/sysv/linux/pselect.c
+++ b/sysdeps/unix/sysv/linux/pselect.c
@@ -19,7 +19,7 @@
#include <errno.h>
#include <signal.h>
#include <time.h>
-#include <sys/poll.h>
+#include <sys/select.h>
#include <kernel-features.h>
#include <sysdep-cancel.h>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [glibc/zack/no-nested-includes] Don’t include sys/select.h from sys/types.h.
@ 2019-06-20 16:06 Zack Weinberg
0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2019-06-20 16:06 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 7790 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b42393774860855b596c0cb0b41639c11963e2c9
commit b42393774860855b596c0cb0b41639c11963e2c9
Author: Zack Weinberg <zackw@panix.com>
Date: Sat Mar 16 12:35:25 2019 -0400
Donât include sys/select.h from sys/types.h.
This is supposedly present for BSD compatibility, but the current
generation of BSDs is not consistent about it: FreeBSD does, OpenBSD
doesnât, NetBSD exposes only fd_set and the FD_* macros. Programs
that need to wait for any of multiple I/O events have several
alternatives to select nowadays, so I think it makes sense to expose
select only to programs that specifically want it.
Only a few places within our own code are affected. A few test
programs need to include sys/select.h explicitly, as does rpc/svc.h.
sysdeps/nptl/thread_db.h needs to declare sigset_t, and
sysdeps/unix/sysv/linux/pselect.c was including sys/poll.h instead of
sys/select.h, which is probably a copy-and-paste error. sys/socket.h
needs to forward-declare struct timespec under __USE_GNU, because
recvmmsg has a struct timespec * argument; Iâm open to the possibility
of having it fully declare struct timespec.
I considered taking sys/select.h out of sys/time.h as well, but POSIX
not only explicitly allows this inclusion, it requires sys/time.h to
declare almost everything that sys/select.h declares. It doesnât seem
worth creating another bits header just to prevent sys/time.h from
declaring pselect, sigset_t, and struct timespec.
Not including sys/select.h from sys/types.h means that sys/types.h
also no longer defines anything from sys/time.h, and a couple of files
were relying on that. (pthread_join_common.c should be using
clock_gettime instead of gettimeofday, but that's out of scope for
this patch series.)
* posix/sys/types.h: Donât include sys/select.h.
* scripts/check-obsolete-constructs.py: Remove whitelist entry
for sys/types.h -> sys/select.h. Adjust commentary re
sys/time.h -> sys/select.h.
* socket/sys/socket.h: When __USE_GNU, forward-declare struct timespec.
* misc/tst-fdset.c, nptl/tst-cancel4.c, scripts/check-c++-types.sh
* sunrpc/rpc/svc.h: Include sys/select.h.
* sysdeps/nptl/thread_db.h: Include bits/types/sigset_t.h.
* sysdeps/unix/sysv/linux/pselect.c: Include sys/select.h,
not sys/poll.h.
* nptl/pthread_join_common.c, sysdeps/unix/sysv/linux/dl-vdso.h:
Include sys/time.h.
Diff:
---
misc/tst-fdset.c | 2 +-
nptl/pthread_join_common.c | 2 ++
nptl/tst-cancel4.c | 1 +
posix/sys/types.h | 3 ---
scripts/check-c++-types.sh | 1 +
scripts/check-obsolete-constructs.py | 6 +++---
socket/sys/socket.h | 4 ++++
sunrpc/rpc/svc.h | 1 +
sysdeps/nptl/thread_db.h | 2 +-
sysdeps/unix/sysv/linux/dl-vdso.h | 6 ++++++
sysdeps/unix/sysv/linux/pselect.c | 2 +-
11 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/misc/tst-fdset.c b/misc/tst-fdset.c
index 70b7028..956e371 100644
--- a/misc/tst-fdset.c
+++ b/misc/tst-fdset.c
@@ -18,7 +18,7 @@
<http://www.gnu.org/licenses/>. */
#include <stdio.h>
-#include <sys/types.h>
+#include <sys/select.h>
static int
do_test (void)
diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c
index 5224ee2..b8b016c 100644
--- a/nptl/pthread_join_common.c
+++ b/nptl/pthread_join_common.c
@@ -20,6 +20,8 @@
#include <atomic.h>
#include <stap-probe.h>
+#include <sys/time.h>
+
static void
cleanup (void *arg)
{
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index 60a965d..dce93dc 100644
--- a/nptl/tst-cancel4.c
+++ b/nptl/tst-cancel4.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/select.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/ipc.h>
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 08305cf..9381695 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -93,9 +93,6 @@ __BEGIN_DECLS
/* In BSD <sys/types.h> is expected to define BYTE_ORDER. */
# include <endian.h>
-
-/* It also defines `fd_set' and the FD_* macros for `select'. */
-# include <sys/select.h>
#endif /* Use misc. */
__END_DECLS
diff --git a/scripts/check-c++-types.sh b/scripts/check-c++-types.sh
index a8f3cff..141ddf7 100755
--- a/scripts/check-c++-types.sh
+++ b/scripts/check-c++-types.sh
@@ -46,6 +46,7 @@ while read t; do
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/resource.h>
+#include <sys/select.h>
#include <unistd.h>
void foo ($t) { }
EOF
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index bd5a97f..a051d4e 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -530,13 +530,13 @@ HEADER_ALLOWED_INCLUDES = {
# mandated: sys/msg.h -> sys/ipc.h
# sys/sem.h -> sys/ipc.h
# sys/shm.h -> sys/ipc.h
- # allowed: sys/time.h -> sys/select.h
- # sys/wait.h -> signal.h
+ # sys/time.h -> sys/select.h (effectively)
+ # allowed: sys/wait.h -> signal.h
"sys/msg.h": [ "sys/ipc.h" ],
"sys/sem.h": [ "sys/ipc.h" ],
"sys/shm.h": [ "sys/ipc.h" ],
"sys/time.h": [ "sys/select.h" ],
- "sys/types.h": [ "endian.h", "sys/select.h" ],
+ "sys/types.h": [ "endian.h" ],
"sys/uio.h": [ "sys/types.h" ],
"sys/un.h": [ "string.h" ],
"sys/wait.h": [ "signal.h" ],
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index 1bb90ed..ce793dc 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -35,6 +35,10 @@ __BEGIN_DECLS
# include <bits/types/struct_osockaddr.h>
#endif
+#ifdef __USE_GNU
+struct timespec;
+#endif
+
/* The following constants should be used for the second parameter of
`shutdown'. */
enum
diff --git a/sunrpc/rpc/svc.h b/sunrpc/rpc/svc.h
index 85d0183..c77dcf0 100644
--- a/sunrpc/rpc/svc.h
+++ b/sunrpc/rpc/svc.h
@@ -53,6 +53,7 @@
#include <features.h>
#include <rpc/rpc_msg.h>
+#include <sys/select.h>
__BEGIN_DECLS
diff --git a/sysdeps/nptl/thread_db.h b/sysdeps/nptl/thread_db.h
index d134aca..4d949b0 100644
--- a/sysdeps/nptl/thread_db.h
+++ b/sysdeps/nptl/thread_db.h
@@ -26,7 +26,7 @@
#include <stdint.h>
#include <sys/types.h>
#include <sys/procfs.h>
-
+#include <bits/types/sigset_t.h>
/* Error codes of the library. */
typedef enum
diff --git a/sysdeps/unix/sysv/linux/dl-vdso.h b/sysdeps/unix/sysv/linux/dl-vdso.h
index 50ee290..c0109ba 100644
--- a/sysdeps/unix/sysv/linux/dl-vdso.h
+++ b/sysdeps/unix/sysv/linux/dl-vdso.h
@@ -23,6 +23,12 @@
#include <ldsodefs.h>
#include <dl-hash.h>
+/* This header must declare all functions that might be looked up
+ in the vDSO by code fragments generated by make-syscalls.sh.
+ At present the only such function that isn't covered by the above
+ headers is gettimeofday. */
+#include <sys/time.h>
+
/* Create version number record for lookup. */
#define PREPARE_VERSION(var, vname, vhash) \
struct r_found_version var; \
diff --git a/sysdeps/unix/sysv/linux/pselect.c b/sysdeps/unix/sysv/linux/pselect.c
index c9406ca..d1106e9 100644
--- a/sysdeps/unix/sysv/linux/pselect.c
+++ b/sysdeps/unix/sysv/linux/pselect.c
@@ -19,7 +19,7 @@
#include <errno.h>
#include <signal.h>
#include <time.h>
-#include <sys/poll.h>
+#include <sys/select.h>
#include <kernel-features.h>
#include <sysdep-cancel.h>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [glibc/zack/no-nested-includes] Don’t include sys/select.h from sys/types.h.
@ 2019-06-18 15:33 Zack Weinberg
0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2019-06-18 15:33 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 6337 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d19f158c2b06f162b8297c5560a28d9b7bb7c9f4
commit d19f158c2b06f162b8297c5560a28d9b7bb7c9f4
Author: Zack Weinberg <zackw@panix.com>
Date: Sat Mar 16 12:35:25 2019 -0400
Donât include sys/select.h from sys/types.h.
This is supposedly present for BSD compatibility, but the current
generation of BSDs is not consistent about it: FreeBSD does, OpenBSD
doesnât, NetBSD exposes only fd_set and the FD_* macros. Programs
that need to wait for any of multiple I/O events have several
alternatives to select nowadays, so I think it makes sense to expose
select only to programs that specifically want it.
Only a few places within our own code are affected. A few test
programs need to include sys/select.h explicitly, as does rpc/svc.h.
sysdeps/nptl/thread_db.h needs to declare sigset_t, and
sysdeps/unix/sysv/linux/pselect.c was including sys/poll.h instead of
sys/select.h, which is probably a copy-and-paste error. sys/socket.h
needs to forward-declare struct timespec under __USE_GNU, because
recvmmsg has a struct timespec * argument; Iâm open to the possibility
of having it fully declare struct timespec.
I considered taking sys/select.h out of sys/time.h as well, but POSIX
not only explicitly allows this inclusion, it requires sys/time.h to
declare almost everything that sys/select.h declares. It doesnât seem
worth creating another bits header just to prevent sys/time.h from
declaring pselect, sigset_t, and struct timespec.
* posix/sys/types.h: Donât include sys/select.h.
* scripts/check-obsolete-constructs.py: Remove whitelist entry
for sys/types.h -> sys/select.h. Adjust commentary re
sys/time.h -> sys/select.h.
* socket/sys/socket.h: When __USE_GNU, forward-declare struct timespec.
* misc/tst-fdset.c, nptl/tst-cancel4.c, scripts/check-c++-types.sh
* sunrpc/rpc/svc.h: Include sys/select.h.
* sysdeps/nptl/thread_db.h: Include bits/types/sigset_t.h.
* sysdeps/unix/sysv/linux/pselect.c: Include sys/select.h,
not sys/poll.h.
Diff:
---
misc/tst-fdset.c | 2 +-
nptl/tst-cancel4.c | 1 +
posix/sys/types.h | 3 ---
scripts/check-c++-types.sh | 1 +
scripts/check-obsolete-constructs.py | 6 +++---
socket/sys/socket.h | 4 ++++
sunrpc/rpc/svc.h | 1 +
sysdeps/nptl/thread_db.h | 2 +-
sysdeps/unix/sysv/linux/pselect.c | 2 +-
9 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/misc/tst-fdset.c b/misc/tst-fdset.c
index 70b7028..956e371 100644
--- a/misc/tst-fdset.c
+++ b/misc/tst-fdset.c
@@ -18,7 +18,7 @@
<http://www.gnu.org/licenses/>. */
#include <stdio.h>
-#include <sys/types.h>
+#include <sys/select.h>
static int
do_test (void)
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index 60a965d..dce93dc 100644
--- a/nptl/tst-cancel4.c
+++ b/nptl/tst-cancel4.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/select.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/ipc.h>
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 8f6d328..3f29307 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -95,9 +95,6 @@ __BEGIN_DECLS
/* In BSD <sys/types.h> is expected to define BYTE_ORDER. */
# include <endian.h>
-
-/* It also defines `fd_set' and the FD_* macros for `select'. */
-# include <sys/select.h>
#endif /* Use misc. */
__END_DECLS
diff --git a/scripts/check-c++-types.sh b/scripts/check-c++-types.sh
index a8f3cff..141ddf7 100755
--- a/scripts/check-c++-types.sh
+++ b/scripts/check-c++-types.sh
@@ -46,6 +46,7 @@ while read t; do
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/resource.h>
+#include <sys/select.h>
#include <unistd.h>
void foo ($t) { }
EOF
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index fb63fe5..36d8746 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -538,13 +538,13 @@ HEADER_ALLOWED_INCLUDES = {
# mandated: sys/msg.h -> sys/ipc.h
# sys/sem.h -> sys/ipc.h
# sys/shm.h -> sys/ipc.h
- # allowed: sys/time.h -> sys/select.h
- # sys/wait.h -> signal.h
+ # sys/time.h -> sys/select.h (effectively)
+ # allowed: sys/wait.h -> signal.h
"sys/msg.h": [ "sys/ipc.h" ],
"sys/sem.h": [ "sys/ipc.h" ],
"sys/shm.h": [ "sys/ipc.h" ],
"sys/time.h": [ "sys/select.h" ],
- "sys/types.h": [ "endian.h", "sys/select.h" ],
+ "sys/types.h": [ "endian.h" ],
"sys/uio.h": [ "sys/types.h" ],
"sys/un.h": [ "string.h" ],
"sys/wait.h": [ "signal.h" ],
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index 6f242d0..eebc9b5 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -36,6 +36,10 @@ __BEGIN_DECLS
# include <bits/types/struct_osockaddr.h>
#endif
+#ifdef __USE_GNU
+struct timespec;
+#endif
+
/* The following constants should be used for the second parameter of
`shutdown'. */
enum
diff --git a/sunrpc/rpc/svc.h b/sunrpc/rpc/svc.h
index 85d0183..c77dcf0 100644
--- a/sunrpc/rpc/svc.h
+++ b/sunrpc/rpc/svc.h
@@ -53,6 +53,7 @@
#include <features.h>
#include <rpc/rpc_msg.h>
+#include <sys/select.h>
__BEGIN_DECLS
diff --git a/sysdeps/nptl/thread_db.h b/sysdeps/nptl/thread_db.h
index d134aca..4d949b0 100644
--- a/sysdeps/nptl/thread_db.h
+++ b/sysdeps/nptl/thread_db.h
@@ -26,7 +26,7 @@
#include <stdint.h>
#include <sys/types.h>
#include <sys/procfs.h>
-
+#include <bits/types/sigset_t.h>
/* Error codes of the library. */
typedef enum
diff --git a/sysdeps/unix/sysv/linux/pselect.c b/sysdeps/unix/sysv/linux/pselect.c
index c9406ca..d1106e9 100644
--- a/sysdeps/unix/sysv/linux/pselect.c
+++ b/sysdeps/unix/sysv/linux/pselect.c
@@ -19,7 +19,7 @@
#include <errno.h>
#include <signal.h>
#include <time.h>
-#include <sys/poll.h>
+#include <sys/select.h>
#include <kernel-features.h>
#include <sysdep-cancel.h>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [glibc/zack/no-nested-includes] Don’t include sys/select.h from sys/types.h.
@ 2019-05-16 18:42 Zack Weinberg
0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2019-05-16 18:42 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 6352 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2e7c1201471461479853e85992f62bfd608a5fff
commit 2e7c1201471461479853e85992f62bfd608a5fff
Author: Zack Weinberg <zackw@panix.com>
Date: Sat Mar 16 12:35:25 2019 -0400
Donât include sys/select.h from sys/types.h.
This is supposedly present for BSD compatibility, but the current
generation of BSDs is not consistent about it: FreeBSD does, OpenBSD
doesnât, NetBSD exposes only fd_set and the FD_* macros. Programs
that need to wait for any of multiple I/O events have several
alternatives to select nowadays, so I think it makes sense to expose
select only to programs that specifically want it.
Only a few places within our own code are affected. A few test
programs need to include sys/select.h explicitly, as does rpc/svc.h.
sysdeps/nptl/thread_db.h needs to declare sigset_t, and
sysdeps/unix/sysv/linux/pselect.c was including sys/poll.h instead of
sys/select.h, which is probably a copy-and-paste error. sys/socket.h
needs to forward-declare struct timespec under __USE_GNU, because
recvmmsg has a struct timespec * argument; Iâm open to the possibility
of having it fully declare struct timespec.
I considered taking sys/select.h out of sys/time.h as well, but POSIX
not only explicitly allows this inclusion, it requires sys/time.h to
declare almost everything that sys/select.h declares. It doesnât seem
worth creating another bits header just to prevent sys/time.h from
declaring pselect, sigset_t, and struct timespec.
* posix/sys/types.h: Donât include sys/select.h.
* scripts/check-obsolete-constructs.py: Remove whitelist entry
for sys/types.h -> sys/select.h. Adjust commentary re
sys/time.h -> sys/select.h.
* socket/sys/socket.h: When __USE_GNU, forward-declare struct timespec.
* misc/tst-fdset.c, nptl/tst-cancel4.c, scripts/check-c++-types.sh
* sunrpc/rpc/svc.h: Include sys/select.h.
* sysdeps/nptl/thread_db.h: Include bits/types/sigset_t.h.
* sysdeps/unix/sysv/linux/pselect.c: Include sys/select.h,
not sys/poll.h.
Diff:
---
misc/tst-fdset.c | 2 +-
nptl/tst-cancel4.c | 1 +
posix/sys/types.h | 3 ---
scripts/check-c++-types.sh | 1 +
scripts/check-obsolete-constructs.py | 6 +++---
socket/sys/socket.h | 4 ++++
sunrpc/rpc/svc.h | 1 +
sysdeps/nptl/thread_db.h | 2 +-
sysdeps/unix/sysv/linux/pselect.c | 2 +-
9 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/misc/tst-fdset.c b/misc/tst-fdset.c
index 70b7028..956e371 100644
--- a/misc/tst-fdset.c
+++ b/misc/tst-fdset.c
@@ -18,7 +18,7 @@
<http://www.gnu.org/licenses/>. */
#include <stdio.h>
-#include <sys/types.h>
+#include <sys/select.h>
static int
do_test (void)
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index 60a965d..dce93dc 100644
--- a/nptl/tst-cancel4.c
+++ b/nptl/tst-cancel4.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/select.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/ipc.h>
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 8f6d328..3f29307 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -95,9 +95,6 @@ __BEGIN_DECLS
/* In BSD <sys/types.h> is expected to define BYTE_ORDER. */
# include <endian.h>
-
-/* It also defines `fd_set' and the FD_* macros for `select'. */
-# include <sys/select.h>
#endif /* Use misc. */
__END_DECLS
diff --git a/scripts/check-c++-types.sh b/scripts/check-c++-types.sh
index a8f3cff..141ddf7 100755
--- a/scripts/check-c++-types.sh
+++ b/scripts/check-c++-types.sh
@@ -46,6 +46,7 @@ while read t; do
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/resource.h>
+#include <sys/select.h>
#include <unistd.h>
void foo ($t) { }
EOF
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index ad23458..c498f08 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -542,13 +542,13 @@ HEADER_ALLOWED_INCLUDES = {
# mandated: sys/msg.h -> sys/ipc.h
# sys/sem.h -> sys/ipc.h
# sys/shm.h -> sys/ipc.h
- # allowed: sys/time.h -> sys/select.h
- # sys/wait.h -> signal.h
+ # sys/time.h -> sys/select.h (effectively)
+ # allowed: sys/wait.h -> signal.h
"sys/msg.h": [ "sys/ipc.h" ],
"sys/sem.h": [ "sys/ipc.h" ],
"sys/shm.h": [ "sys/ipc.h" ],
"sys/time.h": [ "sys/select.h" ],
- "sys/types.h": [ "endian.h", "sys/select.h" ],
+ "sys/types.h": [ "endian.h" ],
"sys/uio.h": [ "sys/types.h" ],
"sys/un.h": [ "string.h", "sys/cdefs.h" ],
"sys/wait.h": [ "signal.h" ],
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index 6f242d0..eebc9b5 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -36,6 +36,10 @@ __BEGIN_DECLS
# include <bits/types/struct_osockaddr.h>
#endif
+#ifdef __USE_GNU
+struct timespec;
+#endif
+
/* The following constants should be used for the second parameter of
`shutdown'. */
enum
diff --git a/sunrpc/rpc/svc.h b/sunrpc/rpc/svc.h
index 85d0183..c77dcf0 100644
--- a/sunrpc/rpc/svc.h
+++ b/sunrpc/rpc/svc.h
@@ -53,6 +53,7 @@
#include <features.h>
#include <rpc/rpc_msg.h>
+#include <sys/select.h>
__BEGIN_DECLS
diff --git a/sysdeps/nptl/thread_db.h b/sysdeps/nptl/thread_db.h
index d134aca..4d949b0 100644
--- a/sysdeps/nptl/thread_db.h
+++ b/sysdeps/nptl/thread_db.h
@@ -26,7 +26,7 @@
#include <stdint.h>
#include <sys/types.h>
#include <sys/procfs.h>
-
+#include <bits/types/sigset_t.h>
/* Error codes of the library. */
typedef enum
diff --git a/sysdeps/unix/sysv/linux/pselect.c b/sysdeps/unix/sysv/linux/pselect.c
index c9406ca..d1106e9 100644
--- a/sysdeps/unix/sysv/linux/pselect.c
+++ b/sysdeps/unix/sysv/linux/pselect.c
@@ -19,7 +19,7 @@
#include <errno.h>
#include <signal.h>
#include <time.h>
-#include <sys/poll.h>
+#include <sys/select.h>
#include <kernel-features.h>
#include <sysdep-cancel.h>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [glibc/zack/no-nested-includes] Don’t include sys/select.h from sys/types.h.
@ 2019-05-16 18:36 Zack Weinberg
0 siblings, 0 replies; 7+ messages in thread
From: Zack Weinberg @ 2019-05-16 18:36 UTC (permalink / raw)
To: glibc-cvs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="us-ascii", Size: 6352 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4494336f9a613d6ff612eca0e353b2505f53f11d
commit 4494336f9a613d6ff612eca0e353b2505f53f11d
Author: Zack Weinberg <zackw@panix.com>
Date: Sat Mar 16 12:35:25 2019 -0400
Donât include sys/select.h from sys/types.h.
This is supposedly present for BSD compatibility, but the current
generation of BSDs is not consistent about it: FreeBSD does, OpenBSD
doesnât, NetBSD exposes only fd_set and the FD_* macros. Programs
that need to wait for any of multiple I/O events have several
alternatives to select nowadays, so I think it makes sense to expose
select only to programs that specifically want it.
Only a few places within our own code are affected. A few test
programs need to include sys/select.h explicitly, as does rpc/svc.h.
sysdeps/nptl/thread_db.h needs to declare sigset_t, and
sysdeps/unix/sysv/linux/pselect.c was including sys/poll.h instead of
sys/select.h, which is probably a copy-and-paste error. sys/socket.h
needs to forward-declare struct timespec under __USE_GNU, because
recvmmsg has a struct timespec * argument; Iâm open to the possibility
of having it fully declare struct timespec.
I considered taking sys/select.h out of sys/time.h as well, but POSIX
not only explicitly allows this inclusion, it requires sys/time.h to
declare almost everything that sys/select.h declares. It doesnât seem
worth creating another bits header just to prevent sys/time.h from
declaring pselect, sigset_t, and struct timespec.
* posix/sys/types.h: Donât include sys/select.h.
* scripts/check-obsolete-constructs.py: Remove whitelist entry
for sys/types.h -> sys/select.h. Adjust commentary re
sys/time.h -> sys/select.h.
* socket/sys/socket.h: When __USE_GNU, forward-declare struct timespec.
* misc/tst-fdset.c, nptl/tst-cancel4.c, scripts/check-c++-types.sh
* sunrpc/rpc/svc.h: Include sys/select.h.
* sysdeps/nptl/thread_db.h: Include bits/types/sigset_t.h.
* sysdeps/unix/sysv/linux/pselect.c: Include sys/select.h,
not sys/poll.h.
Diff:
---
misc/tst-fdset.c | 2 +-
nptl/tst-cancel4.c | 1 +
posix/sys/types.h | 3 ---
scripts/check-c++-types.sh | 1 +
scripts/check-obsolete-constructs.py | 6 +++---
socket/sys/socket.h | 4 ++++
sunrpc/rpc/svc.h | 1 +
sysdeps/nptl/thread_db.h | 2 +-
sysdeps/unix/sysv/linux/pselect.c | 2 +-
9 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/misc/tst-fdset.c b/misc/tst-fdset.c
index 70b7028..956e371 100644
--- a/misc/tst-fdset.c
+++ b/misc/tst-fdset.c
@@ -18,7 +18,7 @@
<http://www.gnu.org/licenses/>. */
#include <stdio.h>
-#include <sys/types.h>
+#include <sys/select.h>
static int
do_test (void)
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index 60a965d..dce93dc 100644
--- a/nptl/tst-cancel4.c
+++ b/nptl/tst-cancel4.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/select.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/ipc.h>
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 8f6d328..3f29307 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -95,9 +95,6 @@ __BEGIN_DECLS
/* In BSD <sys/types.h> is expected to define BYTE_ORDER. */
# include <endian.h>
-
-/* It also defines `fd_set' and the FD_* macros for `select'. */
-# include <sys/select.h>
#endif /* Use misc. */
__END_DECLS
diff --git a/scripts/check-c++-types.sh b/scripts/check-c++-types.sh
index a8f3cff..141ddf7 100755
--- a/scripts/check-c++-types.sh
+++ b/scripts/check-c++-types.sh
@@ -46,6 +46,7 @@ while read t; do
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/resource.h>
+#include <sys/select.h>
#include <unistd.h>
void foo ($t) { }
EOF
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index ad23458..c498f08 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -542,13 +542,13 @@ HEADER_ALLOWED_INCLUDES = {
# mandated: sys/msg.h -> sys/ipc.h
# sys/sem.h -> sys/ipc.h
# sys/shm.h -> sys/ipc.h
- # allowed: sys/time.h -> sys/select.h
- # sys/wait.h -> signal.h
+ # sys/time.h -> sys/select.h (effectively)
+ # allowed: sys/wait.h -> signal.h
"sys/msg.h": [ "sys/ipc.h" ],
"sys/sem.h": [ "sys/ipc.h" ],
"sys/shm.h": [ "sys/ipc.h" ],
"sys/time.h": [ "sys/select.h" ],
- "sys/types.h": [ "endian.h", "sys/select.h" ],
+ "sys/types.h": [ "endian.h" ],
"sys/uio.h": [ "sys/types.h" ],
"sys/un.h": [ "string.h", "sys/cdefs.h" ],
"sys/wait.h": [ "signal.h" ],
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index 6f242d0..eebc9b5 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -36,6 +36,10 @@ __BEGIN_DECLS
# include <bits/types/struct_osockaddr.h>
#endif
+#ifdef __USE_GNU
+struct timespec;
+#endif
+
/* The following constants should be used for the second parameter of
`shutdown'. */
enum
diff --git a/sunrpc/rpc/svc.h b/sunrpc/rpc/svc.h
index 85d0183..c77dcf0 100644
--- a/sunrpc/rpc/svc.h
+++ b/sunrpc/rpc/svc.h
@@ -53,6 +53,7 @@
#include <features.h>
#include <rpc/rpc_msg.h>
+#include <sys/select.h>
__BEGIN_DECLS
diff --git a/sysdeps/nptl/thread_db.h b/sysdeps/nptl/thread_db.h
index d134aca..4d949b0 100644
--- a/sysdeps/nptl/thread_db.h
+++ b/sysdeps/nptl/thread_db.h
@@ -26,7 +26,7 @@
#include <stdint.h>
#include <sys/types.h>
#include <sys/procfs.h>
-
+#include <bits/types/sigset_t.h>
/* Error codes of the library. */
typedef enum
diff --git a/sysdeps/unix/sysv/linux/pselect.c b/sysdeps/unix/sysv/linux/pselect.c
index c9406ca..d1106e9 100644
--- a/sysdeps/unix/sysv/linux/pselect.c
+++ b/sysdeps/unix/sysv/linux/pselect.c
@@ -19,7 +19,7 @@
#include <errno.h>
#include <signal.h>
#include <time.h>
-#include <sys/poll.h>
+#include <sys/select.h>
#include <kernel-features.h>
#include <sysdep-cancel.h>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-01-08 19:20 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-26 16:36 [glibc/zack/no-nested-includes] Don’t include sys/select.h from sys/types.h Zack Weinberg
-- strict thread matches above, loose matches on Subject: below --
2020-01-08 19:20 Zack Weinberg
2019-06-26 15:50 Zack Weinberg
2019-06-20 16:06 Zack Weinberg
2019-06-18 15:33 Zack Weinberg
2019-05-16 18:42 Zack Weinberg
2019-05-16 18:36 Zack Weinberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).