about summary refs log tree commit diff
path: root/sunrpc/rpc/netdb.h
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2019-05-28 13:59:08 -0400
committerZack Weinberg <zackw@panix.com>2020-01-08 13:41:32 -0500
commitcb54252075282ed6ed171a5b0d8eb372c2b06522 (patch)
treee30c4cc531ade5622e560e0e0844a9c3aaa31a06 /sunrpc/rpc/netdb.h
parent7e51209849daa7183794e8b0870a97de4c38e3ac (diff)
downloadglibc-cb54252075282ed6ed171a5b0d8eb372c2b06522.tar.gz
glibc-cb54252075282ed6ed171a5b0d8eb372c2b06522.tar.xz
glibc-cb54252075282ed6ed171a5b0d8eb372c2b06522.zip
Add bits/types/ wrappers for stddef.h and stdarg.h types.
We rely on the compiler's stddef.h and stdarg.h to define size_t,
ptrdiff_t, wchar_t, NULL, and __gnuc_va_list, and to implement a
convention that allows us to request the definition of a specific one:
for instance

    #define __need_size_t
    #include <stddef.h>

is expected to define size_t but not any of the other things stddef.h
defines.

This patch hides that convention behind a set of bits/types/ headers,
which allows check-obsolete-constructs.py to verify that none of our
headers include these headers unconditionally.  (Both of them define
at least one item in the user namespace that no other header is
supposed to expose.)  It will also facilitate coping with compilers
that don’t implement the __need convention.  (That scenario is not
hypothetical, see the next patch.)

Only public headers use the new bits headers.  Non-public headers and
.c files in our codebase, that were formerly defining __need macros,
now just include stddef.h and/or stdarg.h without any __need macros.
A few files didn’t need to be including stddef.h / stdarg.h at all.

Uses of NULL in public headers that aren’t expected to define NULL
are changed to a bare 0.  bits/NULL.h is only used by headers that
are expected to define NULL.

malloc.h and printf.h were, in fact, including stddef.h and/or
stdarg.h unconditionally; they no longer do that.  This broke a few of
our test cases, which are fixed by adding appropriate inclusions to
the relevant .c files.

	* stdlib/bits/NULL.h
	* stdlib/bits/types/__va_list.h
	* stdlib/bits/types/ptrdiff_t.h
	* stdlib/bits/types/size_t.h
	* stdlib/bits/types/va_list.h
	* stdlib/bits/types/wchar_t.h:
	New headers defining a single type or macro each.
	* stdlib/Makefile: Install new headers.
	* include/bits/NULL.h
	* include/bits/types/__va_list.h
	* include/bits/types/ptrdiff_t.h
	* include/bits/types/size_t.h
	* include/bits/types/va_list.h
	* include/bits/types/wchar_t.h:
	New wrapper headers.

	* malloc/malloc.h: Don’t include stdio.h or stddef.h.
	Include bits/NULL.h, bits/types/size_t.h, bits/types/ptrdiff_t.h,
	and bits/types/FILE.h.
	* stdio-common/printf.h: Don’t include stddef.h or stdarg.h.
	Include bits/types/size_t.h, bits/types/wchar_t.h, and
	bits/types/__va_list.h.  Use __gnuc_va_list instead of va_list
	in prototypes.

	* libio/bits/types/struct_FILE.h: Include bits/types/size_t.h.
	* misc/sys/param.h: Include features.h.

	* sysvipc/sys/msg.h: Include bits/msq.h after all bits/types/ headers.
	* sysvipc/sys/sem.h: Include bits/sem.h after all bits/types/ headers.
	* sysvipc/sys/shm.h: Include bits/shm.h after all bits/types/ headers.

	* hurd/hurd/signal.h: Don’t use NULL.
	* hurd/hurd/ioctl.h: Don’t include stdarg.h.
	* hurd/hurd/userlink.h: Don’t include stddef.h.  Don’t use NULL.
	* intl/libintl.h: Don’t include stddef.h.  Don’t use NULL.

	* intl/gettext.c, intl/ngettext.c: Include stddef.h
	unconditionally.  Don’t define any __need macros first.
	Don’t include stdlib.h.

	* sysdeps/posix/sigignore.c:, sysdeps/posix/sigset.c:
	Don’t include errno.h or string.h.

	* malloc/tst-malloc-thread-fail.c: Include stddef.h.
	* malloc/tst-malloc_info.c: Include stdio.h.
	* stdio-common/tst-vfprintf-user-type.c: Include stdarg.h.
	* string/tst-cmp.c: Include stdio.h.

	* debug/wcpcpy_chk.c, iconv/loop.c, iconv/skeleton.c
	* signal/sighold.c, signal/sigrelse.c, stdio-common/tempname.c
	* sysdeps/generic/ldsodefs.h, sysdeps/nptl/libc-lock.h
	* sysdeps/nptl/libc-lockP.h, sysdeps/posix/waitid.c
	* wcsmbs/wcstol_l.c, wcsmbs/wcstoll_l.c, wcsmbs/wcstoul_l.c
	* wcsmbs/wcstoull_l.c, sysdeps/posix/sigignore.c
	* sysdeps/posix/sigset.c: Don’t define __need macros before
	including stddef.h.

	* bits/socket.h, bits/types/stack_t.h, dirent/dirent.h
	* dlfcn/dlfcn.h, gmon/sys/profil.h, grp/grp.h, gshadow/gshadow.h
        * hurd/hurd/signal.h, hurd/hurd/sigpreempt.h, iconv/gconv.h
        * include/set-hooks.h, include/stdio.h, inet/aliases.h
        * io/sys/sendfile.h, libio/stdio.h, misc/bits/types/struct_iovec.h
	* misc/search.h, misc/sys/mman.h, misc/syslog.h, posix/glob.h
	* posix/sched.h, posix/sys/types.h, posix/unistd.h
	* posix/wordexp.h, pwd/pwd.h, shadow/shadow.h, signal/signal.h
        * socket/sys/socket.h, stdlib/alloca.h, stdlib/monetary.h
	* stdlib/stdlib.h, stdlib/sys/random.h, string/string.h
	* string/strings.h, sunrpc/rpc/netdb.h
	* sysdeps/htl/bits/types/struct___pthread_attr.h
	* sysdeps/mach/hurd/bits/socket.h
	* sysdeps/unix/sysv/linux/bits/socket.h
	* sysdeps/unix/sysv/linux/bits/types/stack_t.h
	* sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h
	* sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h
	* sysdeps/unix/sysv/linux/scsi/sg.h
	* sysdeps/unix/sysv/linux/sys/sysctl.h
	* sysvipc/sys/msg.h, sysvipc/sys/sem.h, sysvipc/sys/shm.h
        * time/time.h, wcsmbs/uchar.h, wcsmbs/wchar.h:
	Use bits/types/size_t.h instead of __need_size_t.

	* iconv/gconv.h, iconv/iconv.h, libio/libio.h
	* stdlib/inttypes.h, stdlib/stdlib.h, wcsmbs/wchar.h:
	Use bits/types/wchar_t.h instead of __need_wchar_t.

	* libio/stdio.h, locale/locale.h, misc/sys/param.h
	* posix/sched.h, posix/unistd.h, stdlib/stdlib.h
	* string/string.h, sysdeps/unix/sysv/linux/bits/sigcontext.h
	* time/time.h, wcsmbs/wchar.h: Use bits/NULL.h instead of __need_NULL.

	* libio/stdio.h, misc/err.h: Use bits/types/__va_list.h instead
	of __need___va_list.
	* libio/stdio.h: Use bits/types/va_list.h instead of manually
	defining va_list.

	* hurd/hurd/userlink.h, misc/sys/mman.h, posix/sched.h
	* sysdeps/mach/hurd/bits/socket.h
	* sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h
	* wcsmbs/wchar.h: Reorganize includes; no semantic effect.
	* stdlib/stdlib.h: Normalize format of multiple include guard.
	* sysdeps/unix/sysv/linux/bits/sigcontext.h: Annotate workarounds
	for kernel header bugs.

	* sysdeps/unix/sysv/linux/aarch64/sys/user.h
	* sysdeps/unix/sysv/linux/arm/sys/user.h
	* sysdeps/unix/sysv/linux/m68k/sys/user.h
	* sysdeps/unix/sysv/linux/microblaze/sys/user.h
	* sysdeps/unix/sysv/linux/nios2/sys/user.h
	* sysdeps/unix/sysv/linux/s390/sys/user.h
	* sysdeps/unix/sysv/linux/x86/sys/user.h
	Include features.h.

	* sysdeps/unix/sysv/linux/alpha/sys/user.h
	* sysdeps/unix/sysv/linux/ia64/sys/user.h
	* sysdeps/unix/sysv/linux/mips/sys/user.h
	* sysdeps/unix/sysv/linux/powerpc/sys/user.h
	* sysdeps/unix/sysv/linux/sh/sys/user.h
	* sysdeps/unix/sysv/linux/sparc/sys/user.h
	Include features.h and bits/types/size_t.h, in that order.
	Include kernel headers, if any, after those two.
	Don’t include stddef.h or sys/types.h.

	* scripts/check-obsolete-constructs.py
	(UNIVERSAL_ALLOWED_INCLUDES): Remove stddef.h and stdarg.h.
	(HEADER_ALLOWED_INCLUDES): Update.
Diffstat (limited to 'sunrpc/rpc/netdb.h')
-rw-r--r--sunrpc/rpc/netdb.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/sunrpc/rpc/netdb.h b/sunrpc/rpc/netdb.h
index 529a4ada21..a5aa340e1a 100644
--- a/sunrpc/rpc/netdb.h
+++ b/sunrpc/rpc/netdb.h
@@ -38,8 +38,7 @@
 
 #include <features.h>
 
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 
 __BEGIN_DECLS