about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2019-06-18 11:47:49 -0400
committerZack Weinberg <zackw@panix.com>2020-01-08 13:04:44 -0500
commitafaa4fe717db9f4106570665f5db0cd45684b96a (patch)
tree202ee1da168bf8b9c9a3209fa54d52fb8404d496 /sysdeps
parent89cbc039a98f6bfc7e27c98a7e3799cf190c11f1 (diff)
downloadglibc-afaa4fe717db9f4106570665f5db0cd45684b96a.tar.gz
glibc-afaa4fe717db9f4106570665f5db0cd45684b96a.tar.xz
glibc-afaa4fe717db9f4106570665f5db0cd45684b96a.zip
Don’t include sys/cdefs.h directly from public headers.
The convention throughout glibc is that every public header includes
features.h directly, as its first action, and relies on features.h to
include sys/cdefs.h.  In a few places, though, it’s been done the
other way around, usually in headers that were copied from a BSD
source (where the convention is exactly the opposite).  This patch
makes all installed headers match the glibc convention.

This patch also corrects a bug in glob.h: it may declare size_t
without notifying stddef.h that it has done this, so e.g.

    #define _XOPEN_SOURCE 700
    #include <glob.h>
    #include <stddef.h>
    int dummy;

declares size_t twice, which is invalid prior to C2011.  I wasn’t able
to persuade gcc 8 to issue an error, even with -std=c89 -Wsystem-headers,
but clang is not so lenient.

	* posix/glob.h: Include features.h, not sys/cdefs.h.
	When __USE_XOPEN || USE_XOPEN2K8, include stddef.h for size_t;
	otherwise, issue an immediate #error if __SIZE_TYPE__ is not
	available. Use __gsize_t, not __size_t, as an impl-namespace
	alternative name for size_t.
	* conform/data/glob.h-data: Adjust to match.

	* inet/netinet/igmp.h, mach/lock-intern.h, misc/ar.h
	* misc/sys/auxv.h, resolv/resolv.h, socket/sys/un.h
	* sunrpc/rpc/auth_des.h, sunrpc/rpc/rpc_msg.h
	* sysdeps/generic/memcopy.h, sysdeps/generic/netinet/tcp.h
	* sysdeps/htl/pthread.h, sysdeps/mach/hurd/net/ethernet.h
	* sysdeps/mach/hurd/net/if_arp.h: Include features.h, not sys/cdefs.h.

	* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
        Update.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/memcopy.h3
-rw-r--r--sysdeps/generic/netinet/tcp.h3
-rw-r--r--sysdeps/htl/pthread.h1
-rw-r--r--sysdeps/mach/hurd/net/ethernet.h3
-rw-r--r--sysdeps/mach/hurd/net/if_arp.h4
5 files changed, 7 insertions, 7 deletions
diff --git a/sysdeps/generic/memcopy.h b/sysdeps/generic/memcopy.h
index 0b09ca330c..a2d37a1cd8 100644
--- a/sysdeps/generic/memcopy.h
+++ b/sysdeps/generic/memcopy.h
@@ -20,6 +20,8 @@
 #ifndef _MEMCOPY_H
 #define _MEMCOPY_H	1
 
+#include <features.h>
+
 /* The strategy of the memory functions is:
 
      1. Copy bytes until the destination pointer is aligned.
@@ -38,7 +40,6 @@
    exhaustive in the sense that I tried all alignment and length
    combinations, with and without overlap.  */
 
-#include <sys/cdefs.h>
 #include <endian.h>
 #include <pagecopy.h>
 
diff --git a/sysdeps/generic/netinet/tcp.h b/sysdeps/generic/netinet/tcp.h
index 49f1bfbc26..3b59e949d8 100644
--- a/sysdeps/generic/netinet/tcp.h
+++ b/sysdeps/generic/netinet/tcp.h
@@ -30,10 +30,9 @@
  */
 
 #ifndef _NETINET_TCP_H
-
 #define _NETINET_TCP_H	1
-#include <sys/cdefs.h>
 
+#include <features.h>
 
 __BEGIN_DECLS
 
diff --git a/sysdeps/htl/pthread.h b/sysdeps/htl/pthread.h
index 3216860493..2f9d37707e 100644
--- a/sysdeps/htl/pthread.h
+++ b/sysdeps/htl/pthread.h
@@ -25,7 +25,6 @@
 
 #include <features.h>
 
-#include <sys/cdefs.h>
 #ifndef __extern_inline
 /* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
    inline semantics, unless -fgnu89-inline is used.  */
diff --git a/sysdeps/mach/hurd/net/ethernet.h b/sysdeps/mach/hurd/net/ethernet.h
index 06beb6c9af..53b2e39600 100644
--- a/sysdeps/mach/hurd/net/ethernet.h
+++ b/sysdeps/mach/hurd/net/ethernet.h
@@ -21,7 +21,8 @@
 #ifndef __NET_ETHERNET_H
 #define __NET_ETHERNET_H 1
 
-#include <sys/cdefs.h>
+#include <features.h>
+
 #include <sys/types.h>
 #include <stdint.h>
 #include <net/if_ether.h>     /* IEEE 802.3 Ethernet constants */
diff --git a/sysdeps/mach/hurd/net/if_arp.h b/sysdeps/mach/hurd/net/if_arp.h
index 0fa9bcec9e..ffb6ef1e22 100644
--- a/sysdeps/mach/hurd/net/if_arp.h
+++ b/sysdeps/mach/hurd/net/if_arp.h
@@ -20,9 +20,9 @@
 /* Based on the 4.4BSD and Linux version of this file.  */
 
 #ifndef _NET_IF_ARP_H
-
 #define _NET_IF_ARP_H 1
-#include <sys/cdefs.h>
+
+#include <features.h>
 
 #include <sys/types.h>
 #include <sys/socket.h>