aboutsummaryrefslogtreecommitdiff
path: root/misc
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 /misc
parent89cbc039a98f6bfc7e27c98a7e3799cf190c11f1 (diff)
downloadglibc-afaa4fe717db9f4106570665f5db0cd45684b96a.zip
glibc-afaa4fe717db9f4106570665f5db0cd45684b96a.tar.gz
glibc-afaa4fe717db9f4106570665f5db0cd45684b96a.tar.bz2
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 'misc')
-rw-r--r--misc/ar.h2
-rw-r--r--misc/sys/auxv.h3
2 files changed, 3 insertions, 2 deletions
diff --git a/misc/ar.h b/misc/ar.h
index 85ecba6..8dcef44 100644
--- a/misc/ar.h
+++ b/misc/ar.h
@@ -19,7 +19,7 @@
#ifndef _AR_H
#define _AR_H 1
-#include <sys/cdefs.h>
+#include <features.h>
/* Archive files start with the ARMAG identifying string. Then follows a
`struct ar_hdr', and as many bytes of member file data as its `ar_size'
diff --git a/misc/sys/auxv.h b/misc/sys/auxv.h
index 1a563e1..038bbbe 100644
--- a/misc/sys/auxv.h
+++ b/misc/sys/auxv.h
@@ -19,8 +19,9 @@
#ifndef _SYS_AUXV_H
#define _SYS_AUXV_H 1
+#include <features.h>
+
#include <elf.h>
-#include <sys/cdefs.h>
#include <bits/hwcap.h>
__BEGIN_DECLS