]> git.ipfire.org Git - thirdparty/glibc.git/commit
Don’t include sys/cdefs.h directly from public headers.
authorZack Weinberg <zackw@panix.com>
Tue, 18 Jun 2019 15:47:49 +0000 (11:47 -0400)
committerZack Weinberg <zackw@panix.com>
Wed, 8 Jan 2020 18:04:44 +0000 (13:04 -0500)
commitafaa4fe717db9f4106570665f5db0cd45684b96a
tree202ee1da168bf8b9c9a3209fa54d52fb8404d496
parent89cbc039a98f6bfc7e27c98a7e3799cf190c11f1
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.
16 files changed:
conform/data/glob.h-data
inet/netinet/igmp.h
mach/lock-intern.h
misc/ar.h
misc/sys/auxv.h
posix/glob.h
resolv/resolv.h
scripts/check-obsolete-constructs.py
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