public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/zack/no-nested-includes] Don't include sys/types.h 8/n: Linux debugger headers
@ 2019-06-18 15:35 Zack Weinberg
  0 siblings, 0 replies; 2+ messages in thread
From: Zack Weinberg @ 2019-06-18 15:35 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: 32952 bytes --]

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=29d6f4e7d12a2607317654e1f5813e4a37155432

commit 29d6f4e7d12a2607317654e1f5813e4a37155432
Author: Zack Weinberg <zackw@panix.com>
Date:   Sun May 26 12:30:46 2019 -0400

    Don't include sys/types.h 8/n: Linux debugger headers
    
    The debugger interface headers are a mess and I only have so much
    patience for them.  This does the bare minimum required for
    thread_db.h, sys/procfs.h, and sys/user.h, which are at least
    nominally cross-platform interfaces, to avoid including sys/types.h,
    sys/time.h, and/or signal.h.  Exposure of sys/ucontext.h is reduced
    but not eliminated.  Cross-architecture consistency should be improved.
    
    	* sysdeps/nptl/sys/procfs.h: Include features.h and bits/types.h,
    	not sys/types.h.
    	* sysdeps/nptl/thread_db.h: Don’t include sys/types.h.
    	* sysdeps/nptl/proc_service.h: Include stddef.h for size_t.
            Include bits/types/pid_t.h.
    
    	* sysdeps/unix/sysv/linux/sys/procfs.h: Include bits/types.h and
    	bits/types/struct_timeval.h, not sys/time.h or sys/types.h.
    
    	* sysdeps/unix/sysv/linux/aarch64/bits/procfs.h: Add multiple
    	inclusion guard.  Include bits/types.h.  Correct a comment.
    	* sysdeps/unix/sysv/linux/aarch64/sys/user.h: Include features.h.
    
    	* sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h:
    	Add multiple inclusion guard.  Include sys/ucontext.h.
    	* sysdeps/unix/sysv/linux/alpha/bits/procfs.h:
    	Add multiple inclusion guard.  Don’t include signal.h or
    	sys/ucontext.h.
    	* sysdeps/unix/sysv/linux/alpha/sys/user.h:
    	Include features.h.  Include stddef.h for size_t.  Move
    	inclusion of asm/reg.h above documentation comment.
    
    	* sysdeps/unix/sysv/linux/arm/bits/procfs.h: Add multiple
    	inclusion guard.  Improve commentary.
    	* sysdeps/unix/sysv/linux/arm/sys/user.h: Include features.h.
    
    	* sysdeps/unix/sysv/linux/csky/bits/procfs.h: Add multiple
    	inclusion guard.
    
    	* sysdeps/unix/sysv/linux/hppa/bits/procfs.h: Add multiple
    	inclusion guard.
    
    	* sysdeps/unix/sysv/linux/ia64/bits/procfs.h: Add multiple
    	inclusion guard.  Include sys/ucontext.h, not signal.h.
    	* sysdeps/unix/sysv/linux/ia64/sys/user.h:  Don’t include
    	sys/types.h.  Include stddef.h for size_t.
    
    	* sysdeps/unix/sysv/linux/m68k/bits/procfs.h: Add multiple
    	inclusion guard.  Improve commentary.
    	* sysdeps/unix/sysv/linux/m68k/sys/user.h: Include features.h.
    
    	* sysdeps/unix/sysv/linux/microblaze/bits/procfs.h: Add multiple
    	inclusion guard.  Improve commentary.
    	* sysdeps/unix/sysv/linux/microblaze/sys/user.h: Include features.h.
    
    	* sysdeps/unix/sysv/linux/mips/bits/procfs.h: Add multiple
    	inclusion guard.
    	* sysdeps/unix/sysv/linux/mips/sys/user.h: Include features.h.
    	Define __need_size_t before including stddef.h.  Move inclusion
    	of sgidefs.h below standard headers.
    
    	* sysdeps/unix/sysv/linux/nios2/bits/procfs.h: Add multiple
    	inclusion guard.
    	* sysdeps/unix/sysv/linux/nios2/sys/user.h: Include features.h.
    
    	* sysdeps/unix/sysv/linux/powerpc/bits/procfs.h: Add multiple
    	inclusion guard.  Don’t include signal.h or sys/ucontext.h.
    	Include bits/wordsize.h and asm/elf.h.  Adjust conditional for
    	whether to provide various fallback definitions.
    	* sysdeps/unix/sysv/linux/powerpc/sys/user.h:  Include features.h.
    	Define __need_size_t before including stddef.h.
    
    	* sysdeps/unix/sysv/linux/riscv/bits/procfs.h: Add multiple
    	inclusion guard.  Add comment noting potential problems with
    	use of sys/ucontext.h.
    
    	* sysdeps/unix/sysv/linux/s390/bits/procfs.h: Add multiple
    	inclusion guard.  Add comment noting potential problems with
    	use of sys/ucontext.h.
    	* sysdeps/unix/sysv/linux/s390/sys/user.h: Include features.h.
    
    	* sysdeps/unix/sysv/linux/sh/bits/procfs.h: Add multiple
    	inclusion guard.
    	* sysdeps/unix/sysv/linux/sh/sys/user.h: Include features.h.
    	Define __need_size_t before including stddef.h.  Include
    	asm/ptrace after above two headers.
    
    	* sysdeps/unix/sysv/linux/sparc/bits/procfs.h: Add multiple
    	inclusion guard.  Don’t include signal.h or sys/ucontext.h.
    	* sysdeps/unix/sysv/linux/sparc/sys/user.h:  Include features.h.
    	Define __need_size_t before including stddef.h.
    
    	* sysdeps/unix/sysv/linux/x86/bits/procfs.h: Add multiple
    	inclusion guard.
    	* sysdeps/unix/sysv/linux/x86/sys/user.h: Include features.h.
    
    	* scripts/check-obsolete-constructs.py
    	(HEADER_ALLOWED_INCLUDES, SYSDEP_ALLOWED_INCLUDES): Update.

Diff:
---
 scripts/check-obsolete-constructs.py                 | 10 ++++------
 sysdeps/nptl/proc_service.h                          |  5 +++++
 sysdeps/nptl/sys/procfs.h                            |  3 ++-
 sysdeps/nptl/thread_db.h                             |  1 -
 sysdeps/unix/sysv/linux/aarch64/bits/procfs.h        | 13 +++++++++++--
 sysdeps/unix/sysv/linux/aarch64/sys/user.h           |  2 ++
 sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h |  9 +++++++++
 sysdeps/unix/sysv/linux/alpha/bits/procfs.h          |  8 +++++---
 sysdeps/unix/sysv/linux/alpha/sys/user.h             | 10 +++++++---
 sysdeps/unix/sysv/linux/arm/bits/procfs.h            |  9 ++++++++-
 sysdeps/unix/sysv/linux/arm/sys/user.h               |  2 ++
 sysdeps/unix/sysv/linux/csky/bits/procfs.h           |  5 +++++
 sysdeps/unix/sysv/linux/hppa/bits/procfs.h           |  5 +++++
 sysdeps/unix/sysv/linux/ia64/bits/procfs.h           |  8 +++++++-
 sysdeps/unix/sysv/linux/ia64/sys/user.h              |  4 +++-
 sysdeps/unix/sysv/linux/m68k/bits/procfs.h           |  9 ++++++++-
 sysdeps/unix/sysv/linux/m68k/sys/user.h              |  2 ++
 sysdeps/unix/sysv/linux/microblaze/bits/procfs.h     |  9 ++++++++-
 sysdeps/unix/sysv/linux/microblaze/sys/user.h        |  4 +++-
 sysdeps/unix/sysv/linux/mips/bits/procfs.h           |  5 +++++
 sysdeps/unix/sysv/linux/mips/sys/user.h              |  6 +++++-
 sysdeps/unix/sysv/linux/nios2/bits/procfs.h          |  5 +++++
 sysdeps/unix/sysv/linux/nios2/sys/user.h             |  2 ++
 sysdeps/unix/sysv/linux/powerpc/bits/procfs.h        | 20 +++++++++++++-------
 sysdeps/unix/sysv/linux/powerpc/sys/user.h           |  6 ++++--
 sysdeps/unix/sysv/linux/riscv/bits/procfs.h          |  8 ++++++++
 sysdeps/unix/sysv/linux/s390/bits/procfs.h           |  7 +++++++
 sysdeps/unix/sysv/linux/s390/sys/user.h              |  2 ++
 sysdeps/unix/sysv/linux/sh/bits/procfs.h             |  5 +++++
 sysdeps/unix/sysv/linux/sh/sys/user.h                |  6 +++++-
 sysdeps/unix/sysv/linux/sparc/bits/procfs.h          |  7 +++++--
 sysdeps/unix/sysv/linux/sparc/sys/user.h             |  3 +++
 sysdeps/unix/sysv/linux/sys/procfs.h                 |  6 ++++--
 sysdeps/unix/sysv/linux/x86/bits/procfs.h            |  5 +++++
 sysdeps/unix/sysv/linux/x86/sys/user.h               |  2 ++
 35 files changed, 176 insertions(+), 37 deletions(-)

diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index e2b6b5f..6907c26 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -581,8 +581,7 @@ HEADER_ALLOWED_INCLUDES = {
     "stdio_ext.h":                 [ "stdio.h" ],
     "syscall.h":                   [ "sys/syscall.h" ],
     "termio.h":                    [ "sys/ioctl.h", "termios.h" ],
-    "thread_db.h":                 [ "pthread.h", "stdint.h", "sys/procfs.h",
-                                     "sys/types.h" ],
+    "thread_db.h":                 [ "pthread.h", "stdint.h", "sys/procfs.h" ],
     "ucontext.h":                  [ "sys/ucontext.h" ],
     "utmp.h":                      [ "paths.h" ],
     "values.h":                    [ "float.h", "limits.h" ],
@@ -605,8 +604,7 @@ HEADER_ALLOWED_INCLUDES = {
     "sys/param.h":                 [ "endian.h", "limits.h", "signal.h",
                                      "sys/types.h" ],
     "sys/platform/ppc.h":          [ "stdint.h" ],
-    "sys/procfs.h":                [ "sys/time.h", "sys/types.h",
-                                     "sys/user.h" ],
+    "sys/procfs.h":                [ "sys/ucontext.h", "sys/user.h" ],
     "sys/ptrace.h":                [ "sys/ucontext.h" ],
     "sys/raw.h":                   [ "stdint.h", "sys/ioctl.h" ],
     "sys/signal.h":                [ "signal.h" ],
@@ -618,7 +616,6 @@ HEADER_ALLOWED_INCLUDES = {
     "sys/ttychars.h":              [ "sys/ttydefaults.h" ],
     "sys/ucontext.h":              [ "sys/procfs.h" ],
     "sys/unistd.h":                [ "unistd.h" ],
-    "sys/user.h":                  [ "sys/types.h" ],
     "sys/vfs.h":                   [ "sys/statfs.h" ],
     "sys/xattr.h":                 [ "sys/types.h" ],
 
@@ -719,7 +716,8 @@ SYSDEP_ALLOWED_INCLUDES = {
         "bits/ioctls.h":           [ "asm/ioctls.h", "linux/sockios.h" ],
         "bits/local_lim.h":        [ "linux/limits.h" ],
         "bits/param.h":            [ "linux/limits.h", "linux/param.h" ],
-        "bits/procfs.h":           [ "asm/ptrace.h" ],
+        "bits/procfs.h":           [ "asm/elf.h", "asm/ptrace.h" ],
+        "bits/procfs-prregset.h":  [ "sys/ucontext.h" ],
         "bits/sigcontext.h":       [ "asm/sigcontext.h" ],
         "bits/socket.h":           [ "asm/socket.h" ],
     },
diff --git a/sysdeps/nptl/proc_service.h b/sysdeps/nptl/proc_service.h
index 4aa52c6..524e71f 100644
--- a/sysdeps/nptl/proc_service.h
+++ b/sysdeps/nptl/proc_service.h
@@ -22,6 +22,11 @@
 /* The definitions in this file must correspond to those in the debugger.  */
 #include <sys/procfs.h>
 
+#define __need_size_t
+#include <stddef.h>
+
+#include <bits/types/pid_t.h>
+
 __BEGIN_DECLS
 
 /* Functions in this interface return one of these status codes.  */
diff --git a/sysdeps/nptl/sys/procfs.h b/sysdeps/nptl/sys/procfs.h
index 6ade66d..0f88674 100644
--- a/sysdeps/nptl/sys/procfs.h
+++ b/sysdeps/nptl/sys/procfs.h
@@ -19,7 +19,8 @@
 #ifndef _SYS_PROCFS_H
 #define _SYS_PROCFS_H	1
 
-#include <sys/types.h>
+#include <features.h>
+#include <bits/types.h>
 
 /* The rest of this file provides the types for emulation of the
    Solaris <proc_service.h> interfaces that should be implemented by
diff --git a/sysdeps/nptl/thread_db.h b/sysdeps/nptl/thread_db.h
index 4d949b0..3d6cb3a 100644
--- a/sysdeps/nptl/thread_db.h
+++ b/sysdeps/nptl/thread_db.h
@@ -24,7 +24,6 @@
    with the goal to share the same code in the debugger.  */
 #include <pthread.h>
 #include <stdint.h>
-#include <sys/types.h>
 #include <sys/procfs.h>
 #include <bits/types/sigset_t.h>
 
diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/procfs.h b/sysdeps/unix/sysv/linux/aarch64/bits/procfs.h
index ea91de0..fec2f6a 100644
--- a/sysdeps/unix/sysv/linux/aarch64/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/aarch64/bits/procfs.h
@@ -17,19 +17,28 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
+#include <bits/types.h>
+
 /* Type for a general-purpose register.  */
 typedef __uint64_t elf_greg_t;
 
 /* And the whole bunch of them.  We could have used `struct
-   pt_regs' directly in the typedef, but tradition says that
+   user_regs_struct' directly in the typedef, but tradition says that
    the register set is an array, which does have some peculiar
-   semantics, so leave it that way.  */
+   semantics, so leave it that way.
+
+   struct user_regs_struct is defined in sys/user.h.  */
 #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof (elf_greg_t))
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 /* Register set for the floating-point registers.  */
 typedef struct user_fpsimd_struct elf_fpregset_t;
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/aarch64/sys/user.h b/sysdeps/unix/sysv/linux/aarch64/sys/user.h
index 7f6d8be..949484a 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sys/user.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sys/user.h
@@ -19,6 +19,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
 struct user_regs_struct
 {
   unsigned long long regs[31];
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h b/sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h
index a5fffc0..58b015f 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h
@@ -17,9 +17,18 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_PRREGSET_H
+#define _BITS_PROCFS_PRREGSET_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs-prregset.h> directly; use <sys/procfs.h> instead."
 #endif
 
+/* For gregset_t and fpregset_t.  FIXME: sys/procfs.h should not
+   expose all of sys/ucontext.h.  */
+#include <sys/ucontext.h>
+
 typedef gregset_t __prgregset_t;
 typedef fpregset_t __prfpregset_t;
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/procfs.h b/sysdeps/unix/sysv/linux/alpha/bits/procfs.h
index d0fd280..f04a453 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/procfs.h
@@ -16,13 +16,13 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
-#include <signal.h>
-#include <sys/ucontext.h>
-
 /*
  * The OSF/1 version of <sys/procfs.h> makes gregset_t 46 entries long.
  * I have no idea why that is so.  For now, we just leave it at 33
@@ -36,3 +36,5 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 typedef double elf_fpreg_t;
 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/alpha/sys/user.h b/sysdeps/unix/sysv/linux/alpha/sys/user.h
index 38fcb51..9e36cf4 100644
--- a/sysdeps/unix/sysv/linux/alpha/sys/user.h
+++ b/sysdeps/unix/sysv/linux/alpha/sys/user.h
@@ -18,13 +18,17 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
+#define __need_size_t
+#include <stddef.h>
+
+#include <asm/reg.h>
+
 /* The whole purpose of this file is for gdb/strace and gdb/strace
    only. Don't read too much into it. Don't use it for anything other
    than gdb/strace unless you know what you are doing. */
 
-#include <asm/reg.h>
-#include <stddef.h>
-
 struct user
 {
   unsigned long	int regs[EF_SIZE / 8 + 32];	/* integer and fp regs */
diff --git a/sysdeps/unix/sysv/linux/arm/bits/procfs.h b/sysdeps/unix/sysv/linux/arm/bits/procfs.h
index f168b3a..333fff6 100644
--- a/sysdeps/unix/sysv/linux/arm/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/arm/bits/procfs.h
@@ -16,6 +16,9 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -26,9 +29,13 @@ typedef unsigned long elf_greg_t;
 /* And the whole bunch of them.  We could have used `struct
    user_regs' directly in the typedef, but tradition says that
    the register set is an array, which does have some peculiar
-   semantics, so leave it that way.  */
+   semantics, so leave it that way.
+
+   struct user_regs is defined in sys/user.h.  */
 #define ELF_NGREG (sizeof (struct user_regs) / sizeof (elf_greg_t))
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 /* Register set for the floating-point registers.  */
 typedef struct user_fpregs elf_fpregset_t;
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/arm/sys/user.h b/sysdeps/unix/sysv/linux/arm/sys/user.h
index aae8a99..55db6ca 100644
--- a/sysdeps/unix/sysv/linux/arm/sys/user.h
+++ b/sysdeps/unix/sysv/linux/arm/sys/user.h
@@ -18,6 +18,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
 /* The whole purpose of this file is for GDB and GDB only.  Don't read
    too much into it.  Don't use it for anything other than GDB unless
    you know what you are doing.  */
diff --git a/sysdeps/unix/sysv/linux/csky/bits/procfs.h b/sysdeps/unix/sysv/linux/csky/bits/procfs.h
index 4ec0c5e..97982b6 100644
--- a/sysdeps/unix/sysv/linux/csky/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/csky/bits/procfs.h
@@ -16,6 +16,9 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -35,3 +38,5 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 #define ELF_NFPREG (sizeof (struct user_fp) / sizeof (elf_fpreg_t))
 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/hppa/bits/procfs.h b/sysdeps/unix/sysv/linux/hppa/bits/procfs.h
index 9d57472..5bbdb2b 100644
--- a/sysdeps/unix/sysv/linux/hppa/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/hppa/bits/procfs.h
@@ -16,6 +16,9 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -28,3 +31,5 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 #define ELF_NFPREG 32
 typedef double elf_fpreg_t;
 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/ia64/bits/procfs.h b/sysdeps/unix/sysv/linux/ia64/bits/procfs.h
index 8918975..754e969 100644
--- a/sysdeps/unix/sysv/linux/ia64/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/ia64/bits/procfs.h
@@ -16,11 +16,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
-#include <signal.h>
+/* For struct __ia64_fpreg.  FIXME: sys/procfs.h should not expose all
+   of sys/ucontext.h.  */
 #include <sys/ucontext.h>
 #include <bits/sigcontext.h>
 
@@ -39,3 +43,5 @@ typedef elf_greg_t greg_t;
 typedef elf_gregset_t gregset_t;
 typedef elf_fpregset_t fpregset_t;
 #define NGREG ELF_NGREG
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/ia64/sys/user.h b/sysdeps/unix/sysv/linux/ia64/sys/user.h
index f409e23..87b27c3 100644
--- a/sysdeps/unix/sysv/linux/ia64/sys/user.h
+++ b/sysdeps/unix/sysv/linux/ia64/sys/user.h
@@ -19,7 +19,9 @@
 #define _SYS_USER_H	1
 
 #include <features.h>
-#include <sys/types.h>
+
+#define __need_size_t
+#include <stddef.h>
 
 /* This definition comes directly from the kernel headers.  If
    anything changes in them this header has to be changed, too.  */
diff --git a/sysdeps/unix/sysv/linux/m68k/bits/procfs.h b/sysdeps/unix/sysv/linux/m68k/bits/procfs.h
index 4a9d4aa..401ac23 100644
--- a/sysdeps/unix/sysv/linux/m68k/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/m68k/bits/procfs.h
@@ -16,6 +16,9 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -26,9 +29,13 @@ typedef unsigned long elf_greg_t;
 /* And the whole bunch of them.  We could have used `struct
    user_regs_struct' directly in the typedef, but tradition says that
    the register set is an array, which does have some peculiar
-   semantics, so leave it that way.  */
+   semantics, so leave it that way.
+
+   struct user_regs_struct is defined by sys/user.h.  */
 #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof (elf_greg_t))
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 /* Register set for the floating-point registers.  */
 typedef struct user_m68kfp_struct elf_fpregset_t;
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/m68k/sys/user.h b/sysdeps/unix/sysv/linux/m68k/sys/user.h
index 210d88f..e8cdf8b 100644
--- a/sysdeps/unix/sysv/linux/m68k/sys/user.h
+++ b/sysdeps/unix/sysv/linux/m68k/sys/user.h
@@ -18,6 +18,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
 /* The whole purpose of this file is for GDB and GDB only.  Don't read
    too much into it.  Don't use it for anything other than GDB unless
    you know what you are doing.  */
diff --git a/sysdeps/unix/sysv/linux/microblaze/bits/procfs.h b/sysdeps/unix/sysv/linux/microblaze/bits/procfs.h
index 7da4b73..0f42527 100644
--- a/sysdeps/unix/sysv/linux/microblaze/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/microblaze/bits/procfs.h
@@ -17,6 +17,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -27,9 +30,13 @@ typedef unsigned long elf_greg_t;
 /* And the whole bunch of them.  We could have used `struct
    user_regs_struct' directly in the typedef, but tradition says that
    the register set is an array, which does have some peculiar
-   semantics, so leave it that way.  */
+   semantics, so leave it that way.
+
+   struct user_regs_struct is defined by sys/user.h.  */
 #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof (elf_greg_t))
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 /* Register set for the floating-point registers.  */
 typedef struct user_fpregs_struct elf_fpregset_t;
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/microblaze/sys/user.h b/sysdeps/unix/sysv/linux/microblaze/sys/user.h
index adf08ca..5060e5a 100644
--- a/sysdeps/unix/sysv/linux/microblaze/sys/user.h
+++ b/sysdeps/unix/sysv/linux/microblaze/sys/user.h
@@ -17,7 +17,9 @@
    <http://www.gnu.org/licenses/>.  */
 
 #ifndef _SYS_USER_H
-# define _SYS_USER_H	1
+#define _SYS_USER_H	1
+
+#include <features.h>
 
 /* The whole purpose of this file is for GDB and GDB only.  Don't read
    too much into it.  Don't use it for anything other than GDB unless
diff --git a/sysdeps/unix/sysv/linux/mips/bits/procfs.h b/sysdeps/unix/sysv/linux/mips/bits/procfs.h
index 7df96af..6543713 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/procfs.h
@@ -16,6 +16,9 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -35,3 +38,5 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 typedef double elf_fpreg_t;
 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/mips/sys/user.h b/sysdeps/unix/sysv/linux/mips/sys/user.h
index 29a6c36..32306a5 100644
--- a/sysdeps/unix/sysv/linux/mips/sys/user.h
+++ b/sysdeps/unix/sysv/linux/mips/sys/user.h
@@ -18,9 +18,13 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
-#include <sgidefs.h>
+#include <features.h>
+
+#define __need_size_t
 #include <stddef.h>
 
+#include <sgidefs.h>
+
 /* The whole purpose of this file is for GDB and GDB only.  Don't read
    too much into it.  Don't use it for anything other than GDB unless
    you know what you are doing.  */
diff --git a/sysdeps/unix/sysv/linux/nios2/bits/procfs.h b/sysdeps/unix/sysv/linux/nios2/bits/procfs.h
index a843122..0c401ed 100644
--- a/sysdeps/unix/sysv/linux/nios2/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/nios2/bits/procfs.h
@@ -16,6 +16,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -32,3 +35,5 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 /* Register set for the floating-point registers.  */
 typedef struct user_fpregs elf_fpregset_t;
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/nios2/sys/user.h b/sysdeps/unix/sysv/linux/nios2/sys/user.h
index 8670f77..4adb789 100644
--- a/sysdeps/unix/sysv/linux/nios2/sys/user.h
+++ b/sysdeps/unix/sysv/linux/nios2/sys/user.h
@@ -19,6 +19,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
 /* The whole purpose of this file is for GDB and GDB only.  Don't read
    too much into it.  Don't use it for anything other than GDB unless
    you know what you are doing.  */
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/procfs.h b/sysdeps/unix/sysv/linux/powerpc/bits/procfs.h
index cf67771..18c6870 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/procfs.h
@@ -16,17 +16,20 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
-#include <signal.h>
-#include <sys/ucontext.h>
+#include <bits/wordsize.h>
+#include <asm/elf.h>
+
+/* These definitions may have been provided by asm/elf.h.  Otherwise
+   we define them here.  */
+#ifndef ELF_NGREG
 
-/* These definitions are normally provided by ucontext.h via
-   asm/sigcontext.h, asm/ptrace.h, and asm/elf.h.  Otherwise we define
-   them here.  */
-#if !defined __PPC64_ELF_H && !defined _ASM_POWERPC_ELF_H
 #define ELF_NGREG       48      /* includes nip, msr, lr, etc. */
 #define ELF_NFPREG      33      /* includes fpscr */
 #if __WORDSIZE == 32
@@ -46,4 +49,7 @@ typedef struct {
   unsigned int u[4];
 } __attribute__ ((__aligned__ (16))) elf_vrreg_t;
 typedef elf_vrreg_t elf_vrregset_t[ELF_NVRREG];
-#endif
+
+#endif /* ifndef ELF_NGREG */
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/powerpc/sys/user.h b/sysdeps/unix/sysv/linux/powerpc/sys/user.h
index c6f36d7..f657d6d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sys/user.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sys/user.h
@@ -16,11 +16,13 @@
    <http://www.gnu.org/licenses/>.  */
 
 #ifndef _SYS_USER_H
-
 #define _SYS_USER_H	1
-#include <stddef.h>
+
 #include <features.h>
 
+#define __need_size_t
+#include <stddef.h>
+
 #include <asm/ptrace.h>
 
 struct user {
diff --git a/sysdeps/unix/sysv/linux/riscv/bits/procfs.h b/sysdeps/unix/sysv/linux/riscv/bits/procfs.h
index f2e4503..6ab2601 100644
--- a/sysdeps/unix/sysv/linux/riscv/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/riscv/bits/procfs.h
@@ -16,10 +16,16 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
+/* FIXME: sys/ucontext.h does not define NGREG or NFPREG unless
+   __USE_MISC is active, and sys/procfs.h should not expose all of
+   sys/ucontext.h.  */
 #include <sys/ucontext.h>
 
 /* ELF register definitions */
@@ -29,3 +35,5 @@
 typedef unsigned long int elf_greg_t;
 typedef unsigned long int elf_gregset_t[32];
 typedef union __riscv_mc_fp_state elf_fpregset_t;
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/s390/bits/procfs.h b/sysdeps/unix/sysv/linux/s390/bits/procfs.h
index 364051c..597ccdb 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/procfs.h
@@ -16,10 +16,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
+/* FIXME: sys/ucontext.h does not define NGREG unless __USE_MISC is
+   active, and sys/procfs.h should not expose all of sys/ucontext.h.  */
 #include <sys/ucontext.h>
 
 typedef greg_t elf_greg_t;
@@ -27,3 +32,5 @@ typedef greg_t elf_greg_t;
 typedef gregset_t elf_gregset_t;
 typedef fpreg_t   elf_fpreg_t;
 typedef fpregset_t elf_fpregset_t;
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/s390/sys/user.h b/sysdeps/unix/sysv/linux/s390/sys/user.h
index ab56f51..3fc03f3 100644
--- a/sysdeps/unix/sysv/linux/s390/sys/user.h
+++ b/sysdeps/unix/sysv/linux/s390/sys/user.h
@@ -18,6 +18,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
 /* The whole purpose of this file is for GDB and GDB only.  Don't read
    too much into it.  Don't use it for anything other than GDB unless
    you know what you are doing.  */
diff --git a/sysdeps/unix/sysv/linux/sh/bits/procfs.h b/sysdeps/unix/sysv/linux/sh/bits/procfs.h
index 5e33070..1825874 100644
--- a/sysdeps/unix/sysv/linux/sh/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/sh/bits/procfs.h
@@ -16,9 +16,14 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
 /* elf_gregset_t and elf_fpregset_t are defined by sys/user.h for
    SH.  */
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/sh/sys/user.h b/sysdeps/unix/sysv/linux/sh/sys/user.h
index 54d3d70..54e1dd3 100644
--- a/sysdeps/unix/sysv/linux/sh/sys/user.h
+++ b/sysdeps/unix/sysv/linux/sh/sys/user.h
@@ -18,9 +18,13 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
-#include <asm/ptrace.h>
+#include <features.h>
+
+#define __need_size_t
 #include <stddef.h>
 
+#include <asm/ptrace.h>
+
 /* asm/ptrace.h polutes the namespace.  */
 #undef PTRACE_GETREGS
 #undef PTRACE_SETREGS
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/procfs.h b/sysdeps/unix/sysv/linux/sparc/bits/procfs.h
index cc7ca46..9aa9c6d 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/procfs.h
@@ -16,12 +16,13 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
-#include <signal.h>
-#include <sys/ucontext.h>
 #include <bits/wordsize.h>
 
 #if __WORDSIZE == 64
@@ -59,3 +60,5 @@ typedef struct
 
 typedef unsigned long elf_greg_t;
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/sparc/sys/user.h b/sysdeps/unix/sysv/linux/sparc/sys/user.h
index c9c486a..d5ba07f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sys/user.h
+++ b/sysdeps/unix/sysv/linux/sparc/sys/user.h
@@ -18,6 +18,9 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
+#define __need_size_t
 #include <stddef.h>
 
 struct sunos_regs
diff --git a/sysdeps/unix/sysv/linux/sys/procfs.h b/sysdeps/unix/sysv/linux/sys/procfs.h
index d24c191..c9ef13f 100644
--- a/sysdeps/unix/sysv/linux/sys/procfs.h
+++ b/sysdeps/unix/sysv/linux/sys/procfs.h
@@ -30,8 +30,10 @@
    GDB unless you know what you are doing.  */
 
 #include <features.h>
-#include <sys/time.h>
-#include <sys/types.h>
+
+#include <bits/types.h>
+#include <bits/types/struct_timeval.h>
+
 #include <sys/user.h>
 
 /* bits/procfs.h, provided by each architecture, must define
diff --git a/sysdeps/unix/sysv/linux/x86/bits/procfs.h b/sysdeps/unix/sysv/linux/x86/bits/procfs.h
index 55ea4c9..6feb88c 100644
--- a/sysdeps/unix/sysv/linux/x86/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/x86/bits/procfs.h
@@ -16,6 +16,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -48,3 +51,5 @@ typedef struct user_fpxregs_struct elf_fpxregset_t;
    floating-point stuff.  */
 typedef struct user_fpregs_struct elf_fpregset_t;
 #endif
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/x86/sys/user.h b/sysdeps/unix/sysv/linux/x86/sys/user.h
index b462a00..9de2572 100644
--- a/sysdeps/unix/sysv/linux/x86/sys/user.h
+++ b/sysdeps/unix/sysv/linux/x86/sys/user.h
@@ -18,6 +18,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
 /* The whole purpose of this file is for GDB and GDB only.  Don't read
    too much into it.  Don't use it for anything other than GDB unless
    you know what you are doing.  */


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [glibc/zack/no-nested-includes] Don't include sys/types.h 8/n: Linux debugger headers
@ 2019-05-26 16:37 Zack Weinberg
  0 siblings, 0 replies; 2+ messages in thread
From: Zack Weinberg @ 2019-05-26 16:37 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: 32952 bytes --]

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0d7629caf2df59fffda2be01f5da95901642d1c0

commit 0d7629caf2df59fffda2be01f5da95901642d1c0
Author: Zack Weinberg <zackw@panix.com>
Date:   Sun May 26 12:30:46 2019 -0400

    Don't include sys/types.h 8/n: Linux debugger headers
    
    The debugger interface headers are a mess and I only have so much
    patience for them.  This does the bare minimum required for
    thread_db.h, sys/procfs.h, and sys/user.h, which are at least
    nominally cross-platform interfaces, to avoid including sys/types.h,
    sys/time.h, and/or signal.h.  Exposure of sys/ucontext.h is reduced
    but not eliminated.  Cross-architecture consistency should be improved.
    
    	* sysdeps/nptl/sys/procfs.h: Include features.h and bits/types.h,
    	not sys/types.h.
    	* sysdeps/nptl/thread_db.h: Don’t include sys/types.h.
    	* sysdeps/nptl/proc_service.h: Include stddef.h for size_t.
            Include bits/types/pid_t.h.
    
    	* sysdeps/unix/sysv/linux/sys/procfs.h: Include bits/types.h and
    	bits/types/struct_timeval.h, not sys/time.h or sys/types.h.
    
    	* sysdeps/unix/sysv/linux/aarch64/bits/procfs.h: Add multiple
    	inclusion guard.  Include bits/types.h.  Correct a comment.
    	* sysdeps/unix/sysv/linux/aarch64/sys/user.h: Include features.h.
    
    	* sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h:
    	Add multiple inclusion guard.  Include sys/ucontext.h.
    	* sysdeps/unix/sysv/linux/alpha/bits/procfs.h:
    	Add multiple inclusion guard.  Don’t include signal.h or
    	sys/ucontext.h.
    	* sysdeps/unix/sysv/linux/alpha/sys/user.h:
    	Include features.h.  Include stddef.h for size_t.  Move
    	inclusion of asm/reg.h above documentation comment.
    
    	* sysdeps/unix/sysv/linux/arm/bits/procfs.h: Add multiple
    	inclusion guard.  Improve commentary.
    	* sysdeps/unix/sysv/linux/arm/sys/user.h: Include features.h.
    
    	* sysdeps/unix/sysv/linux/csky/bits/procfs.h: Add multiple
    	inclusion guard.
    
    	* sysdeps/unix/sysv/linux/hppa/bits/procfs.h: Add multiple
    	inclusion guard.
    
    	* sysdeps/unix/sysv/linux/ia64/bits/procfs.h: Add multiple
    	inclusion guard.  Include sys/ucontext.h, not signal.h.
    	* sysdeps/unix/sysv/linux/ia64/sys/user.h:  Don’t include
    	sys/types.h.  Include stddef.h for size_t.
    
    	* sysdeps/unix/sysv/linux/m68k/bits/procfs.h: Add multiple
    	inclusion guard.  Improve commentary.
    	* sysdeps/unix/sysv/linux/m68k/sys/user.h: Include features.h.
    
    	* sysdeps/unix/sysv/linux/microblaze/bits/procfs.h: Add multiple
    	inclusion guard.  Improve commentary.
    	* sysdeps/unix/sysv/linux/microblaze/sys/user.h: Include features.h.
    
    	* sysdeps/unix/sysv/linux/mips/bits/procfs.h: Add multiple
    	inclusion guard.
    	* sysdeps/unix/sysv/linux/mips/sys/user.h: Include features.h.
    	Define __need_size_t before including stddef.h.  Move inclusion
    	of sgidefs.h below standard headers.
    
    	* sysdeps/unix/sysv/linux/nios2/bits/procfs.h: Add multiple
    	inclusion guard.
    	* sysdeps/unix/sysv/linux/nios2/sys/user.h: Include features.h.
    
    	* sysdeps/unix/sysv/linux/powerpc/bits/procfs.h: Add multiple
    	inclusion guard.  Don’t include signal.h or sys/ucontext.h.
    	Include bits/wordsize.h and asm/elf.h.  Adjust conditional for
    	whether to provide various fallback definitions.
    	* sysdeps/unix/sysv/linux/powerpc/sys/user.h:  Include features.h.
    	Define __need_size_t before including stddef.h.
    
    	* sysdeps/unix/sysv/linux/riscv/bits/procfs.h: Add multiple
    	inclusion guard.  Add comment noting potential problems with
    	use of sys/ucontext.h.
    
    	* sysdeps/unix/sysv/linux/s390/bits/procfs.h: Add multiple
    	inclusion guard.  Add comment noting potential problems with
    	use of sys/ucontext.h.
    	* sysdeps/unix/sysv/linux/s390/sys/user.h: Include features.h.
    
    	* sysdeps/unix/sysv/linux/sh/bits/procfs.h: Add multiple
    	inclusion guard.
    	* sysdeps/unix/sysv/linux/sh/sys/user.h: Include features.h.
    	Define __need_size_t before including stddef.h.  Include
    	asm/ptrace after above two headers.
    
    	* sysdeps/unix/sysv/linux/sparc/bits/procfs.h: Add multiple
    	inclusion guard.  Don’t include signal.h or sys/ucontext.h.
    	* sysdeps/unix/sysv/linux/sparc/sys/user.h:  Include features.h.
    	Define __need_size_t before including stddef.h.
    
    	* sysdeps/unix/sysv/linux/x86/bits/procfs.h: Add multiple
    	inclusion guard.
    	* sysdeps/unix/sysv/linux/x86/sys/user.h: Include features.h.
    
    	* scripts/check-obsolete-constructs.py
    	(HEADER_ALLOWED_INCLUDES, SYSDEP_ALLOWED_INCLUDES): Update.

Diff:
---
 scripts/check-obsolete-constructs.py                 | 10 ++++------
 sysdeps/nptl/proc_service.h                          |  5 +++++
 sysdeps/nptl/sys/procfs.h                            |  3 ++-
 sysdeps/nptl/thread_db.h                             |  1 -
 sysdeps/unix/sysv/linux/aarch64/bits/procfs.h        | 13 +++++++++++--
 sysdeps/unix/sysv/linux/aarch64/sys/user.h           |  2 ++
 sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h |  9 +++++++++
 sysdeps/unix/sysv/linux/alpha/bits/procfs.h          |  8 +++++---
 sysdeps/unix/sysv/linux/alpha/sys/user.h             | 10 +++++++---
 sysdeps/unix/sysv/linux/arm/bits/procfs.h            |  9 ++++++++-
 sysdeps/unix/sysv/linux/arm/sys/user.h               |  2 ++
 sysdeps/unix/sysv/linux/csky/bits/procfs.h           |  5 +++++
 sysdeps/unix/sysv/linux/hppa/bits/procfs.h           |  5 +++++
 sysdeps/unix/sysv/linux/ia64/bits/procfs.h           |  8 +++++++-
 sysdeps/unix/sysv/linux/ia64/sys/user.h              |  4 +++-
 sysdeps/unix/sysv/linux/m68k/bits/procfs.h           |  9 ++++++++-
 sysdeps/unix/sysv/linux/m68k/sys/user.h              |  2 ++
 sysdeps/unix/sysv/linux/microblaze/bits/procfs.h     |  9 ++++++++-
 sysdeps/unix/sysv/linux/microblaze/sys/user.h        |  4 +++-
 sysdeps/unix/sysv/linux/mips/bits/procfs.h           |  5 +++++
 sysdeps/unix/sysv/linux/mips/sys/user.h              |  6 +++++-
 sysdeps/unix/sysv/linux/nios2/bits/procfs.h          |  5 +++++
 sysdeps/unix/sysv/linux/nios2/sys/user.h             |  2 ++
 sysdeps/unix/sysv/linux/powerpc/bits/procfs.h        | 20 +++++++++++++-------
 sysdeps/unix/sysv/linux/powerpc/sys/user.h           |  6 ++++--
 sysdeps/unix/sysv/linux/riscv/bits/procfs.h          |  8 ++++++++
 sysdeps/unix/sysv/linux/s390/bits/procfs.h           |  7 +++++++
 sysdeps/unix/sysv/linux/s390/sys/user.h              |  2 ++
 sysdeps/unix/sysv/linux/sh/bits/procfs.h             |  5 +++++
 sysdeps/unix/sysv/linux/sh/sys/user.h                |  6 +++++-
 sysdeps/unix/sysv/linux/sparc/bits/procfs.h          |  7 +++++--
 sysdeps/unix/sysv/linux/sparc/sys/user.h             |  3 +++
 sysdeps/unix/sysv/linux/sys/procfs.h                 |  6 ++++--
 sysdeps/unix/sysv/linux/x86/bits/procfs.h            |  5 +++++
 sysdeps/unix/sysv/linux/x86/sys/user.h               |  2 ++
 35 files changed, 176 insertions(+), 37 deletions(-)

diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index e2b6b5f..6907c26 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -581,8 +581,7 @@ HEADER_ALLOWED_INCLUDES = {
     "stdio_ext.h":                 [ "stdio.h" ],
     "syscall.h":                   [ "sys/syscall.h" ],
     "termio.h":                    [ "sys/ioctl.h", "termios.h" ],
-    "thread_db.h":                 [ "pthread.h", "stdint.h", "sys/procfs.h",
-                                     "sys/types.h" ],
+    "thread_db.h":                 [ "pthread.h", "stdint.h", "sys/procfs.h" ],
     "ucontext.h":                  [ "sys/ucontext.h" ],
     "utmp.h":                      [ "paths.h" ],
     "values.h":                    [ "float.h", "limits.h" ],
@@ -605,8 +604,7 @@ HEADER_ALLOWED_INCLUDES = {
     "sys/param.h":                 [ "endian.h", "limits.h", "signal.h",
                                      "sys/types.h" ],
     "sys/platform/ppc.h":          [ "stdint.h" ],
-    "sys/procfs.h":                [ "sys/time.h", "sys/types.h",
-                                     "sys/user.h" ],
+    "sys/procfs.h":                [ "sys/ucontext.h", "sys/user.h" ],
     "sys/ptrace.h":                [ "sys/ucontext.h" ],
     "sys/raw.h":                   [ "stdint.h", "sys/ioctl.h" ],
     "sys/signal.h":                [ "signal.h" ],
@@ -618,7 +616,6 @@ HEADER_ALLOWED_INCLUDES = {
     "sys/ttychars.h":              [ "sys/ttydefaults.h" ],
     "sys/ucontext.h":              [ "sys/procfs.h" ],
     "sys/unistd.h":                [ "unistd.h" ],
-    "sys/user.h":                  [ "sys/types.h" ],
     "sys/vfs.h":                   [ "sys/statfs.h" ],
     "sys/xattr.h":                 [ "sys/types.h" ],
 
@@ -719,7 +716,8 @@ SYSDEP_ALLOWED_INCLUDES = {
         "bits/ioctls.h":           [ "asm/ioctls.h", "linux/sockios.h" ],
         "bits/local_lim.h":        [ "linux/limits.h" ],
         "bits/param.h":            [ "linux/limits.h", "linux/param.h" ],
-        "bits/procfs.h":           [ "asm/ptrace.h" ],
+        "bits/procfs.h":           [ "asm/elf.h", "asm/ptrace.h" ],
+        "bits/procfs-prregset.h":  [ "sys/ucontext.h" ],
         "bits/sigcontext.h":       [ "asm/sigcontext.h" ],
         "bits/socket.h":           [ "asm/socket.h" ],
     },
diff --git a/sysdeps/nptl/proc_service.h b/sysdeps/nptl/proc_service.h
index 4aa52c6..524e71f 100644
--- a/sysdeps/nptl/proc_service.h
+++ b/sysdeps/nptl/proc_service.h
@@ -22,6 +22,11 @@
 /* The definitions in this file must correspond to those in the debugger.  */
 #include <sys/procfs.h>
 
+#define __need_size_t
+#include <stddef.h>
+
+#include <bits/types/pid_t.h>
+
 __BEGIN_DECLS
 
 /* Functions in this interface return one of these status codes.  */
diff --git a/sysdeps/nptl/sys/procfs.h b/sysdeps/nptl/sys/procfs.h
index 6ade66d..0f88674 100644
--- a/sysdeps/nptl/sys/procfs.h
+++ b/sysdeps/nptl/sys/procfs.h
@@ -19,7 +19,8 @@
 #ifndef _SYS_PROCFS_H
 #define _SYS_PROCFS_H	1
 
-#include <sys/types.h>
+#include <features.h>
+#include <bits/types.h>
 
 /* The rest of this file provides the types for emulation of the
    Solaris <proc_service.h> interfaces that should be implemented by
diff --git a/sysdeps/nptl/thread_db.h b/sysdeps/nptl/thread_db.h
index 4d949b0..3d6cb3a 100644
--- a/sysdeps/nptl/thread_db.h
+++ b/sysdeps/nptl/thread_db.h
@@ -24,7 +24,6 @@
    with the goal to share the same code in the debugger.  */
 #include <pthread.h>
 #include <stdint.h>
-#include <sys/types.h>
 #include <sys/procfs.h>
 #include <bits/types/sigset_t.h>
 
diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/procfs.h b/sysdeps/unix/sysv/linux/aarch64/bits/procfs.h
index ea91de0..fec2f6a 100644
--- a/sysdeps/unix/sysv/linux/aarch64/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/aarch64/bits/procfs.h
@@ -17,19 +17,28 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
+#include <bits/types.h>
+
 /* Type for a general-purpose register.  */
 typedef __uint64_t elf_greg_t;
 
 /* And the whole bunch of them.  We could have used `struct
-   pt_regs' directly in the typedef, but tradition says that
+   user_regs_struct' directly in the typedef, but tradition says that
    the register set is an array, which does have some peculiar
-   semantics, so leave it that way.  */
+   semantics, so leave it that way.
+
+   struct user_regs_struct is defined in sys/user.h.  */
 #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof (elf_greg_t))
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 /* Register set for the floating-point registers.  */
 typedef struct user_fpsimd_struct elf_fpregset_t;
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/aarch64/sys/user.h b/sysdeps/unix/sysv/linux/aarch64/sys/user.h
index 7f6d8be..949484a 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sys/user.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sys/user.h
@@ -19,6 +19,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
 struct user_regs_struct
 {
   unsigned long long regs[31];
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h b/sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h
index a5fffc0..58b015f 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h
@@ -17,9 +17,18 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_PRREGSET_H
+#define _BITS_PROCFS_PRREGSET_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs-prregset.h> directly; use <sys/procfs.h> instead."
 #endif
 
+/* For gregset_t and fpregset_t.  FIXME: sys/procfs.h should not
+   expose all of sys/ucontext.h.  */
+#include <sys/ucontext.h>
+
 typedef gregset_t __prgregset_t;
 typedef fpregset_t __prfpregset_t;
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/alpha/bits/procfs.h b/sysdeps/unix/sysv/linux/alpha/bits/procfs.h
index d0fd280..f04a453 100644
--- a/sysdeps/unix/sysv/linux/alpha/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/alpha/bits/procfs.h
@@ -16,13 +16,13 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
-#include <signal.h>
-#include <sys/ucontext.h>
-
 /*
  * The OSF/1 version of <sys/procfs.h> makes gregset_t 46 entries long.
  * I have no idea why that is so.  For now, we just leave it at 33
@@ -36,3 +36,5 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 typedef double elf_fpreg_t;
 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/alpha/sys/user.h b/sysdeps/unix/sysv/linux/alpha/sys/user.h
index 38fcb51..9e36cf4 100644
--- a/sysdeps/unix/sysv/linux/alpha/sys/user.h
+++ b/sysdeps/unix/sysv/linux/alpha/sys/user.h
@@ -18,13 +18,17 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
+#define __need_size_t
+#include <stddef.h>
+
+#include <asm/reg.h>
+
 /* The whole purpose of this file is for gdb/strace and gdb/strace
    only. Don't read too much into it. Don't use it for anything other
    than gdb/strace unless you know what you are doing. */
 
-#include <asm/reg.h>
-#include <stddef.h>
-
 struct user
 {
   unsigned long	int regs[EF_SIZE / 8 + 32];	/* integer and fp regs */
diff --git a/sysdeps/unix/sysv/linux/arm/bits/procfs.h b/sysdeps/unix/sysv/linux/arm/bits/procfs.h
index f168b3a..333fff6 100644
--- a/sysdeps/unix/sysv/linux/arm/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/arm/bits/procfs.h
@@ -16,6 +16,9 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -26,9 +29,13 @@ typedef unsigned long elf_greg_t;
 /* And the whole bunch of them.  We could have used `struct
    user_regs' directly in the typedef, but tradition says that
    the register set is an array, which does have some peculiar
-   semantics, so leave it that way.  */
+   semantics, so leave it that way.
+
+   struct user_regs is defined in sys/user.h.  */
 #define ELF_NGREG (sizeof (struct user_regs) / sizeof (elf_greg_t))
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 /* Register set for the floating-point registers.  */
 typedef struct user_fpregs elf_fpregset_t;
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/arm/sys/user.h b/sysdeps/unix/sysv/linux/arm/sys/user.h
index aae8a99..55db6ca 100644
--- a/sysdeps/unix/sysv/linux/arm/sys/user.h
+++ b/sysdeps/unix/sysv/linux/arm/sys/user.h
@@ -18,6 +18,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
 /* The whole purpose of this file is for GDB and GDB only.  Don't read
    too much into it.  Don't use it for anything other than GDB unless
    you know what you are doing.  */
diff --git a/sysdeps/unix/sysv/linux/csky/bits/procfs.h b/sysdeps/unix/sysv/linux/csky/bits/procfs.h
index 4ec0c5e..97982b6 100644
--- a/sysdeps/unix/sysv/linux/csky/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/csky/bits/procfs.h
@@ -16,6 +16,9 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -35,3 +38,5 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 #define ELF_NFPREG (sizeof (struct user_fp) / sizeof (elf_fpreg_t))
 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/hppa/bits/procfs.h b/sysdeps/unix/sysv/linux/hppa/bits/procfs.h
index 9d57472..5bbdb2b 100644
--- a/sysdeps/unix/sysv/linux/hppa/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/hppa/bits/procfs.h
@@ -16,6 +16,9 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -28,3 +31,5 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 #define ELF_NFPREG 32
 typedef double elf_fpreg_t;
 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/ia64/bits/procfs.h b/sysdeps/unix/sysv/linux/ia64/bits/procfs.h
index 8918975..754e969 100644
--- a/sysdeps/unix/sysv/linux/ia64/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/ia64/bits/procfs.h
@@ -16,11 +16,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
-#include <signal.h>
+/* For struct __ia64_fpreg.  FIXME: sys/procfs.h should not expose all
+   of sys/ucontext.h.  */
 #include <sys/ucontext.h>
 #include <bits/sigcontext.h>
 
@@ -39,3 +43,5 @@ typedef elf_greg_t greg_t;
 typedef elf_gregset_t gregset_t;
 typedef elf_fpregset_t fpregset_t;
 #define NGREG ELF_NGREG
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/ia64/sys/user.h b/sysdeps/unix/sysv/linux/ia64/sys/user.h
index f409e23..87b27c3 100644
--- a/sysdeps/unix/sysv/linux/ia64/sys/user.h
+++ b/sysdeps/unix/sysv/linux/ia64/sys/user.h
@@ -19,7 +19,9 @@
 #define _SYS_USER_H	1
 
 #include <features.h>
-#include <sys/types.h>
+
+#define __need_size_t
+#include <stddef.h>
 
 /* This definition comes directly from the kernel headers.  If
    anything changes in them this header has to be changed, too.  */
diff --git a/sysdeps/unix/sysv/linux/m68k/bits/procfs.h b/sysdeps/unix/sysv/linux/m68k/bits/procfs.h
index 4a9d4aa..401ac23 100644
--- a/sysdeps/unix/sysv/linux/m68k/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/m68k/bits/procfs.h
@@ -16,6 +16,9 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -26,9 +29,13 @@ typedef unsigned long elf_greg_t;
 /* And the whole bunch of them.  We could have used `struct
    user_regs_struct' directly in the typedef, but tradition says that
    the register set is an array, which does have some peculiar
-   semantics, so leave it that way.  */
+   semantics, so leave it that way.
+
+   struct user_regs_struct is defined by sys/user.h.  */
 #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof (elf_greg_t))
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 /* Register set for the floating-point registers.  */
 typedef struct user_m68kfp_struct elf_fpregset_t;
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/m68k/sys/user.h b/sysdeps/unix/sysv/linux/m68k/sys/user.h
index 210d88f..e8cdf8b 100644
--- a/sysdeps/unix/sysv/linux/m68k/sys/user.h
+++ b/sysdeps/unix/sysv/linux/m68k/sys/user.h
@@ -18,6 +18,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
 /* The whole purpose of this file is for GDB and GDB only.  Don't read
    too much into it.  Don't use it for anything other than GDB unless
    you know what you are doing.  */
diff --git a/sysdeps/unix/sysv/linux/microblaze/bits/procfs.h b/sysdeps/unix/sysv/linux/microblaze/bits/procfs.h
index 7da4b73..0f42527 100644
--- a/sysdeps/unix/sysv/linux/microblaze/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/microblaze/bits/procfs.h
@@ -17,6 +17,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -27,9 +30,13 @@ typedef unsigned long elf_greg_t;
 /* And the whole bunch of them.  We could have used `struct
    user_regs_struct' directly in the typedef, but tradition says that
    the register set is an array, which does have some peculiar
-   semantics, so leave it that way.  */
+   semantics, so leave it that way.
+
+   struct user_regs_struct is defined by sys/user.h.  */
 #define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof (elf_greg_t))
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 /* Register set for the floating-point registers.  */
 typedef struct user_fpregs_struct elf_fpregset_t;
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/microblaze/sys/user.h b/sysdeps/unix/sysv/linux/microblaze/sys/user.h
index adf08ca..5060e5a 100644
--- a/sysdeps/unix/sysv/linux/microblaze/sys/user.h
+++ b/sysdeps/unix/sysv/linux/microblaze/sys/user.h
@@ -17,7 +17,9 @@
    <http://www.gnu.org/licenses/>.  */
 
 #ifndef _SYS_USER_H
-# define _SYS_USER_H	1
+#define _SYS_USER_H	1
+
+#include <features.h>
 
 /* The whole purpose of this file is for GDB and GDB only.  Don't read
    too much into it.  Don't use it for anything other than GDB unless
diff --git a/sysdeps/unix/sysv/linux/mips/bits/procfs.h b/sysdeps/unix/sysv/linux/mips/bits/procfs.h
index 7df96af..6543713 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/procfs.h
@@ -16,6 +16,9 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -35,3 +38,5 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 typedef double elf_fpreg_t;
 typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/mips/sys/user.h b/sysdeps/unix/sysv/linux/mips/sys/user.h
index 29a6c36..32306a5 100644
--- a/sysdeps/unix/sysv/linux/mips/sys/user.h
+++ b/sysdeps/unix/sysv/linux/mips/sys/user.h
@@ -18,9 +18,13 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
-#include <sgidefs.h>
+#include <features.h>
+
+#define __need_size_t
 #include <stddef.h>
 
+#include <sgidefs.h>
+
 /* The whole purpose of this file is for GDB and GDB only.  Don't read
    too much into it.  Don't use it for anything other than GDB unless
    you know what you are doing.  */
diff --git a/sysdeps/unix/sysv/linux/nios2/bits/procfs.h b/sysdeps/unix/sysv/linux/nios2/bits/procfs.h
index a843122..0c401ed 100644
--- a/sysdeps/unix/sysv/linux/nios2/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/nios2/bits/procfs.h
@@ -16,6 +16,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -32,3 +35,5 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
 
 /* Register set for the floating-point registers.  */
 typedef struct user_fpregs elf_fpregset_t;
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/nios2/sys/user.h b/sysdeps/unix/sysv/linux/nios2/sys/user.h
index 8670f77..4adb789 100644
--- a/sysdeps/unix/sysv/linux/nios2/sys/user.h
+++ b/sysdeps/unix/sysv/linux/nios2/sys/user.h
@@ -19,6 +19,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
 /* The whole purpose of this file is for GDB and GDB only.  Don't read
    too much into it.  Don't use it for anything other than GDB unless
    you know what you are doing.  */
diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/procfs.h b/sysdeps/unix/sysv/linux/powerpc/bits/procfs.h
index cf67771..18c6870 100644
--- a/sysdeps/unix/sysv/linux/powerpc/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/powerpc/bits/procfs.h
@@ -16,17 +16,20 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
-#include <signal.h>
-#include <sys/ucontext.h>
+#include <bits/wordsize.h>
+#include <asm/elf.h>
+
+/* These definitions may have been provided by asm/elf.h.  Otherwise
+   we define them here.  */
+#ifndef ELF_NGREG
 
-/* These definitions are normally provided by ucontext.h via
-   asm/sigcontext.h, asm/ptrace.h, and asm/elf.h.  Otherwise we define
-   them here.  */
-#if !defined __PPC64_ELF_H && !defined _ASM_POWERPC_ELF_H
 #define ELF_NGREG       48      /* includes nip, msr, lr, etc. */
 #define ELF_NFPREG      33      /* includes fpscr */
 #if __WORDSIZE == 32
@@ -46,4 +49,7 @@ typedef struct {
   unsigned int u[4];
 } __attribute__ ((__aligned__ (16))) elf_vrreg_t;
 typedef elf_vrreg_t elf_vrregset_t[ELF_NVRREG];
-#endif
+
+#endif /* ifndef ELF_NGREG */
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/powerpc/sys/user.h b/sysdeps/unix/sysv/linux/powerpc/sys/user.h
index c6f36d7..f657d6d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sys/user.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sys/user.h
@@ -16,11 +16,13 @@
    <http://www.gnu.org/licenses/>.  */
 
 #ifndef _SYS_USER_H
-
 #define _SYS_USER_H	1
-#include <stddef.h>
+
 #include <features.h>
 
+#define __need_size_t
+#include <stddef.h>
+
 #include <asm/ptrace.h>
 
 struct user {
diff --git a/sysdeps/unix/sysv/linux/riscv/bits/procfs.h b/sysdeps/unix/sysv/linux/riscv/bits/procfs.h
index f2e4503..6ab2601 100644
--- a/sysdeps/unix/sysv/linux/riscv/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/riscv/bits/procfs.h
@@ -16,10 +16,16 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
+/* FIXME: sys/ucontext.h does not define NGREG or NFPREG unless
+   __USE_MISC is active, and sys/procfs.h should not expose all of
+   sys/ucontext.h.  */
 #include <sys/ucontext.h>
 
 /* ELF register definitions */
@@ -29,3 +35,5 @@
 typedef unsigned long int elf_greg_t;
 typedef unsigned long int elf_gregset_t[32];
 typedef union __riscv_mc_fp_state elf_fpregset_t;
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/s390/bits/procfs.h b/sysdeps/unix/sysv/linux/s390/bits/procfs.h
index 364051c..597ccdb 100644
--- a/sysdeps/unix/sysv/linux/s390/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/s390/bits/procfs.h
@@ -16,10 +16,15 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
+/* FIXME: sys/ucontext.h does not define NGREG unless __USE_MISC is
+   active, and sys/procfs.h should not expose all of sys/ucontext.h.  */
 #include <sys/ucontext.h>
 
 typedef greg_t elf_greg_t;
@@ -27,3 +32,5 @@ typedef greg_t elf_greg_t;
 typedef gregset_t elf_gregset_t;
 typedef fpreg_t   elf_fpreg_t;
 typedef fpregset_t elf_fpregset_t;
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/s390/sys/user.h b/sysdeps/unix/sysv/linux/s390/sys/user.h
index ab56f51..3fc03f3 100644
--- a/sysdeps/unix/sysv/linux/s390/sys/user.h
+++ b/sysdeps/unix/sysv/linux/s390/sys/user.h
@@ -18,6 +18,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
 /* The whole purpose of this file is for GDB and GDB only.  Don't read
    too much into it.  Don't use it for anything other than GDB unless
    you know what you are doing.  */
diff --git a/sysdeps/unix/sysv/linux/sh/bits/procfs.h b/sysdeps/unix/sysv/linux/sh/bits/procfs.h
index 5e33070..1825874 100644
--- a/sysdeps/unix/sysv/linux/sh/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/sh/bits/procfs.h
@@ -16,9 +16,14 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
 /* elf_gregset_t and elf_fpregset_t are defined by sys/user.h for
    SH.  */
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/sh/sys/user.h b/sysdeps/unix/sysv/linux/sh/sys/user.h
index 54d3d70..54e1dd3 100644
--- a/sysdeps/unix/sysv/linux/sh/sys/user.h
+++ b/sysdeps/unix/sysv/linux/sh/sys/user.h
@@ -18,9 +18,13 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
-#include <asm/ptrace.h>
+#include <features.h>
+
+#define __need_size_t
 #include <stddef.h>
 
+#include <asm/ptrace.h>
+
 /* asm/ptrace.h polutes the namespace.  */
 #undef PTRACE_GETREGS
 #undef PTRACE_SETREGS
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/procfs.h b/sysdeps/unix/sysv/linux/sparc/bits/procfs.h
index cc7ca46..9aa9c6d 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/procfs.h
@@ -16,12 +16,13 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
 
-#include <signal.h>
-#include <sys/ucontext.h>
 #include <bits/wordsize.h>
 
 #if __WORDSIZE == 64
@@ -59,3 +60,5 @@ typedef struct
 
 typedef unsigned long elf_greg_t;
 typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/sparc/sys/user.h b/sysdeps/unix/sysv/linux/sparc/sys/user.h
index c9c486a..d5ba07f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sys/user.h
+++ b/sysdeps/unix/sysv/linux/sparc/sys/user.h
@@ -18,6 +18,9 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
+#define __need_size_t
 #include <stddef.h>
 
 struct sunos_regs
diff --git a/sysdeps/unix/sysv/linux/sys/procfs.h b/sysdeps/unix/sysv/linux/sys/procfs.h
index d24c191..c9ef13f 100644
--- a/sysdeps/unix/sysv/linux/sys/procfs.h
+++ b/sysdeps/unix/sysv/linux/sys/procfs.h
@@ -30,8 +30,10 @@
    GDB unless you know what you are doing.  */
 
 #include <features.h>
-#include <sys/time.h>
-#include <sys/types.h>
+
+#include <bits/types.h>
+#include <bits/types/struct_timeval.h>
+
 #include <sys/user.h>
 
 /* bits/procfs.h, provided by each architecture, must define
diff --git a/sysdeps/unix/sysv/linux/x86/bits/procfs.h b/sysdeps/unix/sysv/linux/x86/bits/procfs.h
index 55ea4c9..6feb88c 100644
--- a/sysdeps/unix/sysv/linux/x86/bits/procfs.h
+++ b/sysdeps/unix/sysv/linux/x86/bits/procfs.h
@@ -16,6 +16,9 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef _BITS_PROCFS_H
+#define _BITS_PROCFS_H 1
+
 #ifndef _SYS_PROCFS_H
 # error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
 #endif
@@ -48,3 +51,5 @@ typedef struct user_fpxregs_struct elf_fpxregset_t;
    floating-point stuff.  */
 typedef struct user_fpregs_struct elf_fpregset_t;
 #endif
+
+#endif /* bits/procfs.h */
diff --git a/sysdeps/unix/sysv/linux/x86/sys/user.h b/sysdeps/unix/sysv/linux/x86/sys/user.h
index b462a00..9de2572 100644
--- a/sysdeps/unix/sysv/linux/x86/sys/user.h
+++ b/sysdeps/unix/sysv/linux/x86/sys/user.h
@@ -18,6 +18,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H	1
 
+#include <features.h>
+
 /* The whole purpose of this file is for GDB and GDB only.  Don't read
    too much into it.  Don't use it for anything other than GDB unless
    you know what you are doing.  */


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-18 15:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-18 15:35 [glibc/zack/no-nested-includes] Don't include sys/types.h 8/n: Linux debugger headers Zack Weinberg
  -- strict thread matches above, loose matches on Subject: below --
2019-05-26 16:37 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).