From patchwork Wed Jun 26 17:50:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 33440 Received: (qmail 2092 invoked by alias); 26 Jun 2019 18:26:34 -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 2027 invoked by uid 89); 26 Jun 2019 18:26:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.1 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=california, California X-HELO: l2mail1.panix.com From: Zack Weinberg To: libc-alpha@sourceware.org Cc: joseph@codesourcery.com, carlos@redhat.com Subject: [PATCH 18/25] =?UTF-8?q?Don=E2=80=99t=20include=20signal.h=20from?= =?UTF-8?q?=20sys/wait.h=20or=20sys/param.h.?= Date: Wed, 26 Jun 2019 13:50:22 -0400 Message-Id: <20190626175029.4699-9-zackw@panix.com> In-Reply-To: <20190626175029.4699-1-zackw@panix.com> References: <20190626175029.4699-1-zackw@panix.com> MIME-Version: 1.0 Besides the snarl of debugger/ucontext interfaces, these are the only public headers that include signal.h. sys/wait.h includes signal.h only for the definition of siginfo_t. We already have a single-type header for that, so use it. siginfo_t contains a field whose type is uid_t, but sys/wait.h is not specified to define uid_t, so, as is already done for pid_t, the conformance test is modified to expect that field to have type __uid_t instead. It is not clear what subset of the definitions from signal.h are actually expected by historical users of sys/param.h; I’ve chosen to take the comment at face value and cut it down to bits/signum.h, which supplies _NSIG and all of the SIG* constants. This requires adjusting every copy of bits/signum.h to permit inclusion by sys/param.h as well as signal.h. While I was at it I moved the comment about sys/param.h being obsolete from sysdeps/mach/hurd/bits/param.h, where it’s not likely to be seen, to the top-level sys/param.h, and edited it to give more useful advice. This patch partially fixes Hurd-specific bug 23088; sys/wait.h is now conformant. * posix/sys/wait.h: Include bits/types/siginfo_t.h, not signal.h. * conform/data/sys/wait.h-data: Do not expect a definition of uid_t. * malloc/tst-mallocfork.c, nptl/tst-fork4.c, nptl/tst-getpid3.c * nptl/tst-mutex9.c, nptl/tst-rwlock12.c * resolv/tst-resolv-res_init-skeleton.c * sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c: Include signal.h. * nptl/tst-cancel4.c, rt/tst-mqueue1.c * support/tst-support_capture_subprocess.c * sysdeps/unix/sysv/linux/tst-align-clone.c: Include signal.h. Sort includes. * misc/sys/param.h: Include bits/signum.h, not signal.h. Add comment explaining that this header is obsolete, based on a similar comment in Hurd bits/param.h. * bits/param.h: Add multiple inclusion guard and defensive #error. * sysdeps/mach/hurd/bits/param.h: Add multiple inclusion guard. Remove comment explaining that this header is obsolete (see above). * sysdeps/mach/i386/bits/mach/param.h: Add multiple inclusion guard. * sysdeps/unix/sysv/linux/bits/param.h: Add multiple inclusion guard. * bits/signum-generic.h, bits/signum.h * sysdeps/unix/bsd/bits/signum.h * sysdeps/unix/sysv/linux/alpha/bits/signum.h * sysdeps/unix/sysv/linux/bits/signum.h * sysdeps/unix/sysv/linux/hppa/bits/signum.h * sysdeps/unix/sysv/linux/mips/bits/signum.h: Allow inclusion by sys/param.h as well as signal.h. * scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES): Update. * sysdeps/mach/hurd/i386/Makefile: Remove XFAILs for sys/wait.h. --- bits/param.h | 7 +++++ bits/signum-generic.h | 2 +- bits/signum.h | 2 +- conform/data/sys/wait.h-data | 1 + malloc/tst-mallocfork.c | 1 + misc/sys/param.h | 8 +++++- nptl/tst-cancel4.c | 27 ++++++++++--------- nptl/tst-fork4.c | 1 + nptl/tst-getpid3.c | 1 + nptl/tst-mutex9.c | 1 + nptl/tst-rwlock12.c | 1 + posix/sys/wait.h | 2 +- resolv/tst-resolv-res_init-skeleton.c | 1 + rt/tst-mqueue1.c | 5 ++-- scripts/check-obsolete-constructs.py | 7 +++-- support/tst-support_capture_subprocess.c | 19 +++++++------ sysdeps/mach/hurd/bits/param.h | 13 +++++---- sysdeps/mach/hurd/i386/Makefile | 4 --- sysdeps/mach/i386/bits/mach/param.h | 5 ++++ sysdeps/unix/bsd/bits/signum.h | 2 +- sysdeps/unix/sysv/linux/alpha/bits/signum.h | 2 +- sysdeps/unix/sysv/linux/bits/param.h | 5 ++++ sysdeps/unix/sysv/linux/bits/signum.h | 2 +- sysdeps/unix/sysv/linux/hppa/bits/signum.h | 2 +- sysdeps/unix/sysv/linux/mips/bits/signum.h | 2 +- .../sysv/linux/s390/tst-ptrace-singleblock.c | 1 + sysdeps/unix/sysv/linux/sparc/bits/signum.h | 2 +- sysdeps/unix/sysv/linux/tst-align-clone.c | 5 ++-- 28 files changed, 81 insertions(+), 50 deletions(-) diff --git a/bits/param.h b/bits/param.h index e83f60f0b5..44c8505ad0 100644 --- a/bits/param.h +++ b/bits/param.h @@ -16,6 +16,9 @@ License along with the GNU C Library; if not, see . */ +#ifndef _BITS_PARAM_H +#define _BITS_PARAM_H 1 + #ifndef _SYS_PARAM_H # error "Never use directly; include instead." #endif @@ -31,3 +34,7 @@ EXEC_PAGESIZE */ + +#error "Generic bits/param.h should not have been used." + +#endif diff --git a/bits/signum-generic.h b/bits/signum-generic.h index 6fbbf20a31..71308d635d 100644 --- a/bits/signum-generic.h +++ b/bits/signum-generic.h @@ -19,7 +19,7 @@ #ifndef _BITS_SIGNUM_GENERIC_H #define _BITS_SIGNUM_GENERIC_H 1 -#ifndef _SIGNAL_H +#if !defined _SIGNAL_H && !defined _SYS_PARAM_H #error "Never include directly; use instead." #endif diff --git a/bits/signum.h b/bits/signum.h index 8c788c8e7e..90e13c9824 100644 --- a/bits/signum.h +++ b/bits/signum.h @@ -19,7 +19,7 @@ #ifndef _BITS_SIGNUM_H #define _BITS_SIGNUM_H 1 -#ifndef _SIGNAL_H +#if !defined _SIGNAL_H && !defined _SYS_PARAM_H #error "Never include directly; use instead." #endif diff --git a/conform/data/sys/wait.h-data b/conform/data/sys/wait.h-data index c0761424da..aa3a87ea15 100644 --- a/conform/data/sys/wait.h-data +++ b/conform/data/sys/wait.h-data @@ -2,6 +2,7 @@ #ifdef POSIX # define pid_t __pid_t #endif +#define uid_t __uid_t constant WNOHANG constant WUNTRACED diff --git a/malloc/tst-mallocfork.c b/malloc/tst-mallocfork.c index 00851a16c3..d1d973c28b 100644 --- a/malloc/tst-mallocfork.c +++ b/malloc/tst-mallocfork.c @@ -2,6 +2,7 @@ https://sourceware.org/bugzilla/show_bug.cgi?id=838. */ #include #include +#include #include #include #include diff --git a/misc/sys/param.h b/misc/sys/param.h index bb6478f79b..1dedc699a4 100644 --- a/misc/sys/param.h +++ b/misc/sys/param.h @@ -16,6 +16,12 @@ License along with the GNU C Library; if not, see . */ +/* This header is provided only for compatibility with historic Unix + systems. New programs should use some combination of , + , , , , and + instead, and the names defined in those headers. The utility + macros at the end of this header should not be used at all. */ + #ifndef _SYS_PARAM_H #define _SYS_PARAM_H 1 @@ -24,7 +30,7 @@ #include #include #include /* Define BYTE_ORDER et al. */ -#include /* Define NSIG. */ +#include /* Define NSIG. */ #include /* This file defines some things in system-specific ways. */ diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c index dce93dc03a..575c09d53f 100644 --- a/nptl/tst-cancel4.c +++ b/nptl/tst-cancel4.c @@ -19,27 +19,28 @@ /* NOTE: this tests functionality beyond POSIX. POSIX does not allow exit to be called more than once. */ +#include +#include +#include +#include +#include #include #include #include #include -#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include #include +#include +#include /* Since STREAMS are not supported in the standard Linux kernel and diff --git a/nptl/tst-fork4.c b/nptl/tst-fork4.c index b491d3eec8..4deaf2476c 100644 --- a/nptl/tst-fork4.c +++ b/nptl/tst-fork4.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include diff --git a/nptl/tst-getpid3.c b/nptl/tst-getpid3.c index f1e77f6b10..3883a471ed 100644 --- a/nptl/tst-getpid3.c +++ b/nptl/tst-getpid3.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include diff --git a/nptl/tst-mutex9.c b/nptl/tst-mutex9.c index e9fd8e2859..4efd97bb45 100644 --- a/nptl/tst-mutex9.c +++ b/nptl/tst-mutex9.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include diff --git a/nptl/tst-rwlock12.c b/nptl/tst-rwlock12.c index 2d28a5b1d3..70a678f9eb 100644 --- a/nptl/tst-rwlock12.c +++ b/nptl/tst-rwlock12.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include diff --git a/posix/sys/wait.h b/posix/sys/wait.h index 691be2759c..7f8e0693dc 100644 --- a/posix/sys/wait.h +++ b/posix/sys/wait.h @@ -30,7 +30,7 @@ __BEGIN_DECLS #include #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 -# include +# include #endif #if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8 diff --git a/resolv/tst-resolv-res_init-skeleton.c b/resolv/tst-resolv-res_init-skeleton.c index 678f396c4c..32a790774f 100644 --- a/resolv/tst-resolv-res_init-skeleton.c +++ b/resolv/tst-resolv-res_init-skeleton.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/rt/tst-mqueue1.c b/rt/tst-mqueue1.c index fb8d2e2ff0..5e5039a14b 100644 --- a/rt/tst-mqueue1.c +++ b/rt/tst-mqueue1.c @@ -20,13 +20,14 @@ #include #include #include +#include +#include #include #include #include -#include #include #include -#include +#include #include "tst-mqueue.h" static int diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py index a051d4e845..bca0f12c18 100755 --- a/scripts/check-obsolete-constructs.py +++ b/scripts/check-obsolete-constructs.py @@ -531,15 +531,15 @@ HEADER_ALLOWED_INCLUDES = { # sys/sem.h -> sys/ipc.h # sys/shm.h -> sys/ipc.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" ], + # necessary for backward compatibility with BSD "sys/types.h": [ "endian.h" ], + "sys/uio.h": [ "sys/types.h" ], "sys/un.h": [ "string.h" ], - "sys/wait.h": [ "signal.h" ], # POSIX networking headers # allowed: netdb.h -> netinet/in.h @@ -593,8 +593,7 @@ HEADER_ALLOWED_INCLUDES = { "sys/ioctl.h": [ "sys/ttydefaults.h" ], "sys/mount.h": [ "sys/ioctl.h" ], "sys/mtio.h": [ "sys/ioctl.h", "sys/types.h" ], - "sys/param.h": [ "endian.h", "limits.h", "signal.h", - "sys/types.h" ], + "sys/param.h": [ "endian.h", "limits.h", "sys/types.h" ], "sys/platform/ppc.h": [ "stdint.h" ], "sys/procfs.h": [ "sys/time.h", "sys/types.h", "sys/user.h" ], diff --git a/support/tst-support_capture_subprocess.c b/support/tst-support_capture_subprocess.c index ab363e41ac..11e8cb7282 100644 --- a/support/tst-support_capture_subprocess.c +++ b/support/tst-support_capture_subprocess.c @@ -16,21 +16,23 @@ License along with the GNU C Library; if not, see . */ +#include +#include +#include +#include +#include #include #include #include #include +#include +#include + +#include #include #include #include #include -#include -#include -#include -#include -#include -#include -#include /* Nonzero if the program gets called via 'exec'. */ static int restart; @@ -273,7 +275,8 @@ do_multiple_tests (enum test_type type) .out = random_string (lengths[length_idx_stdout]), .err = random_string (lengths[length_idx_stderr]), .write_mode = write_mode, - .signal = signal * SIGTERM, /* 0 or SIGTERM. */ + .signal = signal * + SIGTERM, /* 0 or SIGTERM. */ .status = status * 3, /* 0 or 3. */ }; TEST_VERIFY (strlen (test.out) == lengths[length_idx_stdout]); diff --git a/sysdeps/mach/hurd/bits/param.h b/sysdeps/mach/hurd/bits/param.h index a0162e9ac8..09485f1d3e 100644 --- a/sysdeps/mach/hurd/bits/param.h +++ b/sysdeps/mach/hurd/bits/param.h @@ -16,19 +16,16 @@ License along with the GNU C Library; if not, see . */ +#ifndef _BITS_PARAM_H +#define _BITS_PARAM_H 1 + #ifndef _SYS_PARAM_H # error "Never use directly; include instead." #endif #include -/* This file is deprecated and is provided only for compatibility with - Unix systems. It is unwise to include this file on programs which - are intended only for GNU systems. - - Parts from: - - * Copyright (c) 1982, 1986, 1989 The Regents of the University of California. +/* Copyright (c) 1982, 1986, 1989 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -85,3 +82,5 @@ #define FSHIFT 11 /* Bits to right of fixed binary point. */ #define FSCALE (1<. */ +#ifndef _BITS_MACH_PARAM_H +#define _BITS_MACH_PARAM_H 1 + #ifndef _SYS_PARAM_H # error "Never use directly; include instead." #endif @@ -23,3 +26,5 @@ #ifndef EXEC_PAGESIZE #define EXEC_PAGESIZE 4096 #endif + +#endif diff --git a/sysdeps/unix/bsd/bits/signum.h b/sysdeps/unix/bsd/bits/signum.h index 7e3df3273b..e0178e9390 100644 --- a/sysdeps/unix/bsd/bits/signum.h +++ b/sysdeps/unix/bsd/bits/signum.h @@ -19,7 +19,7 @@ #ifndef _BITS_SIGNUM_H #define _BITS_SIGNUM_H 1 -#ifndef _SIGNAL_H +#if !defined _SIGNAL_H && !defined _SYS_PARAM_H #error "Never include directly; use instead." #endif diff --git a/sysdeps/unix/sysv/linux/alpha/bits/signum.h b/sysdeps/unix/sysv/linux/alpha/bits/signum.h index da4ff93c9c..4355d35ab9 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/signum.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/signum.h @@ -19,7 +19,7 @@ #ifndef _BITS_SIGNUM_H #define _BITS_SIGNUM_H 1 -#ifndef _SIGNAL_H +#if !defined _SIGNAL_H && !defined _SYS_PARAM_H #error "Never include directly; use instead." #endif diff --git a/sysdeps/unix/sysv/linux/bits/param.h b/sysdeps/unix/sysv/linux/bits/param.h index 53c0f9f136..f847c51031 100644 --- a/sysdeps/unix/sysv/linux/bits/param.h +++ b/sysdeps/unix/sysv/linux/bits/param.h @@ -16,6 +16,9 @@ License along with the GNU C Library; if not, see . */ +#ifndef _BITS_PARAM_H +#define _BITS_PARAM_H 1 + #ifndef _SYS_PARAM_H # error "Never use directly; include instead." #endif @@ -40,3 +43,5 @@ and NCARGS anyway. */ #define NOFILE 256 #define NCARGS 131072 + +#endif /* bits/param.h */ diff --git a/sysdeps/unix/sysv/linux/bits/signum.h b/sysdeps/unix/sysv/linux/bits/signum.h index 25b0d2a6cf..86fde6a7d1 100644 --- a/sysdeps/unix/sysv/linux/bits/signum.h +++ b/sysdeps/unix/sysv/linux/bits/signum.h @@ -19,7 +19,7 @@ #ifndef _BITS_SIGNUM_H #define _BITS_SIGNUM_H 1 -#ifndef _SIGNAL_H +#if !defined _SIGNAL_H && !defined _SYS_PARAM_H #error "Never include directly; use instead." #endif diff --git a/sysdeps/unix/sysv/linux/hppa/bits/signum.h b/sysdeps/unix/sysv/linux/hppa/bits/signum.h index c643626f99..59599668cf 100644 --- a/sysdeps/unix/sysv/linux/hppa/bits/signum.h +++ b/sysdeps/unix/sysv/linux/hppa/bits/signum.h @@ -19,7 +19,7 @@ #ifndef _BITS_SIGNUM_H #define _BITS_SIGNUM_H 1 -#ifndef _SIGNAL_H +#if !defined _SIGNAL_H && !defined _SYS_PARAM_H #error "Never include directly; use instead." #endif diff --git a/sysdeps/unix/sysv/linux/mips/bits/signum.h b/sysdeps/unix/sysv/linux/mips/bits/signum.h index 89a63e4a03..1a430c16ba 100644 --- a/sysdeps/unix/sysv/linux/mips/bits/signum.h +++ b/sysdeps/unix/sysv/linux/mips/bits/signum.h @@ -19,7 +19,7 @@ #ifndef _BITS_SIGNUM_H #define _BITS_SIGNUM_H 1 -#ifndef _SIGNAL_H +#if !defined _SIGNAL_H && !defined _SYS_PARAM_H #error "Never include directly; use instead." #endif diff --git a/sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c b/sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c index 89e86ad923..e7d36d2d75 100644 --- a/sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c +++ b/sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c @@ -16,6 +16,7 @@ License along with the GNU C Library; if not, see . */ +#include #include #include #include diff --git a/sysdeps/unix/sysv/linux/sparc/bits/signum.h b/sysdeps/unix/sysv/linux/sparc/bits/signum.h index ec746fee99..866a1c3d9d 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/signum.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/signum.h @@ -19,7 +19,7 @@ #ifndef _BITS_SIGNUM_H #define _BITS_SIGNUM_H 1 -#ifndef _SIGNAL_H +#if !defined _SIGNAL_H && !defined _SYS_PARAM_H #error "Never include directly; use instead." #endif diff --git a/sysdeps/unix/sysv/linux/tst-align-clone.c b/sysdeps/unix/sysv/linux/tst-align-clone.c index 82ecf7ba32..100eacfbfe 100644 --- a/sysdeps/unix/sysv/linux/tst-align-clone.c +++ b/sysdeps/unix/sysv/linux/tst-align-clone.c @@ -16,14 +16,15 @@ . */ #include +#include +#include #include #include #include #include -#include #include +#include #include -#include static int f (void *arg)