public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/zack/no-nested-includes] Don’t include signal.h from sys/wait.h or sys/param.h.
@ 2020-01-08 19:20 Zack Weinberg
0 siblings, 0 replies; 3+ 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: 22027 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=39906a3e2c0811b6097ec53cbe7b4d9f2321315e
commit 39906a3e2c0811b6097ec53cbe7b4d9f2321315e
Author: Zack Weinberg <zackw@panix.com>
Date: Mon Jun 10 11:34:41 2019 -0400
Donât include signal.h from sys/wait.h or sys/param.h.
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.
Diff:
---
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 | 25 +++++++++++-----------
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 +-
.../unix/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, 80 insertions(+), 49 deletions(-)
diff --git a/bits/param.h b/bits/param.h
index df5634e..9528af9 100644
--- a/bits/param.h
+++ b/bits/param.h
@@ -16,6 +16,9 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#ifndef _BITS_PARAM_H
+#define _BITS_PARAM_H 1
+
#ifndef _SYS_PARAM_H
# error "Never use <bits/param.h> directly; include <sys/param.h> 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 504e5fb..6c6281a 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 <bits/signum-generic.h> directly; use <signal.h> instead."
#endif
diff --git a/bits/signum.h b/bits/signum.h
index 183e3c0..5361e00 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/conform/data/sys/wait.h-data b/conform/data/sys/wait.h-data
index c076142..aa3a87e 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 00851a1..d1d973c 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 <assert.h>
#include <errno.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/misc/sys/param.h b/misc/sys/param.h
index eca50cf..c50c4ce 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
<https://www.gnu.org/licenses/>. */
+/* This header is provided only for compatibility with historic Unix
+ systems. New programs should use some combination of <endian.h>,
+ <limits.h>, <signal.h>, <stddef.h>, <stdint.h>, and <sys/types.h>
+ 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 <sys/types.h>
#include <limits.h>
#include <endian.h> /* Define BYTE_ORDER et al. */
-#include <signal.h> /* Define NSIG. */
+#include <bits/signum.h> /* Define NSIG. */
#include <bits/NULL.h>
/* This file defines some things in system-specific ways. */
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index 5ede8a0..4931bf3 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 <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <pthread.h>
+#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#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>
-#include <sys/msg.h>
-#include <unistd.h>
-#include <errno.h>
-#include <limits.h>
-#include <pthread.h>
-#include <fcntl.h>
#include <termios.h>
+#include <unistd.h>
+#include <sys/ipc.h>
#include <sys/mman.h>
+#include <sys/msg.h>
#include <sys/poll.h>
-#include <sys/wait.h>
+#include <sys/select.h>
+#include <sys/socket.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <sys/uio.h>
+#include <sys/un.h>
+#include <sys/wait.h>
/* Since STREAMS are not supported in the standard Linux kernel and
diff --git a/nptl/tst-fork4.c b/nptl/tst-fork4.c
index 3efbb72..e1b1ff9 100644
--- a/nptl/tst-fork4.c
+++ b/nptl/tst-fork4.c
@@ -18,6 +18,7 @@
#include <errno.h>
#include <pthread.h>
+#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
diff --git a/nptl/tst-getpid3.c b/nptl/tst-getpid3.c
index f1e77f6..3883a47 100644
--- a/nptl/tst-getpid3.c
+++ b/nptl/tst-getpid3.c
@@ -1,5 +1,6 @@
#include <errno.h>
#include <pthread.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/nptl/tst-mutex9.c b/nptl/tst-mutex9.c
index 2d7927b..04487f6 100644
--- a/nptl/tst-mutex9.c
+++ b/nptl/tst-mutex9.c
@@ -18,6 +18,7 @@
#include <errno.h>
#include <pthread.h>
+#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/nptl/tst-rwlock12.c b/nptl/tst-rwlock12.c
index 73937fe..89919bb 100644
--- a/nptl/tst-rwlock12.c
+++ b/nptl/tst-rwlock12.c
@@ -18,6 +18,7 @@
#include <errno.h>
#include <pthread.h>
+#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/posix/sys/wait.h b/posix/sys/wait.h
index d4646ac..1e128d0 100644
--- a/posix/sys/wait.h
+++ b/posix/sys/wait.h
@@ -30,7 +30,7 @@ __BEGIN_DECLS
#include <bits/types/pid_t.h>
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-# include <signal.h>
+# include <bits/types/siginfo_t.h>
#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 17021ac..c46282d 100644
--- a/resolv/tst-resolv-res_init-skeleton.c
+++ b/resolv/tst-resolv-res_init-skeleton.c
@@ -25,6 +25,7 @@
#include <gnu/lib-names.h>
#include <netdb.h>
#include <resolv/resolv_context.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <support/capture_subprocess.h>
diff --git a/rt/tst-mqueue1.c b/rt/tst-mqueue1.c
index c35580b..6e83a82 100644
--- a/rt/tst-mqueue1.c
+++ b/rt/tst-mqueue1.c
@@ -20,13 +20,14 @@
#include <errno.h>
#include <fcntl.h>
#include <mqueue.h>
+#include <signal.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
-#include <stdint.h>
+#include <sys/wait.h>
#include "tst-mqueue.h"
static int
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 77999d8..48a21cd 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 67bbc1e..86442fe 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
<https://www.gnu.org/licenses/>. */
+#include <errno.h>
+#include <getopt.h>
+#include <limits.h>
+#include <paths.h>
+#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#include <array_length.h>
#include <support/capture_subprocess.h>
#include <support/check.h>
#include <support/support.h>
#include <support/temp_file.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <paths.h>
-#include <getopt.h>
-#include <limits.h>
-#include <errno.h>
-#include <array_length.h>
/* 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 c288664..25875ce 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
<https://www.gnu.org/licenses/>. */
+#ifndef _BITS_PARAM_H
+#define _BITS_PARAM_H 1
+
#ifndef _SYS_PARAM_H
# error "Never use <bits/param.h> directly; include <sys/param.h> instead."
#endif
#include <bits/mach/param.h>
-/* 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<<FSHIFT)
+
+#endif /* bits/param.h */
diff --git a/sysdeps/mach/hurd/i386/Makefile b/sysdeps/mach/hurd/i386/Makefile
index 2a7d138..aa23a4b 100644
--- a/sysdeps/mach/hurd/i386/Makefile
+++ b/sysdeps/mach/hurd/i386/Makefile
@@ -36,7 +36,6 @@ test-xfail-UNIX98/aio.h/conform = yes
test-xfail-UNIX98/ftw.h/conform = yes
test-xfail-UNIX98/mqueue.h/conform = yes
test-xfail-UNIX98/netinet/in.h/conform = yes
-test-xfail-UNIX98/sys/wait.h/conform = yes
test-xfail-UNIX98/sys/sem.h/conform = yes
test-xfail-UNIX98/sys/uio.h/conform = yes
test-xfail-UNIX98/sys/socket.h/conform = yes
@@ -51,7 +50,6 @@ test-xfail-POSIX2008/regex.h/conform = yes
test-xfail-POSIX2008/aio.h/conform = yes
test-xfail-POSIX2008/mqueue.h/conform = yes
test-xfail-POSIX2008/netinet/in.h/conform = yes
-test-xfail-POSIX2008/sys/wait.h/conform = yes
test-xfail-POSIX2008/sys/socket.h/conform = yes
test-xfail-POSIX2008/sys/types.h/conform = yes
test-xfail-POSIX2008/arpa/inet.h/conform = yes
@@ -64,7 +62,6 @@ test-xfail-XOPEN2K/aio.h/conform = yes
test-xfail-XOPEN2K/ftw.h/conform = yes
test-xfail-XOPEN2K/mqueue.h/conform = yes
test-xfail-XOPEN2K/netinet/in.h/conform = yes
-test-xfail-XOPEN2K/sys/wait.h/conform = yes
test-xfail-XOPEN2K/sys/sem.h/conform = yes
test-xfail-XOPEN2K/sys/uio.h/conform = yes
test-xfail-XOPEN2K/sys/socket.h/conform = yes
@@ -80,7 +77,6 @@ test-xfail-XOPEN2K8/aio.h/conform = yes
test-xfail-XOPEN2K8/ftw.h/conform = yes
test-xfail-XOPEN2K8/mqueue.h/conform = yes
test-xfail-XOPEN2K8/netinet/in.h/conform = yes
-test-xfail-XOPEN2K8/sys/wait.h/conform = yes
test-xfail-XOPEN2K8/sys/sem.h/conform = yes
test-xfail-XOPEN2K8/sys/uio.h/conform = yes
test-xfail-XOPEN2K8/sys/socket.h/conform = yes
diff --git a/sysdeps/mach/i386/bits/mach/param.h b/sysdeps/mach/i386/bits/mach/param.h
index 80d6f9f..daa4b8e 100644
--- a/sysdeps/mach/i386/bits/mach/param.h
+++ b/sysdeps/mach/i386/bits/mach/param.h
@@ -16,6 +16,9 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#ifndef _BITS_MACH_PARAM_H
+#define _BITS_MACH_PARAM_H 1
+
#ifndef _SYS_PARAM_H
# error "Never use <bits/mach/param.h> directly; include <sys/param.h> 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 a8d47af..292782f 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/signum.h b/sysdeps/unix/sysv/linux/alpha/bits/signum.h
index 63add0e..1cfa208 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/bits/param.h b/sysdeps/unix/sysv/linux/bits/param.h
index 1ed5dbd..1557a1d 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
<https://www.gnu.org/licenses/>. */
+#ifndef _BITS_PARAM_H
+#define _BITS_PARAM_H 1
+
#ifndef _SYS_PARAM_H
# error "Never use <bits/param.h> directly; include <sys/param.h> 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 423fd8b..19646fe 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/hppa/bits/signum.h b/sysdeps/unix/sysv/linux/hppa/bits/signum.h
index 2210304..8c9441e 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/mips/bits/signum.h b/sysdeps/unix/sysv/linux/mips/bits/signum.h
index f5a5e7b..05363d9 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 <bits/signum.h> directly; use <signal.h> 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 9535889..adbe427 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
<https://www.gnu.org/licenses/>. */
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/signum.h b/sysdeps/unix/sysv/linux/sparc/bits/signum.h
index 40fb39a..42e7212 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/tst-align-clone.c b/sysdeps/unix/sysv/linux/tst-align-clone.c
index 261ef9e..2fe303d 100644
--- a/sysdeps/unix/sysv/linux/tst-align-clone.c
+++ b/sysdeps/unix/sysv/linux/tst-align-clone.c
@@ -16,14 +16,15 @@
<https://www.gnu.org/licenses/>. */
#include <sched.h>
+#include <signal.h>
+#include <stackinfo.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
-#include <sys/wait.h>
#include <unistd.h>
+#include <sys/wait.h>
#include <tst-stack-align.h>
-#include <stackinfo.h>
static int
f (void *arg)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [glibc/zack/no-nested-includes] Don’t include signal.h from sys/wait.h or sys/param.h.
@ 2019-06-26 15:50 Zack Weinberg
0 siblings, 0 replies; 3+ 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: 22019 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ecc75db5004317eb766c5dd8ddc4e9d4fd2c4d1c
commit ecc75db5004317eb766c5dd8ddc4e9d4fd2c4d1c
Author: Zack Weinberg <zackw@panix.com>
Date: Mon Jun 10 11:34:41 2019 -0400
Donât include signal.h from sys/wait.h or sys/param.h.
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.
Diff:
---
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 | 25 +++++++++++-----------
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 +-
.../unix/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, 80 insertions(+), 49 deletions(-)
diff --git a/bits/param.h b/bits/param.h
index e83f60f..44c8505 100644
--- a/bits/param.h
+++ b/bits/param.h
@@ -16,6 +16,9 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#ifndef _BITS_PARAM_H
+#define _BITS_PARAM_H 1
+
#ifndef _SYS_PARAM_H
# error "Never use <bits/param.h> directly; include <sys/param.h> 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 6fbbf20..71308d6 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 <bits/signum-generic.h> directly; use <signal.h> instead."
#endif
diff --git a/bits/signum.h b/bits/signum.h
index 8c788c8..90e13c9 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/conform/data/sys/wait.h-data b/conform/data/sys/wait.h-data
index c076142..aa3a87e 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 00851a1..d1d973c 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 <assert.h>
#include <errno.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/misc/sys/param.h b/misc/sys/param.h
index bb6478f..1dedc69 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
<http://www.gnu.org/licenses/>. */
+/* This header is provided only for compatibility with historic Unix
+ systems. New programs should use some combination of <endian.h>,
+ <limits.h>, <signal.h>, <stddef.h>, <stdint.h>, and <sys/types.h>
+ 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 <sys/types.h>
#include <limits.h>
#include <endian.h> /* Define BYTE_ORDER et al. */
-#include <signal.h> /* Define NSIG. */
+#include <bits/signum.h> /* Define NSIG. */
#include <bits/NULL.h>
/* This file defines some things in system-specific ways. */
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index dce93dc..575c09d 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 <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <pthread.h>
+#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#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>
-#include <sys/msg.h>
-#include <unistd.h>
-#include <errno.h>
-#include <limits.h>
-#include <pthread.h>
-#include <fcntl.h>
#include <termios.h>
+#include <unistd.h>
+#include <sys/ipc.h>
#include <sys/mman.h>
+#include <sys/msg.h>
#include <sys/poll.h>
-#include <sys/wait.h>
+#include <sys/select.h>
+#include <sys/socket.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <sys/uio.h>
+#include <sys/un.h>
+#include <sys/wait.h>
/* Since STREAMS are not supported in the standard Linux kernel and
diff --git a/nptl/tst-fork4.c b/nptl/tst-fork4.c
index b491d3e..4deaf24 100644
--- a/nptl/tst-fork4.c
+++ b/nptl/tst-fork4.c
@@ -18,6 +18,7 @@
#include <errno.h>
#include <pthread.h>
+#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
diff --git a/nptl/tst-getpid3.c b/nptl/tst-getpid3.c
index f1e77f6..3883a47 100644
--- a/nptl/tst-getpid3.c
+++ b/nptl/tst-getpid3.c
@@ -1,5 +1,6 @@
#include <errno.h>
#include <pthread.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/nptl/tst-mutex9.c b/nptl/tst-mutex9.c
index e9fd8e2..4efd97b 100644
--- a/nptl/tst-mutex9.c
+++ b/nptl/tst-mutex9.c
@@ -18,6 +18,7 @@
#include <errno.h>
#include <pthread.h>
+#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/nptl/tst-rwlock12.c b/nptl/tst-rwlock12.c
index 2d28a5b..70a678f 100644
--- a/nptl/tst-rwlock12.c
+++ b/nptl/tst-rwlock12.c
@@ -18,6 +18,7 @@
#include <errno.h>
#include <pthread.h>
+#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/posix/sys/wait.h b/posix/sys/wait.h
index 691be27..7f8e069 100644
--- a/posix/sys/wait.h
+++ b/posix/sys/wait.h
@@ -30,7 +30,7 @@ __BEGIN_DECLS
#include <bits/types/pid_t.h>
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-# include <signal.h>
+# include <bits/types/siginfo_t.h>
#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 678f396..32a7907 100644
--- a/resolv/tst-resolv-res_init-skeleton.c
+++ b/resolv/tst-resolv-res_init-skeleton.c
@@ -25,6 +25,7 @@
#include <gnu/lib-names.h>
#include <netdb.h>
#include <resolv/resolv_context.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <support/capture_subprocess.h>
diff --git a/rt/tst-mqueue1.c b/rt/tst-mqueue1.c
index fb8d2e2..5e5039a 100644
--- a/rt/tst-mqueue1.c
+++ b/rt/tst-mqueue1.c
@@ -20,13 +20,14 @@
#include <errno.h>
#include <fcntl.h>
#include <mqueue.h>
+#include <signal.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
-#include <stdint.h>
+#include <sys/wait.h>
#include "tst-mqueue.h"
static int
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index a051d4e..bca0f12 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 ab363e4..11e8cb7 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
<http://www.gnu.org/licenses/>. */
+#include <errno.h>
+#include <getopt.h>
+#include <limits.h>
+#include <paths.h>
+#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#include <array_length.h>
#include <support/capture_subprocess.h>
#include <support/check.h>
#include <support/support.h>
#include <support/temp_file.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <paths.h>
-#include <getopt.h>
-#include <limits.h>
-#include <errno.h>
-#include <array_length.h>
/* 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 a0162e9..09485f1 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
<http://www.gnu.org/licenses/>. */
+#ifndef _BITS_PARAM_H
+#define _BITS_PARAM_H 1
+
#ifndef _SYS_PARAM_H
# error "Never use <bits/param.h> directly; include <sys/param.h> instead."
#endif
#include <bits/mach/param.h>
-/* 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<<FSHIFT)
+
+#endif /* bits/param.h */
diff --git a/sysdeps/mach/hurd/i386/Makefile b/sysdeps/mach/hurd/i386/Makefile
index 8404eb0..bf62a5f 100644
--- a/sysdeps/mach/hurd/i386/Makefile
+++ b/sysdeps/mach/hurd/i386/Makefile
@@ -36,7 +36,6 @@ test-xfail-UNIX98/aio.h/conform = yes
test-xfail-UNIX98/ftw.h/conform = yes
test-xfail-UNIX98/mqueue.h/conform = yes
test-xfail-UNIX98/netinet/in.h/conform = yes
-test-xfail-UNIX98/sys/wait.h/conform = yes
test-xfail-UNIX98/sys/sem.h/conform = yes
test-xfail-UNIX98/sys/uio.h/conform = yes
test-xfail-UNIX98/sys/socket.h/conform = yes
@@ -51,7 +50,6 @@ test-xfail-POSIX2008/regex.h/conform = yes
test-xfail-POSIX2008/aio.h/conform = yes
test-xfail-POSIX2008/mqueue.h/conform = yes
test-xfail-POSIX2008/netinet/in.h/conform = yes
-test-xfail-POSIX2008/sys/wait.h/conform = yes
test-xfail-POSIX2008/sys/socket.h/conform = yes
test-xfail-POSIX2008/sys/types.h/conform = yes
test-xfail-POSIX2008/arpa/inet.h/conform = yes
@@ -64,7 +62,6 @@ test-xfail-XOPEN2K/aio.h/conform = yes
test-xfail-XOPEN2K/ftw.h/conform = yes
test-xfail-XOPEN2K/mqueue.h/conform = yes
test-xfail-XOPEN2K/netinet/in.h/conform = yes
-test-xfail-XOPEN2K/sys/wait.h/conform = yes
test-xfail-XOPEN2K/sys/sem.h/conform = yes
test-xfail-XOPEN2K/sys/uio.h/conform = yes
test-xfail-XOPEN2K/sys/socket.h/conform = yes
@@ -80,7 +77,6 @@ test-xfail-XOPEN2K8/aio.h/conform = yes
test-xfail-XOPEN2K8/ftw.h/conform = yes
test-xfail-XOPEN2K8/mqueue.h/conform = yes
test-xfail-XOPEN2K8/netinet/in.h/conform = yes
-test-xfail-XOPEN2K8/sys/wait.h/conform = yes
test-xfail-XOPEN2K8/sys/sem.h/conform = yes
test-xfail-XOPEN2K8/sys/uio.h/conform = yes
test-xfail-XOPEN2K8/sys/socket.h/conform = yes
diff --git a/sysdeps/mach/i386/bits/mach/param.h b/sysdeps/mach/i386/bits/mach/param.h
index 09a549d..3fbe86a 100644
--- a/sysdeps/mach/i386/bits/mach/param.h
+++ b/sysdeps/mach/i386/bits/mach/param.h
@@ -16,6 +16,9 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#ifndef _BITS_MACH_PARAM_H
+#define _BITS_MACH_PARAM_H 1
+
#ifndef _SYS_PARAM_H
# error "Never use <bits/mach/param.h> directly; include <sys/param.h> 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 7e3df32..e0178e9 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/signum.h b/sysdeps/unix/sysv/linux/alpha/bits/signum.h
index da4ff93..4355d35 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/bits/param.h b/sysdeps/unix/sysv/linux/bits/param.h
index 53c0f9f..f847c51 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
<http://www.gnu.org/licenses/>. */
+#ifndef _BITS_PARAM_H
+#define _BITS_PARAM_H 1
+
#ifndef _SYS_PARAM_H
# error "Never use <bits/param.h> directly; include <sys/param.h> 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 25b0d2a..86fde6a 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/hppa/bits/signum.h b/sysdeps/unix/sysv/linux/hppa/bits/signum.h
index c643626..5959966 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/mips/bits/signum.h b/sysdeps/unix/sysv/linux/mips/bits/signum.h
index 89a63e4..1a430c1 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 <bits/signum.h> directly; use <signal.h> 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 89e86ad..e7d36d2 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
<http://www.gnu.org/licenses/>. */
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/signum.h b/sysdeps/unix/sysv/linux/sparc/bits/signum.h
index ec746fe..866a1c3 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/tst-align-clone.c b/sysdeps/unix/sysv/linux/tst-align-clone.c
index 82ecf7b..100eacf 100644
--- a/sysdeps/unix/sysv/linux/tst-align-clone.c
+++ b/sysdeps/unix/sysv/linux/tst-align-clone.c
@@ -16,14 +16,15 @@
<http://www.gnu.org/licenses/>. */
#include <sched.h>
+#include <signal.h>
+#include <stackinfo.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
-#include <sys/wait.h>
#include <unistd.h>
+#include <sys/wait.h>
#include <tst-stack-align.h>
-#include <stackinfo.h>
static int
f (void *arg)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [glibc/zack/no-nested-includes] Don’t include signal.h from sys/wait.h or sys/param.h.
@ 2019-06-20 16:06 Zack Weinberg
0 siblings, 0 replies; 3+ 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: 20105 bytes --]
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b761b9106d2e7b70596c857cd0193b000c8c1389
commit b761b9106d2e7b70596c857cd0193b000c8c1389
Author: Zack Weinberg <zackw@panix.com>
Date: Mon Jun 10 11:34:41 2019 -0400
Donât include signal.h from sys/wait.h or sys/param.h.
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.
* 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.
Diff:
---
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 | 25 +++++++++++-----------
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/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 +-
.../unix/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 +++--
27 files changed, 80 insertions(+), 45 deletions(-)
diff --git a/bits/param.h b/bits/param.h
index e83f60f..44c8505 100644
--- a/bits/param.h
+++ b/bits/param.h
@@ -16,6 +16,9 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#ifndef _BITS_PARAM_H
+#define _BITS_PARAM_H 1
+
#ifndef _SYS_PARAM_H
# error "Never use <bits/param.h> directly; include <sys/param.h> 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 6fbbf20..71308d6 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 <bits/signum-generic.h> directly; use <signal.h> instead."
#endif
diff --git a/bits/signum.h b/bits/signum.h
index 8c788c8..90e13c9 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/conform/data/sys/wait.h-data b/conform/data/sys/wait.h-data
index c076142..aa3a87e 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 00851a1..d1d973c 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 <assert.h>
#include <errno.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/misc/sys/param.h b/misc/sys/param.h
index bb6478f..1dedc69 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
<http://www.gnu.org/licenses/>. */
+/* This header is provided only for compatibility with historic Unix
+ systems. New programs should use some combination of <endian.h>,
+ <limits.h>, <signal.h>, <stddef.h>, <stdint.h>, and <sys/types.h>
+ 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 <sys/types.h>
#include <limits.h>
#include <endian.h> /* Define BYTE_ORDER et al. */
-#include <signal.h> /* Define NSIG. */
+#include <bits/signum.h> /* Define NSIG. */
#include <bits/NULL.h>
/* This file defines some things in system-specific ways. */
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index dce93dc..575c09d 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 <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <pthread.h>
+#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#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>
-#include <sys/msg.h>
-#include <unistd.h>
-#include <errno.h>
-#include <limits.h>
-#include <pthread.h>
-#include <fcntl.h>
#include <termios.h>
+#include <unistd.h>
+#include <sys/ipc.h>
#include <sys/mman.h>
+#include <sys/msg.h>
#include <sys/poll.h>
-#include <sys/wait.h>
+#include <sys/select.h>
+#include <sys/socket.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <sys/uio.h>
+#include <sys/un.h>
+#include <sys/wait.h>
/* Since STREAMS are not supported in the standard Linux kernel and
diff --git a/nptl/tst-fork4.c b/nptl/tst-fork4.c
index b491d3e..4deaf24 100644
--- a/nptl/tst-fork4.c
+++ b/nptl/tst-fork4.c
@@ -18,6 +18,7 @@
#include <errno.h>
#include <pthread.h>
+#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
diff --git a/nptl/tst-getpid3.c b/nptl/tst-getpid3.c
index f1e77f6..3883a47 100644
--- a/nptl/tst-getpid3.c
+++ b/nptl/tst-getpid3.c
@@ -1,5 +1,6 @@
#include <errno.h>
#include <pthread.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/nptl/tst-mutex9.c b/nptl/tst-mutex9.c
index 917276e..0e2c8d8 100644
--- a/nptl/tst-mutex9.c
+++ b/nptl/tst-mutex9.c
@@ -18,6 +18,7 @@
#include <errno.h>
#include <pthread.h>
+#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/nptl/tst-rwlock12.c b/nptl/tst-rwlock12.c
index 2d28a5b..70a678f 100644
--- a/nptl/tst-rwlock12.c
+++ b/nptl/tst-rwlock12.c
@@ -18,6 +18,7 @@
#include <errno.h>
#include <pthread.h>
+#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/posix/sys/wait.h b/posix/sys/wait.h
index 691be27..7f8e069 100644
--- a/posix/sys/wait.h
+++ b/posix/sys/wait.h
@@ -30,7 +30,7 @@ __BEGIN_DECLS
#include <bits/types/pid_t.h>
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-# include <signal.h>
+# include <bits/types/siginfo_t.h>
#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 678f396..32a7907 100644
--- a/resolv/tst-resolv-res_init-skeleton.c
+++ b/resolv/tst-resolv-res_init-skeleton.c
@@ -25,6 +25,7 @@
#include <gnu/lib-names.h>
#include <netdb.h>
#include <resolv/resolv_context.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <support/capture_subprocess.h>
diff --git a/rt/tst-mqueue1.c b/rt/tst-mqueue1.c
index fb8d2e2..5e5039a 100644
--- a/rt/tst-mqueue1.c
+++ b/rt/tst-mqueue1.c
@@ -20,13 +20,14 @@
#include <errno.h>
#include <fcntl.h>
#include <mqueue.h>
+#include <signal.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
-#include <stdint.h>
+#include <sys/wait.h>
#include "tst-mqueue.h"
static int
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index a051d4e..bca0f12 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 ab363e4..11e8cb7 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
<http://www.gnu.org/licenses/>. */
+#include <errno.h>
+#include <getopt.h>
+#include <limits.h>
+#include <paths.h>
+#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#include <array_length.h>
#include <support/capture_subprocess.h>
#include <support/check.h>
#include <support/support.h>
#include <support/temp_file.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <paths.h>
-#include <getopt.h>
-#include <limits.h>
-#include <errno.h>
-#include <array_length.h>
/* 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 a0162e9..09485f1 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
<http://www.gnu.org/licenses/>. */
+#ifndef _BITS_PARAM_H
+#define _BITS_PARAM_H 1
+
#ifndef _SYS_PARAM_H
# error "Never use <bits/param.h> directly; include <sys/param.h> instead."
#endif
#include <bits/mach/param.h>
-/* 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<<FSHIFT)
+
+#endif /* bits/param.h */
diff --git a/sysdeps/mach/i386/bits/mach/param.h b/sysdeps/mach/i386/bits/mach/param.h
index 09a549d..3fbe86a 100644
--- a/sysdeps/mach/i386/bits/mach/param.h
+++ b/sysdeps/mach/i386/bits/mach/param.h
@@ -16,6 +16,9 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#ifndef _BITS_MACH_PARAM_H
+#define _BITS_MACH_PARAM_H 1
+
#ifndef _SYS_PARAM_H
# error "Never use <bits/mach/param.h> directly; include <sys/param.h> 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 7e3df32..e0178e9 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/signum.h b/sysdeps/unix/sysv/linux/alpha/bits/signum.h
index da4ff93..4355d35 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/bits/param.h b/sysdeps/unix/sysv/linux/bits/param.h
index 53c0f9f..f847c51 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
<http://www.gnu.org/licenses/>. */
+#ifndef _BITS_PARAM_H
+#define _BITS_PARAM_H 1
+
#ifndef _SYS_PARAM_H
# error "Never use <bits/param.h> directly; include <sys/param.h> 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 25b0d2a..86fde6a 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/hppa/bits/signum.h b/sysdeps/unix/sysv/linux/hppa/bits/signum.h
index c643626..5959966 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/mips/bits/signum.h b/sysdeps/unix/sysv/linux/mips/bits/signum.h
index 89a63e4..1a430c1 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 <bits/signum.h> directly; use <signal.h> 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 89e86ad..e7d36d2 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
<http://www.gnu.org/licenses/>. */
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/signum.h b/sysdeps/unix/sysv/linux/sparc/bits/signum.h
index ec746fe..866a1c3 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 <bits/signum.h> directly; use <signal.h> instead."
#endif
diff --git a/sysdeps/unix/sysv/linux/tst-align-clone.c b/sysdeps/unix/sysv/linux/tst-align-clone.c
index 82ecf7b..100eacf 100644
--- a/sysdeps/unix/sysv/linux/tst-align-clone.c
+++ b/sysdeps/unix/sysv/linux/tst-align-clone.c
@@ -16,14 +16,15 @@
<http://www.gnu.org/licenses/>. */
#include <sched.h>
+#include <signal.h>
+#include <stackinfo.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
-#include <sys/wait.h>
#include <unistd.h>
+#include <sys/wait.h>
#include <tst-stack-align.h>
-#include <stackinfo.h>
static int
f (void *arg)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-01-08 19:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-08 19:20 [glibc/zack/no-nested-includes] Don’t include signal.h from sys/wait.h or sys/param.h Zack Weinberg
-- strict thread matches above, loose matches on Subject: below --
2019-06-26 15:50 Zack Weinberg
2019-06-20 16:06 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).