This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[glibc/zack/no-nested-includes] Don't include sys/types.h 5/n: misc nonstandard headers


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

commit eaf9d41cbf79ae4299caa25e6d72a523c6908ac8
Author: Zack Weinberg <zackw@panix.com>
Date:   Sun May 26 11:49:25 2019 -0400

    Don't include sys/types.h 5/n: misc nonstandard headers
    
    Many nonstandard headers can also easily avoid including sys/types.h.
    
    	* elf/link.h, inet/aliases.h, misc/sys/xattr.h:
    	Don't include sys/types.h.  Include stddef.h for size_t.
    
    	* gmon/sys/gmon.h: Don't include sys/types.h.
    	* gmon/sys/profil.h: Don't include sys/types.h.
    	Include stddef.h for size_t.  Include bits/types/struct_timeval.h.
    	* io/fts.h: Don't include sys/types.h.
    	Include bits/types/dev_t.h, bits/types/ino_t.h, bits/types/ino64_t.h,
    	and bits/types/nlink_t.h.
    	* io/sys/sendfile.h: Don't include sys/types.h.
    	Include stddef.h for size_t.
    	Include bits/types.h, bits/types/off_t.h, and bits/types/ssize_t.h.
    	* stdlib/sys/random.h: Don't include sys/types.h.
    	Include stddef.h for size_t.
    	Include bits/types/ssize_t.h.
    
    	* gmon/tst-sprofil.h: Include sys/time.h.
    	* sysdeps/mach/hurd/sendfile.c: Include sys/types.h.
    	* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES): Update.

Diff:
---
 elf/link.h                           | 5 ++++-
 gmon/sys/gmon.h                      | 2 --
 gmon/sys/profil.h                    | 6 ++++--
 gmon/tst-sprofil.c                   | 1 +
 inet/aliases.h                       | 4 ++--
 io/fts.h                             | 5 ++++-
 io/sys/sendfile.h                    | 8 +++++++-
 misc/sys/xattr.h                     | 5 ++++-
 scripts/check-obsolete-constructs.py | 8 +-------
 stdlib/sys/random.h                  | 5 ++++-
 sysdeps/mach/hurd/sendfile.c         | 1 +
 11 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/elf/link.h b/elf/link.h
index 7a463bc..e3143a8 100644
--- a/elf/link.h
+++ b/elf/link.h
@@ -21,9 +21,12 @@
 #define	_LINK_H	1
 
 #include <features.h>
+
+#define __need_size_t
+#include <stddef.h>
+
 #include <elf.h>
 #include <dlfcn.h>
-#include <sys/types.h>
 
 /* We use this macro to refer to ELF types independent of the native wordsize.
    `ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'.  */
diff --git a/gmon/sys/gmon.h b/gmon/sys/gmon.h
index b4cc3b0..5d7de0f 100644
--- a/gmon/sys/gmon.h
+++ b/gmon/sys/gmon.h
@@ -34,8 +34,6 @@
 
 #include <features.h>
 
-#include <sys/types.h>
-
 /*
  * See gmon_out.h for gmon.out format.
  */
diff --git a/gmon/sys/profil.h b/gmon/sys/profil.h
index ba99ac8..e38f153 100644
--- a/gmon/sys/profil.h
+++ b/gmon/sys/profil.h
@@ -20,8 +20,10 @@
 
 #include <features.h>
 
-#include <sys/time.h>
-#include <sys/types.h>
+#define __need_size_t
+#include <stddef.h>
+
+#include <bits/types/struct_timeval.h>
 
 /* This interface is intended to follow the sprofil() system calls as
    described by the sprofil(2) man page of Irix v6.5, except that:
diff --git a/gmon/tst-sprofil.c b/gmon/tst-sprofil.c
index 3f7f909..53de7a6 100644
--- a/gmon/tst-sprofil.c
+++ b/gmon/tst-sprofil.c
@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/profil.h>
+#include <sys/time.h>
 
 #include <bits/wordsize.h>
 
diff --git a/inet/aliases.h b/inet/aliases.h
index 67828ca..66230b6 100644
--- a/inet/aliases.h
+++ b/inet/aliases.h
@@ -20,8 +20,8 @@
 
 #include <features.h>
 
-#include <sys/types.h>
-
+#define __need_size_t
+#include <stddef.h>
 
 __BEGIN_DECLS
 
diff --git a/io/fts.h b/io/fts.h
index acfa260..0e43b35 100644
--- a/io/fts.h
+++ b/io/fts.h
@@ -51,8 +51,11 @@
 #define	_FTS_H 1
 
 #include <features.h>
-#include <sys/types.h>
 
+#include <bits/types/dev_t.h>
+#include <bits/types/ino_t.h>
+#include <bits/types/ino64_t.h>
+#include <bits/types/nlink_t.h>
 
 typedef struct {
 	struct _ftsent *fts_cur;	/* current node */
diff --git a/io/sys/sendfile.h b/io/sys/sendfile.h
index b21c085..5ed26d3 100644
--- a/io/sys/sendfile.h
+++ b/io/sys/sendfile.h
@@ -20,7 +20,13 @@
 #define _SYS_SENDFILE_H	1
 
 #include <features.h>
-#include <sys/types.h>
+
+#include <bits/types.h>
+#include <bits/types/off_t.h>
+#include <bits/types/ssize_t.h>
+
+#define __need_size_t
+#include <stddef.h>
 
 __BEGIN_DECLS
 
diff --git a/misc/sys/xattr.h b/misc/sys/xattr.h
index f1143f8..9531333 100644
--- a/misc/sys/xattr.h
+++ b/misc/sys/xattr.h
@@ -19,8 +19,11 @@
 #define _SYS_XATTR_H	1
 
 #include <features.h>
-#include <sys/types.h>
 
+#define __need_size_t
+#include <stddef.h>
+
+#include <bits/types/ssize_t.h>
 
 __BEGIN_DECLS
 
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 4bc4909..4472c80 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -556,19 +556,17 @@ HEADER_ALLOWED_INCLUDES = {
     "netinet/tcp.h":               [ "sys/socket.h" ],
 
     # Nonstandardized top-level headers
-    "aliases.h":                   [ "sys/types.h" ],
     "argp.h":                      [ "ctype.h", "errno.h", "getopt.h",
                                      "limits.h", "stdio.h" ],
     "argz.h":                      [ "errno.h", "string.h" ],
     "elf.h":                       [ "stdint.h" ],
     "envz.h":                      [ "argz.h", "errno.h" ],
     "fpregdef.h":                  [ "sys/fpregdef.h" ],
-    "fts.h":                       [ "sys/types.h" ],
     "gshadow.h":                   [ "paths.h" ],
     "ieee754.h":                   [ "float.h" ],
     "lastlog.h":                   [ "utmp.h" ],
     "libintl.h":                   [ "locale.h" ],
-    "link.h":                      [ "dlfcn.h", "elf.h", "sys/types.h" ],
+    "link.h":                      [ "dlfcn.h", "elf.h" ],
     "malloc.h":                    [ "stdio.h" ],
     "memory.h":                    [ "string.h" ],
     "mntent.h":                    [ "paths.h" ],
@@ -603,7 +601,6 @@ HEADER_ALLOWED_INCLUDES = {
     "sys/fcntl.h":                 [ "fcntl.h" ],
     "sys/file.h":                  [ "fcntl.h" ],
     "sys/fsuid.h":                 [ "sys/types.h" ],
-    "sys/gmon.h":                  [ "sys/types.h" ],
     "sys/inotify.h":               [ "stdint.h" ],
     "sys/ioctl.h":                 [ "sys/ttydefaults.h" ],
     "sys/mount.h":                 [ "sys/ioctl.h" ],
@@ -613,12 +610,9 @@ HEADER_ALLOWED_INCLUDES = {
     "sys/platform/ppc.h":          [ "stdint.h" ],
     "sys/procfs.h":                [ "sys/time.h", "sys/types.h",
                                      "sys/user.h" ],
-    "sys/profil.h":                [ "sys/time.h", "sys/types.h" ],
     "sys/ptrace.h":                [ "sys/ucontext.h" ],
     "sys/quota.h":                 [ "sys/types.h" ],
-    "sys/random.h":                [ "sys/types.h" ],
     "sys/raw.h":                   [ "stdint.h", "sys/ioctl.h" ],
-    "sys/sendfile.h":              [ "sys/types.h" ],
     "sys/signal.h":                [ "signal.h" ],
     "sys/signalfd.h":              [ "stdint.h" ],
     "sys/socketvar.h":             [ "sys/socket.h" ],
diff --git a/stdlib/sys/random.h b/stdlib/sys/random.h
index 2297edf..f3cd54e 100644
--- a/stdlib/sys/random.h
+++ b/stdlib/sys/random.h
@@ -20,7 +20,10 @@
 #define _SYS_RANDOM_H 1
 
 #include <features.h>
-#include <sys/types.h>
+
+#define __need_size_t
+#include <stddef.h>
+#include <bits/types/ssize_t.h>
 
 /* Flags for use with getrandom.  */
 #define GRND_NONBLOCK 0x01
diff --git a/sysdeps/mach/hurd/sendfile.c b/sysdeps/mach/hurd/sendfile.c
index 4857396..dbb1ab8 100644
--- a/sysdeps/mach/hurd/sendfile.c
+++ b/sysdeps/mach/hurd/sendfile.c
@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <sys/sendfile.h>
+#include <sys/types.h>
 #include <stddef.h>
 
 /* Send COUNT bytes from file associated with IN_FD starting at OFFSET to


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]