From patchwork Wed Jun 26 17:50:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 33439 Received: (qmail 1806 invoked by alias); 26 Jun 2019 18:26:32 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 1797 invoked by uid 89); 26 Jun 2019 18:26:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: l2mail1.panix.com From: Zack Weinberg To: libc-alpha@sourceware.org Cc: joseph@codesourcery.com, carlos@redhat.com Subject: [PATCH 17/25] =?UTF-8?q?Don=E2=80=99t=20include=20sys/select.h=20?= =?UTF-8?q?from=20sys/types.h.?= Date: Wed, 26 Jun 2019 13:50:21 -0400 Message-Id: <20190626175029.4699-8-zackw@panix.com> In-Reply-To: <20190626175029.4699-1-zackw@panix.com> References: <20190626175029.4699-1-zackw@panix.com> MIME-Version: 1.0 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. --- 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 70b7028dad..956e371746 100644 --- a/misc/tst-fdset.c +++ b/misc/tst-fdset.c @@ -18,7 +18,7 @@ . */ #include -#include +#include static int do_test (void) diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c index 5224ee2110..b8b016ccb7 100644 --- a/nptl/pthread_join_common.c +++ b/nptl/pthread_join_common.c @@ -20,6 +20,8 @@ #include #include +#include + static void cleanup (void *arg) { diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c index 60a965d23a..dce93dc03a 100644 --- a/nptl/tst-cancel4.c +++ b/nptl/tst-cancel4.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/posix/sys/types.h b/posix/sys/types.h index 08305cf812..9381695548 100644 --- a/posix/sys/types.h +++ b/posix/sys/types.h @@ -93,9 +93,6 @@ __BEGIN_DECLS /* In BSD is expected to define BYTE_ORDER. */ # include - -/* It also defines `fd_set' and the FD_* macros for `select'. */ -# include #endif /* Use misc. */ __END_DECLS diff --git a/scripts/check-c++-types.sh b/scripts/check-c++-types.sh index a8f3cfff7b..141ddf7440 100755 --- a/scripts/check-c++-types.sh +++ b/scripts/check-c++-types.sh @@ -46,6 +46,7 @@ while read t; do #include #include #include +#include #include void foo ($t) { } EOF diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py index bd5a97f76b..a051d4e845 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 1bb90ed67c..ce793dc3e2 100644 --- a/socket/sys/socket.h +++ b/socket/sys/socket.h @@ -35,6 +35,10 @@ __BEGIN_DECLS # include #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 85d0183d48..c77dcf0c4a 100644 --- a/sunrpc/rpc/svc.h +++ b/sunrpc/rpc/svc.h @@ -53,6 +53,7 @@ #include #include +#include __BEGIN_DECLS diff --git a/sysdeps/nptl/thread_db.h b/sysdeps/nptl/thread_db.h index d134acaa24..4d949b0c37 100644 --- a/sysdeps/nptl/thread_db.h +++ b/sysdeps/nptl/thread_db.h @@ -26,7 +26,7 @@ #include #include #include - +#include /* 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 9e61ca7423..edecf5faf4 100644 --- a/sysdeps/unix/sysv/linux/dl-vdso.h +++ b/sysdeps/unix/sysv/linux/dl-vdso.h @@ -23,6 +23,12 @@ #include #include +/* 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 + /* 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 c9406cac09..d1106e9b18 100644 --- a/sysdeps/unix/sysv/linux/pselect.c +++ b/sysdeps/unix/sysv/linux/pselect.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include