From: Zack Weinberg Date: Tue, 28 May 2019 17:59:08 +0000 (-0400) Subject: Add bits/types/ wrappers for stddef.h and stdarg.h types. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb54252075282ed6ed171a5b0d8eb372c2b06522;p=thirdparty%2Fglibc.git 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 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. --- diff --git a/bits/socket.h b/bits/socket.h index e72dcfda40b..c844429ab85 100644 --- a/bits/socket.h +++ b/bits/socket.h @@ -23,11 +23,9 @@ # error "Never include directly; use instead." #endif -#define __need_size_t -#include - #include #include +#include #include /* Types of sockets. */ diff --git a/bits/types/stack_t.h b/bits/types/stack_t.h index a5aac932bbe..0cd11ea59c4 100644 --- a/bits/types/stack_t.h +++ b/bits/types/stack_t.h @@ -19,8 +19,7 @@ #ifndef __stack_t_defined #define __stack_t_defined 1 -#define __need_size_t -#include +#include /* Structure describing a signal stack. */ typedef struct diff --git a/debug/wcpcpy_chk.c b/debug/wcpcpy_chk.c index ff489b4e461..0dbdedb41cb 100644 --- a/debug/wcpcpy_chk.c +++ b/debug/wcpcpy_chk.c @@ -17,8 +17,6 @@ . */ #include - -#define __need_ptrdiff_t #include diff --git a/dirent/dirent.h b/dirent/dirent.h index 0886b6d30d1..4dca152e535 100644 --- a/dirent/dirent.h +++ b/dirent/dirent.h @@ -233,8 +233,7 @@ extern int dirfd (DIR *__dirp) __THROW __nonnull ((1)); # endif # endif -# define __need_size_t -# include +# include /* Scan the directory DIR, calling SELECTOR on each directory entry. Entries for which SELECT returns nonzero are individually malloc'd, diff --git a/dlfcn/dlfcn.h b/dlfcn/dlfcn.h index c629fc7f420..5eb2f685421 100644 --- a/dlfcn/dlfcn.h +++ b/dlfcn/dlfcn.h @@ -20,8 +20,8 @@ #define _DLFCN_H 1 #include -#define __need_size_t -#include + +#include /* Collect various system dependent definitions and declarations. */ #include diff --git a/grp/grp.h b/grp/grp.h index 5ef235ef210..a2c20a493f7 100644 --- a/grp/grp.h +++ b/grp/grp.h @@ -27,9 +27,7 @@ __BEGIN_DECLS #include - -#define __need_size_t -#include +#include /* For the Single Unix specification we must define this type here. */ #if defined __USE_XOPEN || defined __USE_XOPEN2K @@ -167,9 +165,6 @@ extern int fgetgrent_r (FILE *__restrict __stream, #ifdef __USE_MISC -# define __need_size_t -# include - /* Set the group set for the current user to GROUPS (N of them). */ extern int setgroups (size_t __n, const __gid_t *__groups) __THROW; diff --git a/gshadow/gshadow.h b/gshadow/gshadow.h index 9bcb473ce56..8dec35d4f8c 100644 --- a/gshadow/gshadow.h +++ b/gshadow/gshadow.h @@ -23,9 +23,7 @@ #include #include #include - -#define __need_size_t -#include +#include /* Path to the user database files. */ #define GSHADOW _PATH_GSHADOW diff --git a/hurd/hurd/ioctl.h b/hurd/hurd/ioctl.h index bc136d8b7fd..83c3e8c13b0 100644 --- a/hurd/hurd/ioctl.h +++ b/hurd/hurd/ioctl.h @@ -19,8 +19,6 @@ #ifndef _HURD_IOCTL_H #define _HURD_IOCTL_H 1 -#define __need___va_list -#include #include #include diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h index 6583dcb5b1e..22de146adbd 100644 --- a/hurd/hurd/signal.h +++ b/hurd/hurd/signal.h @@ -21,10 +21,6 @@ #define _HURD_SIGNAL_H 1 #include -#define __need_size_t -#define __need_NULL -#include - #include #include #include @@ -34,6 +30,7 @@ #include #include #include +#include #include #include @@ -164,7 +161,7 @@ extern void _hurd_sigstate_delete (thread_t thread); _HURD_SIGNAL_H_EXTERN_INLINE struct hurd_sigstate * _hurd_self_sigstate (void) { - if (THREAD_SELF->_hurd_sigstate == NULL) + if (! THREAD_SELF->_hurd_sigstate) THREAD_SELF->_hurd_sigstate = _hurd_thread_sigstate (__mach_thread_self ()); return THREAD_SELF->_hurd_sigstate; } @@ -207,11 +204,11 @@ _hurd_critical_section_lock (void) #ifdef __LIBC_NO_TLS if (__LIBC_NO_TLS ()) /* TLS is currently initializing, no need to enter critical section. */ - return NULL; + return 0; #endif ss = THREAD_SELF->_hurd_sigstate; - if (ss == NULL) + if (! ss) { /* The thread variable is unset; this must be the first time we've asked for it. In this case, the critical section flag cannot @@ -222,7 +219,7 @@ _hurd_critical_section_lock (void) if (! __spin_try_lock (&ss->critical_section_lock)) /* We are already in a critical section, so do nothing. */ - return NULL; + return 0; /* With the critical section lock held no signal handler will run. Return our sigstate pointer; this will be passed to @@ -239,7 +236,7 @@ extern void _hurd_critical_section_unlock (void *our_lock); _HURD_SIGNAL_H_EXTERN_INLINE void _hurd_critical_section_unlock (void *our_lock) { - if (our_lock == NULL) + if (! our_lock) /* The critical section lock was held when we began. Do nothing. */ return; else diff --git a/hurd/hurd/sigpreempt.h b/hurd/hurd/sigpreempt.h index 2591c472d34..42d5e8b27c6 100644 --- a/hurd/hurd/sigpreempt.h +++ b/hurd/hurd/sigpreempt.h @@ -19,8 +19,7 @@ #ifndef _HURD_SIGPREEMPT_H #define _HURD_SIGPREEMPT_H 1 -#define __need_size_t -#include +#include #include #include #include /* For sighandler_t, SIG_ERR. */ diff --git a/hurd/hurd/userlink.h b/hurd/hurd/userlink.h index 7c008a81bce..1b8cce96490 100644 --- a/hurd/hurd/userlink.h +++ b/hurd/hurd/userlink.h @@ -17,20 +17,16 @@ . */ #ifndef _HURD_USERLINK_H - #define _HURD_USERLINK_H 1 -#include -#define __need_NULL -#include +#include +#include #if defined __USE_EXTERN_INLINES && defined _LIBC # if IS_IN (libc) # include # endif #endif -#include - /* This structure records a link in two doubly-linked lists. We call these the per-resource user list and the per-thread @@ -156,11 +152,11 @@ _hurd_userlink_move (struct hurd_userlink *new_link, { *new_link = *link; - if (new_link->resource.next != NULL) + if (new_link->resource.next) new_link->resource.next->resource.prevp = &new_link->resource.next; *new_link->resource.prevp = new_link; - if (new_link->thread.next != NULL) + if (new_link->thread.next) new_link->thread.next->thread.prevp = &new_link->thread.next; *new_link->thread.prevp = new_link; } @@ -180,13 +176,13 @@ extern int _hurd_userlink_clear (struct hurd_userlink **chainp); _HURD_USERLINK_H_EXTERN_INLINE int _hurd_userlink_clear (struct hurd_userlink **chainp) { - if (*chainp == NULL) + if (! *chainp) return 1; /* Detach the chain of current users from the cell. The last user to remove his link from that chain will deallocate the old resource. */ - (*chainp)->resource.prevp = NULL; - *chainp = NULL; + (*chainp)->resource.prevp = 0; + *chainp = 0; return 0; } # endif diff --git a/iconv/gconv.h b/iconv/gconv.h index 6add5966427..041989e595f 100644 --- a/iconv/gconv.h +++ b/iconv/gconv.h @@ -24,12 +24,10 @@ #include #include +#include +#include #include -#define __need_size_t -#define __need_wchar_t -#include - /* ISO 10646 value used to signal invalid value. */ #define __UNKNOWN_10646_CHAR ((wchar_t) 0xfffd) diff --git a/iconv/iconv.h b/iconv/iconv.h index a457001c0ca..b421cb07c15 100644 --- a/iconv/iconv.h +++ b/iconv/iconv.h @@ -19,8 +19,7 @@ #define _ICONV_H 1 #include -#define __need_size_t -#include +#include __BEGIN_DECLS diff --git a/iconv/loop.c b/iconv/loop.c index 9f7570d5915..cfae4a5e62a 100644 --- a/iconv/loop.c +++ b/iconv/loop.c @@ -54,7 +54,6 @@ #include #include #include /* For MIN. */ -#define __need_size_t #include #include diff --git a/iconv/skeleton.c b/iconv/skeleton.c index 1dc642e2fc9..0ca3498694c 100644 --- a/iconv/skeleton.c +++ b/iconv/skeleton.c @@ -140,8 +140,6 @@ #include #include #include -#define __need_size_t -#define __need_NULL #include #ifndef STATIC_GCONV diff --git a/include/bits/NULL.h b/include/bits/NULL.h new file mode 100644 index 00000000000..0584572ed30 --- /dev/null +++ b/include/bits/NULL.h @@ -0,0 +1 @@ +#include diff --git a/include/bits/types/__va_list.h b/include/bits/types/__va_list.h new file mode 100644 index 00000000000..436e6ed8235 --- /dev/null +++ b/include/bits/types/__va_list.h @@ -0,0 +1 @@ +#include diff --git a/include/bits/types/ptrdiff_t.h b/include/bits/types/ptrdiff_t.h new file mode 100644 index 00000000000..d16c0d3c2bb --- /dev/null +++ b/include/bits/types/ptrdiff_t.h @@ -0,0 +1 @@ +#include diff --git a/include/bits/types/size_t.h b/include/bits/types/size_t.h new file mode 100644 index 00000000000..feaa04363f8 --- /dev/null +++ b/include/bits/types/size_t.h @@ -0,0 +1 @@ +#include diff --git a/include/bits/types/va_list.h b/include/bits/types/va_list.h new file mode 100644 index 00000000000..dbc749a7523 --- /dev/null +++ b/include/bits/types/va_list.h @@ -0,0 +1 @@ +#include diff --git a/include/bits/types/wchar_t.h b/include/bits/types/wchar_t.h new file mode 100644 index 00000000000..343bd5855d6 --- /dev/null +++ b/include/bits/types/wchar_t.h @@ -0,0 +1 @@ +#include diff --git a/include/set-hooks.h b/include/set-hooks.h index dba382c3a8c..90db3b3b846 100644 --- a/include/set-hooks.h +++ b/include/set-hooks.h @@ -19,8 +19,7 @@ #ifndef _SET_HOOKS_H #define _SET_HOOKS_H 1 -#define __need_size_t -#include +#include #include #include diff --git a/include/stdio.h b/include/stdio.h index dffa7765dd6..5cd38eaeedf 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -84,9 +84,7 @@ libc_hidden_proto (__isoc99_vfscanf) extern FILE *__new_tmpfile (void); extern FILE *__old_tmpfile (void); -# define __need_size_t -# include - +# include # include /* Generate a unique file name (and possibly open it). */ diff --git a/intl/gettext.c b/intl/gettext.c index b8c98ae19c4..da2ae6c3a51 100644 --- a/intl/gettext.c +++ b/intl/gettext.c @@ -18,12 +18,7 @@ # include #endif -#ifdef _LIBC -# define __need_NULL -# include -#else -# include /* Just for NULL. */ -#endif +#include /* Just for NULL. */ #include "gettextP.h" #ifdef _LIBC diff --git a/intl/libintl.h b/intl/libintl.h index 2fd0a31e8e6..e4b5c725877 100644 --- a/intl/libintl.h +++ b/intl/libintl.h @@ -95,10 +95,6 @@ extern char *bind_textdomain_codeset (const char *__domainname, /* Optimized version of the function above. */ #if defined __OPTIMIZE__ && !defined __cplusplus -/* We need NULL for `gettext'. */ -# define __need_NULL -# include - /* We need LC_MESSAGES for `dgettext'. */ # include @@ -106,12 +102,12 @@ extern char *bind_textdomain_codeset (const char *__domainname, `__builtin_constant_p' predicate in dcgettext would always return false. */ -# define gettext(msgid) dgettext (NULL, msgid) +# define gettext(msgid) dgettext (0, msgid) # define dgettext(domainname, msgid) \ dcgettext (domainname, msgid, LC_MESSAGES) -# define ngettext(msgid1, msgid2, n) dngettext (NULL, msgid1, msgid2, n) +# define ngettext(msgid1, msgid2, n) dngettext (0, msgid1, msgid2, n) # define dngettext(domainname, msgid1, msgid2, n) \ dcngettext (domainname, msgid1, msgid2, n, LC_MESSAGES) diff --git a/intl/ngettext.c b/intl/ngettext.c index 47f93ad698d..8fcf908cc92 100644 --- a/intl/ngettext.c +++ b/intl/ngettext.c @@ -18,12 +18,7 @@ # include #endif -#ifdef _LIBC -# define __need_NULL -# include -#else -# include /* Just for NULL. */ -#endif +#include /* Just for NULL. */ #include "gettextP.h" #ifdef _LIBC diff --git a/libio/bits/types/struct_FILE.h b/libio/bits/types/struct_FILE.h index 06feadf3123..881c2339819 100644 --- a/libio/bits/types/struct_FILE.h +++ b/libio/bits/types/struct_FILE.h @@ -31,6 +31,7 @@ #endif #include +#include struct _IO_FILE; struct _IO_marker; diff --git a/libio/libio.h b/libio/libio.h index 3781b296e3f..37bc8f25c1f 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -41,10 +41,8 @@ # error "Someone forgot to include stdio-lock.h" #endif -#define __need_wchar_t -#include - #include +#include #include #include diff --git a/libio/stdio.h b/libio/stdio.h index cf99970f90b..1a2cd4046bd 100644 --- a/libio/stdio.h +++ b/libio/stdio.h @@ -28,33 +28,22 @@ __BEGIN_DECLS -#define __need_size_t -#define __need_NULL -#include - -#define __need___va_list -#include - #include #include #include #include +#include #include #include +#include +#include #ifdef __USE_GNU # include #endif #if defined __USE_XOPEN || defined __USE_XOPEN2K8 -# ifdef __GNUC__ -# ifndef _VA_LIST_DEFINED -typedef __gnuc_va_list va_list; -# define _VA_LIST_DEFINED -# endif -# else -# include -# endif +# include #endif #if defined __USE_UNIX98 || defined __USE_XOPEN2K diff --git a/locale/locale.h b/locale/locale.h index b013c8bb024..0ef9a391a6e 100644 --- a/locale/locale.h +++ b/locale/locale.h @@ -24,9 +24,8 @@ #include -#define __need_NULL -#include #include +#include __BEGIN_DECLS diff --git a/malloc/malloc.h b/malloc/malloc.h index 0c762644213..85985248f98 100644 --- a/malloc/malloc.h +++ b/malloc/malloc.h @@ -20,8 +20,11 @@ #define _MALLOC_H 1 #include -#include -#include + +#include +#include +#include +#include #ifdef _LIBC # define __MALLOC_HOOK_VOLATILE diff --git a/malloc/tst-malloc-thread-fail.c b/malloc/tst-malloc-thread-fail.c index 30a154f2ee0..226e551d0f5 100644 --- a/malloc/tst-malloc-thread-fail.c +++ b/malloc/tst-malloc-thread-fail.c @@ -20,6 +20,7 @@ related to allocation failures, notably switching to a different arena, and falling back to mmap (via sysmalloc). */ +#include #include #include #include diff --git a/malloc/tst-malloc_info.c b/malloc/tst-malloc_info.c index d92cccff8b4..de97bff8cb6 100644 --- a/malloc/tst-malloc_info.c +++ b/malloc/tst-malloc_info.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include diff --git a/misc/bits/types/struct_iovec.h b/misc/bits/types/struct_iovec.h index 793258b4811..c92ae0d91a6 100644 --- a/misc/bits/types/struct_iovec.h +++ b/misc/bits/types/struct_iovec.h @@ -19,8 +19,7 @@ #ifndef __iovec_defined #define __iovec_defined 1 -#define __need_size_t -#include +#include /* Structure for scatter/gather I/O. */ struct iovec diff --git a/misc/err.h b/misc/err.h index f6fd72945f7..5503c4e175c 100644 --- a/misc/err.h +++ b/misc/err.h @@ -21,11 +21,7 @@ #include -#define __need___va_list -#include -#ifndef __GNUC_VA_LIST -# define __gnuc_va_list void * -#endif +#include __BEGIN_DECLS diff --git a/misc/search.h b/misc/search.h index a075570179e..3b5c03f4f1d 100644 --- a/misc/search.h +++ b/misc/search.h @@ -21,8 +21,7 @@ #include -#define __need_size_t -#include +#include __BEGIN_DECLS diff --git a/misc/sys/mman.h b/misc/sys/mman.h index 01cc6407045..38f2e37b842 100644 --- a/misc/sys/mman.h +++ b/misc/sys/mman.h @@ -20,13 +20,11 @@ #define _SYS_MMAN_H 1 #include -#include - -#define __need_size_t -#include -#include +#include #include +#include +#include #include diff --git a/misc/sys/param.h b/misc/sys/param.h index d7c319b1571..eca50cf9bf4 100644 --- a/misc/sys/param.h +++ b/misc/sys/param.h @@ -19,13 +19,13 @@ #ifndef _SYS_PARAM_H #define _SYS_PARAM_H 1 -#define __need_NULL -#include +#include #include #include #include /* Define BYTE_ORDER et al. */ #include /* Define NSIG. */ +#include /* This file defines some things in system-specific ways. */ #include diff --git a/misc/syslog.h b/misc/syslog.h index 406133ba71d..f7b7a6743fd 100644 --- a/misc/syslog.h +++ b/misc/syslog.h @@ -33,8 +33,7 @@ #define _SYSLOG_H 1 #include -#define __need___va_list -#include +#include /* This file defines _PATH_LOG. */ #include diff --git a/posix/glob.h b/posix/glob.h index e647ba813a1..c913238a30c 100644 --- a/posix/glob.h +++ b/posix/glob.h @@ -29,8 +29,7 @@ __BEGIN_DECLS a different purpose. */ #if defined __USE_XOPEN || defined __USE_XOPEN2K8 -# define __need_size_t -# include +#include typedef size_t __gsize_t; #elif defined __SIZE_TYPE__ typedef __SIZE_TYPE__ __gsize_t; diff --git a/posix/sched.h b/posix/sched.h index bb7e727da08..d4465256c62 100644 --- a/posix/sched.h +++ b/posix/sched.h @@ -22,18 +22,15 @@ #include /* Get type definitions. */ +#include #include - -#define __need_size_t -#define __need_NULL -#include - +#include +#include #include #include #ifndef __USE_XOPEN2K # include #endif -#include /* Get system specific constant and data structure definitions. */ #include diff --git a/posix/sys/types.h b/posix/sys/types.h index ba8e72a2150..64fa0101145 100644 --- a/posix/sys/types.h +++ b/posix/sys/types.h @@ -28,9 +28,6 @@ __BEGIN_DECLS #include -#define __need_size_t -#include - #include #include #include @@ -42,6 +39,7 @@ __BEGIN_DECLS #include #include #include +#include #include #include #include diff --git a/posix/unistd.h b/posix/unistd.h index e5958e3d36c..386b4e59a33 100644 --- a/posix/unistd.h +++ b/posix/unistd.h @@ -214,13 +214,11 @@ __BEGIN_DECLS /* All functions that are not declared anywhere else. */ +#include #include +#include #include -#define __need_size_t -#define __need_NULL -#include - #if defined __USE_XOPEN || defined __USE_XOPEN2K /* The Single Unix specification says that some more types are available here. */ diff --git a/posix/wordexp.h b/posix/wordexp.h index 4e52ace50f3..f94796cb24e 100644 --- a/posix/wordexp.h +++ b/posix/wordexp.h @@ -19,8 +19,7 @@ #define _WORDEXP_H 1 #include -#define __need_size_t -#include +#include __BEGIN_DECLS diff --git a/pwd/pwd.h b/pwd/pwd.h index 7f490f57deb..8f49ea22f01 100644 --- a/pwd/pwd.h +++ b/pwd/pwd.h @@ -27,9 +27,7 @@ __BEGIN_DECLS #include - -#define __need_size_t -#include +#include #if defined __USE_XOPEN || defined __USE_XOPEN2K /* The Single Unix specification says that some more types are diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py index 8b52463cfb0..5d4faac0f0b 100755 --- a/scripts/check-obsolete-constructs.py +++ b/scripts/check-obsolete-constructs.py @@ -491,14 +491,6 @@ def ObsoleteTypedefChecker(reporter, fname): # but we are not ready to enforce that yet. UNIVERSAL_ALLOWED_INCLUDES = { "features.h", - - # Technically these should only ever be included with __need - # macros active, but some headers deliberately break this rule - # when they think they're dealing with freestanding headers from a - # non-GNU compiler, so enforcing it would be more trouble than - # it's worth. - "stddef.h", - "stdarg.h", } # Specific headers are allowed to include specific other headers. @@ -575,7 +567,7 @@ HEADER_ALLOWED_INCLUDES = { "link.h": [ "dlfcn.h", "elf.h", "sys/types.h" ], "mntent.h": [ "paths.h" ], "nss.h": [ "stdint.h" ], - "obstack.h": [ "string.h" ], + "obstack.h": [ "stddef.h", "string.h" ], "proc_service.h": [ "sys/procfs.h" ], "pty.h": [ "sys/ioctl.h", "termios.h" ], "sgtty.h": [ "sys/ioctl.h" ], @@ -619,7 +611,6 @@ HEADER_ALLOWED_INCLUDES = { "sys/timex.h": [ "sys/time.h" ], "sys/ttychars.h": [ "sys/ttydefaults.h" ], "sys/ucontext.h": [ "sys/procfs.h" ], - "sys/user.h": [ "sys/types.h" ], "sys/vfs.h": [ "sys/statfs.h" ], "sys/xattr.h": [ "sys/types.h" ], @@ -696,6 +687,12 @@ HEADER_ALLOWED_INCLUDES = { "bits/types/res_state.h": [ "netinet/in.h", "sys/types.h" ], "bits/utmp.h": [ "paths.h", "sys/time.h", "sys/types.h" ], "bits/utmpx.h": [ "paths.h", "sys/time.h" ], + + "bits/types/__va_list.h": [ "stdarg.h" ], + "bits/types/ptrdiff_t.h": [ "stddef.h" ], + "bits/types/size_t.h": [ "stddef.h" ], + "bits/types/wchar_t.h": [ "stddef.h" ], + "bits/NULL.h": [ "stddef.h" ], } # As above, but each group of whitelist entries is only used for diff --git a/shadow/shadow.h b/shadow/shadow.h index cb17ef62e34..20bcde32e4d 100644 --- a/shadow/shadow.h +++ b/shadow/shadow.h @@ -28,10 +28,8 @@ #include -#define __need_size_t -#include - #include +#include /* Paths to the user database files. */ #define SHADOW _PATH_SHADOW diff --git a/signal/sighold.c b/signal/sighold.c index 9fe97912811..53f9eea3077 100644 --- a/signal/sighold.c +++ b/signal/sighold.c @@ -17,7 +17,6 @@ License along with the GNU C Library; if not, see . */ -#define __need_NULL #include #include diff --git a/signal/signal.h b/signal/signal.h index f7f50c82d4f..ae40b903914 100644 --- a/signal/signal.h +++ b/signal/signal.h @@ -289,9 +289,7 @@ extern int sigreturn (struct sigcontext *__scp) __THROW; #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8 -# define __need_size_t -# include - +# include # include # if defined __USE_XOPEN || defined __USE_XOPEN2K8 /* This will define `ucontext_t' and `mcontext_t'. */ diff --git a/signal/sigrelse.c b/signal/sigrelse.c index ad257714df1..e4bc638e691 100644 --- a/signal/sigrelse.c +++ b/signal/sigrelse.c @@ -17,7 +17,6 @@ License along with the GNU C Library; if not, see . */ -#define __need_NULL #include #include diff --git a/socket/sys/socket.h b/socket/sys/socket.h index 7780c00ecbd..0c158d1e931 100644 --- a/socket/sys/socket.h +++ b/socket/sys/socket.h @@ -23,9 +23,8 @@ __BEGIN_DECLS +#include #include -#define __need_size_t -#include /* This operating system-specific header file defines the SOCK_*, PF_*, AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr', diff --git a/stdio-common/printf.h b/stdio-common/printf.h index ad3c8a42549..1ac342d0e5f 100644 --- a/stdio-common/printf.h +++ b/stdio-common/printf.h @@ -23,12 +23,9 @@ __BEGIN_DECLS #include - -#define __need_size_t -#define __need_wchar_t -#include - -#include +#include +#include +#include struct printf_info @@ -89,7 +86,7 @@ typedef int printf_arginfo_function (const struct printf_info *__info, /* Type of a function to get a value of a user-defined from the variable argument list. */ -typedef void printf_va_arg_function (void *__mem, va_list *__ap); +typedef void printf_va_arg_function (void *__mem, __gnuc_va_list *__ap); /* Register FUNC to be called to format SPEC specifiers; ARGINFO must be diff --git a/stdio-common/tempname.c b/stdio-common/tempname.c index fac978d6185..07bbf8d0685 100644 --- a/stdio-common/tempname.c +++ b/stdio-common/tempname.c @@ -15,7 +15,6 @@ License along with the GNU C Library; if not, see . */ -#define __need_size_t #include #include #include diff --git a/stdio-common/tst-vfprintf-user-type.c b/stdio-common/tst-vfprintf-user-type.c index 6c840fe04b3..cf5c483b75a 100644 --- a/stdio-common/tst-vfprintf-user-type.c +++ b/stdio-common/tst-vfprintf-user-type.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include diff --git a/stdlib/Makefile b/stdlib/Makefile index 45214b59e4d..6f8e6ba31d2 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -29,7 +29,9 @@ headers := stdlib.h bits/stdlib.h bits/stdlib-ldbl.h bits/stdlib-float.h \ ucontext.h sys/ucontext.h bits/indirect-return.h \ alloca.h fmtmsg.h \ bits/stdlib-bsearch.h sys/random.h bits/stdint-intn.h \ - bits/stdint-uintn.h bits/time64.h \ + bits/stdint-uintn.h bits/time64.h bits/NULL.h \ + bits/types/ptrdiff_t.h bits/types/size_t.h bits/types/wchar_t.h \ + bits/types/__va_list.h bits/types/va_list.h routines := \ atof atoi atol atoll \ diff --git a/stdlib/alloca.h b/stdlib/alloca.h index bd446887208..a5b0b7a7bf9 100644 --- a/stdlib/alloca.h +++ b/stdlib/alloca.h @@ -20,8 +20,7 @@ #include -#define __need_size_t -#include +#include __BEGIN_DECLS diff --git a/stdlib/bits/NULL.h b/stdlib/bits/NULL.h new file mode 100644 index 00000000000..79285bd7b27 --- /dev/null +++ b/stdlib/bits/NULL.h @@ -0,0 +1,8 @@ +#ifndef _BITS_NULL_H +#define _BITS_NULL_H 1 + +/* We rely on the compiler's stddef.h to define NULL for us. */ +#define __need_NULL +#include + +#endif diff --git a/stdlib/bits/types/__va_list.h b/stdlib/bits/types/__va_list.h new file mode 100644 index 00000000000..e3c53c3e056 --- /dev/null +++ b/stdlib/bits/types/__va_list.h @@ -0,0 +1,9 @@ +#ifndef ____va_list_defined +#define ____va_list_defined 1 + +/* We rely on the compiler's stdarg.h to define __gnuc_va_list for us. */ +#define __need___va_list +#include +#undef __need___va_list + +#endif diff --git a/stdlib/bits/types/ptrdiff_t.h b/stdlib/bits/types/ptrdiff_t.h new file mode 100644 index 00000000000..23a8b986d5f --- /dev/null +++ b/stdlib/bits/types/ptrdiff_t.h @@ -0,0 +1,9 @@ +#ifndef __ptrdiff_t_defined +#define __ptrdiff_t_defined 1 + +/* We rely on the compiler's stddef.h to define ptrdiff_t for us. */ +#define __need_ptrdiff_t +#include +#undef __need_ptrdiff_t + +#endif diff --git a/stdlib/bits/types/size_t.h b/stdlib/bits/types/size_t.h new file mode 100644 index 00000000000..e151458eb3f --- /dev/null +++ b/stdlib/bits/types/size_t.h @@ -0,0 +1,9 @@ +#ifndef __size_t_defined +#define __size_t_defined 1 + +/* We rely on the compiler's stddef.h to define size_t for us. */ +#define __need_size_t +#include +#undef __need_size_t + +#endif diff --git a/stdlib/bits/types/va_list.h b/stdlib/bits/types/va_list.h new file mode 100644 index 00000000000..6f3acac3797 --- /dev/null +++ b/stdlib/bits/types/va_list.h @@ -0,0 +1,15 @@ +/* This guard macro needs to match the one used by at least gcc and + clang's stdarg.h to indicate that va_list, specifically, has been + defined. */ +#ifndef _VA_LIST + +#include + +/* Check again, __va_list.h may not have been able to avoid including + all of stdarg.h. */ +# ifndef _VA_LIST +typedef __gnuc_va_list va_list; +# endif +# define _VA_LIST + +#endif diff --git a/stdlib/bits/types/wchar_t.h b/stdlib/bits/types/wchar_t.h new file mode 100644 index 00000000000..1e44e157cca --- /dev/null +++ b/stdlib/bits/types/wchar_t.h @@ -0,0 +1,9 @@ +#ifndef __wchar_t_defined +#define __wchar_t_defined 1 + +/* We rely on the compiler's stddef.h to define wchar_t for us. */ +#define __need_wchar_t +#include +#undef __need_wchar_t + +#endif diff --git a/stdlib/inttypes.h b/stdlib/inttypes.h index c5ec307c5c6..f42cea5d80b 100644 --- a/stdlib/inttypes.h +++ b/stdlib/inttypes.h @@ -32,8 +32,7 @@ #elif defined __WCHAR_TYPE__ typedef __WCHAR_TYPE__ __gwchar_t; #else -# define __need_wchar_t -# include +#include typedef wchar_t __gwchar_t; #endif diff --git a/stdlib/monetary.h b/stdlib/monetary.h index 8f268a0060a..80f4ea107c4 100644 --- a/stdlib/monetary.h +++ b/stdlib/monetary.h @@ -22,9 +22,8 @@ #include /* Get needed types. */ -#define __need_size_t -#include #include +#include #include __BEGIN_DECLS diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index 9f1f1b80e3d..3e3351ef71d 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -20,20 +20,17 @@ */ #ifndef _STDLIB_H +#define _STDLIB_H 1 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION #include -/* Get size_t, wchar_t and NULL from . */ -#define __need_size_t -#define __need_wchar_t -#define __need_NULL -#include +#include +#include +#include __BEGIN_DECLS -#define _STDLIB_H 1 - #if (defined __USE_XOPEN || defined __USE_XOPEN2K8) && !defined _SYS_WAIT_H /* XPG requires a few symbols from being defined. */ # include diff --git a/string/string.h b/string/string.h index a0f2860cc2f..234ee91d4a3 100644 --- a/string/string.h +++ b/string/string.h @@ -27,10 +27,8 @@ __BEGIN_DECLS -/* Get size_t and NULL from . */ -#define __need_size_t -#define __need_NULL -#include +#include +#include /* Tell the caller that we provide correct C++ prototypes. */ #if defined __cplusplus && (__GNUC_PREREQ (4, 4) \ diff --git a/string/strings.h b/string/strings.h index 87882ec0a75..65dfca89357 100644 --- a/string/strings.h +++ b/string/strings.h @@ -19,8 +19,7 @@ #define _STRINGS_H 1 #include -#define __need_size_t -#include +#include /* Tell the caller that we provide correct C++ prototypes. */ #if defined __cplusplus && __GNUC_PREREQ (4, 4) diff --git a/string/tst-cmp.c b/string/tst-cmp.c index 13af0fcb83e..5b2a72068f3 100644 --- a/string/tst-cmp.c +++ b/string/tst-cmp.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/sunrpc/rpc/netdb.h b/sunrpc/rpc/netdb.h index 529a4ada218..a5aa340e1a0 100644 --- a/sunrpc/rpc/netdb.h +++ b/sunrpc/rpc/netdb.h @@ -38,8 +38,7 @@ #include -#define __need_size_t -#include +#include __BEGIN_DECLS diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 497938ffa20..0ca43f3ca11 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -22,8 +22,6 @@ #include #include -#define __need_size_t -#define __need_NULL #include #include #include diff --git a/sysdeps/htl/bits/types/struct___pthread_attr.h b/sysdeps/htl/bits/types/struct___pthread_attr.h index 482e10b2546..7558db185e9 100644 --- a/sysdeps/htl/bits/types/struct___pthread_attr.h +++ b/sysdeps/htl/bits/types/struct___pthread_attr.h @@ -19,11 +19,9 @@ #ifndef _BITS_TYPES_STRUCT___PTHREAD_ATTR #define _BITS_TYPES_STRUCT___PTHREAD_ATTR 1 +#include #include -#define __need_size_t -#include - enum __pthread_detachstate; enum __pthread_inheritsched; enum __pthread_contentionscope; diff --git a/sysdeps/mach/hurd/bits/socket.h b/sysdeps/mach/hurd/bits/socket.h index 06a731184b4..f7c6f562988 100644 --- a/sysdeps/mach/hurd/bits/socket.h +++ b/sysdeps/mach/hurd/bits/socket.h @@ -24,12 +24,11 @@ # error "Never include directly; use instead." #endif -#define __need_size_t -#include -#include #include +#include #include +#include /* Types of sockets. */ enum __socket_type diff --git a/sysdeps/nptl/libc-lock.h b/sysdeps/nptl/libc-lock.h index bfeee32eaff..bf613655576 100644 --- a/sysdeps/nptl/libc-lock.h +++ b/sysdeps/nptl/libc-lock.h @@ -20,7 +20,6 @@ #define _LIBC_LOCK_H 1 #include -#define __need_NULL #include diff --git a/sysdeps/nptl/libc-lockP.h b/sysdeps/nptl/libc-lockP.h index 86d903dddc3..15156df7ac6 100644 --- a/sysdeps/nptl/libc-lockP.h +++ b/sysdeps/nptl/libc-lockP.h @@ -20,7 +20,6 @@ #define _LIBC_LOCKP_H 1 #include -#define __need_NULL #include diff --git a/sysdeps/posix/sigignore.c b/sysdeps/posix/sigignore.c index 33bf67aacaa..0172094e44d 100644 --- a/sysdeps/posix/sigignore.c +++ b/sysdeps/posix/sigignore.c @@ -17,11 +17,8 @@ License along with the GNU C Library; if not, see . */ -#include -#define __need_NULL #include #include -#include /* For the real memset prototype. */ #include int diff --git a/sysdeps/posix/sigset.c b/sysdeps/posix/sigset.c index df965d1c637..fea6fbf166d 100644 --- a/sysdeps/posix/sigset.c +++ b/sysdeps/posix/sigset.c @@ -15,11 +15,8 @@ License along with the GNU C Library; if not, see . */ -#include -#define __need_NULL #include #include -#include /* For the real memset prototype. */ #include /* Set the disposition for SIG. */ diff --git a/sysdeps/posix/waitid.c b/sysdeps/posix/waitid.c index f7520767356..faca7fd4dce 100644 --- a/sysdeps/posix/waitid.c +++ b/sysdeps/posix/waitid.c @@ -20,7 +20,6 @@ #include #include #include -#define __need_NULL #include #include #include diff --git a/sysdeps/unix/sysv/linux/aarch64/sys/user.h b/sysdeps/unix/sysv/linux/aarch64/sys/user.h index 2288220fe1f..dab30192a14 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sys/user.h +++ b/sysdeps/unix/sysv/linux/aarch64/sys/user.h @@ -19,6 +19,8 @@ #ifndef _SYS_USER_H #define _SYS_USER_H 1 +#include + struct user_regs_struct { unsigned long long regs[31]; diff --git a/sysdeps/unix/sysv/linux/alpha/sys/user.h b/sysdeps/unix/sysv/linux/alpha/sys/user.h index 9a0179ff6d3..c1a0f1915f0 100644 --- a/sysdeps/unix/sysv/linux/alpha/sys/user.h +++ b/sysdeps/unix/sysv/linux/alpha/sys/user.h @@ -18,13 +18,15 @@ #ifndef _SYS_USER_H #define _SYS_USER_H 1 +#include +#include + +#include + /* The whole purpose of this file is for gdb/strace and gdb/strace only. Don't read too much into it. Don't use it for anything other than gdb/strace unless you know what you are doing. */ -#include -#include - struct user { unsigned long int regs[EF_SIZE / 8 + 32]; /* integer and fp regs */ diff --git a/sysdeps/unix/sysv/linux/arm/sys/user.h b/sysdeps/unix/sysv/linux/arm/sys/user.h index 555bfde3d70..77a28aebb16 100644 --- a/sysdeps/unix/sysv/linux/arm/sys/user.h +++ b/sysdeps/unix/sysv/linux/arm/sys/user.h @@ -18,6 +18,8 @@ #ifndef _SYS_USER_H #define _SYS_USER_H 1 +#include + /* The whole purpose of this file is for GDB and GDB only. Don't read too much into it. Don't use it for anything other than GDB unless you know what you are doing. */ diff --git a/sysdeps/unix/sysv/linux/bits/sigcontext.h b/sysdeps/unix/sysv/linux/bits/sigcontext.h index 83b173872ac..79667e4339d 100644 --- a/sysdeps/unix/sysv/linux/bits/sigcontext.h +++ b/sysdeps/unix/sysv/linux/bits/sigcontext.h @@ -24,14 +24,17 @@ #ifndef sigcontext_struct /* Kernel headers before 2.1.1 define a struct sigcontext_struct, but - we need sigcontext. */ + we need sigcontext. FIXME: Is this workaround still necessary? + 2.1.1 was many years ago. */ # define sigcontext_struct sigcontext # include -/* The Linux kernel headers redefine NULL wrongly, so cleanup afterwards. */ -# define __need_NULL -# include +/* The Linux kernel headers redefine NULL wrongly, so cleanup afterwards. + FIXME: This won't work if bits/NULL.h or stddef.h has already been + included. Is this workaround still necessary? Current (4.19) uapi + headers do not redefine NULL. */ +#include #endif #endif /* bits/sigcontext.h */ diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h index f275b334993..65c72198ef8 100644 --- a/sysdeps/unix/sysv/linux/bits/socket.h +++ b/sysdeps/unix/sysv/linux/bits/socket.h @@ -23,10 +23,9 @@ # error "Never include directly; use instead." #endif -#define __need_size_t -#include #include +#include #include /* Get the architecture-dependent definition of enum __socket_type. */ diff --git a/sysdeps/unix/sysv/linux/bits/types/stack_t.h b/sysdeps/unix/sysv/linux/bits/types/stack_t.h index 82b9e496a30..6f40ecbd7ff 100644 --- a/sysdeps/unix/sysv/linux/bits/types/stack_t.h +++ b/sysdeps/unix/sysv/linux/bits/types/stack_t.h @@ -19,8 +19,7 @@ #ifndef __stack_t_defined #define __stack_t_defined 1 -#define __need_size_t -#include +#include /* Structure describing a signal stack. */ typedef struct diff --git a/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h b/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h index 54f23166579..252eff321c9 100644 --- a/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h +++ b/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h @@ -23,11 +23,10 @@ # error "Never use directly; include instead." #endif -#define __need_size_t -#include -#include +#include #include #include +#include #include struct __ia64_fpreg diff --git a/sysdeps/unix/sysv/linux/ia64/sys/user.h b/sysdeps/unix/sysv/linux/ia64/sys/user.h index 469c502aba7..24e6af8494d 100644 --- a/sysdeps/unix/sysv/linux/ia64/sys/user.h +++ b/sysdeps/unix/sysv/linux/ia64/sys/user.h @@ -19,7 +19,7 @@ #define _SYS_USER_H 1 #include -#include +#include /* This definition comes directly from the kernel headers. If anything changes in them this header has to be changed, too. */ diff --git a/sysdeps/unix/sysv/linux/m68k/sys/user.h b/sysdeps/unix/sysv/linux/m68k/sys/user.h index 7226b68fe0d..b21f8a0393e 100644 --- a/sysdeps/unix/sysv/linux/m68k/sys/user.h +++ b/sysdeps/unix/sysv/linux/m68k/sys/user.h @@ -18,6 +18,8 @@ #ifndef _SYS_USER_H #define _SYS_USER_H 1 +#include + /* The whole purpose of this file is for GDB and GDB only. Don't read too much into it. Don't use it for anything other than GDB unless you know what you are doing. */ diff --git a/sysdeps/unix/sysv/linux/microblaze/sys/user.h b/sysdeps/unix/sysv/linux/microblaze/sys/user.h index cccbe639985..1ab0bb3f4b2 100644 --- a/sysdeps/unix/sysv/linux/microblaze/sys/user.h +++ b/sysdeps/unix/sysv/linux/microblaze/sys/user.h @@ -19,6 +19,8 @@ #ifndef _SYS_USER_H # define _SYS_USER_H 1 +#include + /* The whole purpose of this file is for GDB and GDB only. Don't read too much into it. Don't use it for anything other than GDB unless you know what you are doing. */ diff --git a/sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h b/sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h index a62ed164e52..9ca7a81dd21 100644 --- a/sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h +++ b/sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h @@ -19,8 +19,7 @@ #ifndef __stack_t_defined #define __stack_t_defined 1 -#define __need_size_t -#include +#include /* Structure describing a signal stack. */ typedef struct diff --git a/sysdeps/unix/sysv/linux/mips/sys/user.h b/sysdeps/unix/sysv/linux/mips/sys/user.h index 1eb336a0940..400688c4741 100644 --- a/sysdeps/unix/sysv/linux/mips/sys/user.h +++ b/sysdeps/unix/sysv/linux/mips/sys/user.h @@ -18,8 +18,10 @@ #ifndef _SYS_USER_H #define _SYS_USER_H 1 +#include +#include + #include -#include /* The whole purpose of this file is for GDB and GDB only. Don't read too much into it. Don't use it for anything other than GDB unless diff --git a/sysdeps/unix/sysv/linux/nios2/sys/user.h b/sysdeps/unix/sysv/linux/nios2/sys/user.h index 17d48d2c286..883f9efe498 100644 --- a/sysdeps/unix/sysv/linux/nios2/sys/user.h +++ b/sysdeps/unix/sysv/linux/nios2/sys/user.h @@ -19,6 +19,8 @@ #ifndef _SYS_USER_H #define _SYS_USER_H 1 +#include + /* The whole purpose of this file is for GDB and GDB only. Don't read too much into it. Don't use it for anything other than GDB unless you know what you are doing. */ diff --git a/sysdeps/unix/sysv/linux/powerpc/sys/user.h b/sysdeps/unix/sysv/linux/powerpc/sys/user.h index 71db79c0193..d22634e108e 100644 --- a/sysdeps/unix/sysv/linux/powerpc/sys/user.h +++ b/sysdeps/unix/sysv/linux/powerpc/sys/user.h @@ -16,10 +16,10 @@ . */ #ifndef _SYS_USER_H - #define _SYS_USER_H 1 -#include + #include +#include #include diff --git a/sysdeps/unix/sysv/linux/s390/sys/user.h b/sysdeps/unix/sysv/linux/s390/sys/user.h index bc88aae11e6..93c095f864a 100644 --- a/sysdeps/unix/sysv/linux/s390/sys/user.h +++ b/sysdeps/unix/sysv/linux/s390/sys/user.h @@ -18,6 +18,8 @@ #ifndef _SYS_USER_H #define _SYS_USER_H 1 +#include + /* The whole purpose of this file is for GDB and GDB only. Don't read too much into it. Don't use it for anything other than GDB unless you know what you are doing. */ diff --git a/sysdeps/unix/sysv/linux/scsi/sg.h b/sysdeps/unix/sysv/linux/scsi/sg.h index aae939973dc..639bd972bfc 100644 --- a/sysdeps/unix/sysv/linux/scsi/sg.h +++ b/sysdeps/unix/sysv/linux/scsi/sg.h @@ -26,9 +26,7 @@ #define _SCSI_SG_H 1 #include -#define __need_size_t -#include - +#include /* New interface introduced in the 3.x SG drivers follows */ diff --git a/sysdeps/unix/sysv/linux/sh/sys/user.h b/sysdeps/unix/sysv/linux/sh/sys/user.h index 5d3e04a2f6c..b8bcc8411b2 100644 --- a/sysdeps/unix/sysv/linux/sh/sys/user.h +++ b/sysdeps/unix/sysv/linux/sh/sys/user.h @@ -18,8 +18,11 @@ #ifndef _SYS_USER_H #define _SYS_USER_H 1 +#include +#include + #include -#include + /* asm/ptrace.h polutes the namespace. */ #undef PTRACE_GETREGS diff --git a/sysdeps/unix/sysv/linux/sparc/sys/user.h b/sysdeps/unix/sysv/linux/sparc/sys/user.h index 7aaa170b720..400b89bb118 100644 --- a/sysdeps/unix/sysv/linux/sparc/sys/user.h +++ b/sysdeps/unix/sysv/linux/sparc/sys/user.h @@ -18,7 +18,8 @@ #ifndef _SYS_USER_H #define _SYS_USER_H 1 -#include +#include +#include struct sunos_regs { diff --git a/sysdeps/unix/sysv/linux/sys/sysctl.h b/sysdeps/unix/sysv/linux/sys/sysctl.h index 1ead597244f..c5d06d1a48b 100644 --- a/sysdeps/unix/sysv/linux/sys/sysctl.h +++ b/sysdeps/unix/sysv/linux/sys/sysctl.h @@ -21,8 +21,8 @@ #warning "The header is deprecated and will be removed." #include -#define __need_size_t -#include +#include + /* Prevent more kernel headers than necessary to be included. */ #ifndef _LINUX_KERNEL_H # define _LINUX_KERNEL_H 1 diff --git a/sysdeps/unix/sysv/linux/x86/sys/user.h b/sysdeps/unix/sysv/linux/x86/sys/user.h index fd4646773da..a1de03de83c 100644 --- a/sysdeps/unix/sysv/linux/x86/sys/user.h +++ b/sysdeps/unix/sysv/linux/x86/sys/user.h @@ -18,6 +18,8 @@ #ifndef _SYS_USER_H #define _SYS_USER_H 1 +#include + /* The whole purpose of this file is for GDB and GDB only. Don't read too much into it. Don't use it for anything other than GDB unless you know what you are doing. */ diff --git a/sysvipc/sys/msg.h b/sysvipc/sys/msg.h index b110e16eff5..8bd4f814474 100644 --- a/sysvipc/sys/msg.h +++ b/sysvipc/sys/msg.h @@ -20,20 +20,18 @@ #include -#define __need_size_t -#include - /* Get common definition of System V style IPC. */ #include -/* Get system dependent definition of `struct msqid_ds' and more. */ -#include - /* Define types required by the standard. */ #include #include +#include #include +/* Get system dependent definition of `struct msqid_ds' and more. */ +#include + /* The following System V style IPC functions implement a message queue system. The definition is found in XPG2. */ diff --git a/sysvipc/sys/sem.h b/sysvipc/sys/sem.h index 4ede2dd6ef0..852c8a01932 100644 --- a/sysvipc/sys/sem.h +++ b/sysvipc/sys/sem.h @@ -20,19 +20,18 @@ #include -#define __need_size_t -#include - /* Get common definition of System V style IPC. */ #include -/* Get system dependent definition of `struct semid_ds' and more. */ -#include - +/* Define types required by the standard. */ +#include #ifdef __USE_GNU # include #endif +/* Get system dependent definition of `struct semid_ds' and more. */ +#include + /* The following System V style IPC functions implement a semaphore handling. The definition is found in XPG2. */ diff --git a/sysvipc/sys/shm.h b/sysvipc/sys/shm.h index c1cc2951c4a..f8c57fc56d8 100644 --- a/sysvipc/sys/shm.h +++ b/sysvipc/sys/shm.h @@ -20,21 +20,19 @@ #include -#define __need_size_t -#include - /* Get common definition of System V style IPC. */ #include -/* Get system dependent definition of `struct shmid_ds' and more. */ -#include - /* Define types required by the standard. */ +#include #include #ifdef __USE_XOPEN # include #endif +/* Get system dependent definition of `struct shmid_ds' and more. */ +#include + __BEGIN_DECLS /* The following System V style IPC functions implement a shared memory diff --git a/time/time.h b/time/time.h index c12d5e2fb38..d645492ce91 100644 --- a/time/time.h +++ b/time/time.h @@ -24,17 +24,15 @@ #include -#define __need_size_t -#define __need_NULL -#include - /* This defines CLOCKS_PER_SEC, which is the number of processor clock ticks per second, and possibly a number of other constants. */ #include -/* Many of the typedefs and structs whose official home is this header - may also need to be defined by other headers. */ +/* Typedefs and structs required to be defined by this header. + Many are also defined by other headers. */ +#include #include +#include #include #include diff --git a/wcsmbs/uchar.h b/wcsmbs/uchar.h index f1108edc6a6..1189f05fd07 100644 --- a/wcsmbs/uchar.h +++ b/wcsmbs/uchar.h @@ -25,10 +25,8 @@ #include -#define __need_size_t -#include - #include +#include #include #ifndef __USE_ISOCXX11 diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h index 5e0d65b14e5..71e53c8b4c4 100644 --- a/wcsmbs/wchar.h +++ b/wcsmbs/wchar.h @@ -27,20 +27,16 @@ #include /* Gather machine dependent type support. */ -#include - -#define __need_size_t -#define __need_wchar_t -#define __need_NULL -#include - -#define __need___va_list -#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include #if defined __USE_UNIX98 || defined __USE_XOPEN2K # include diff --git a/wcsmbs/wcstol_l.c b/wcsmbs/wcstol_l.c index 33625c18542..3cf1fba3d20 100644 --- a/wcsmbs/wcstol_l.c +++ b/wcsmbs/wcstol_l.c @@ -17,7 +17,6 @@ License along with the GNU C Library; if not, see . */ -#define __need_wchar_t #include #include diff --git a/wcsmbs/wcstoll_l.c b/wcsmbs/wcstoll_l.c index 63d7d01b768..6a93a754f3f 100644 --- a/wcsmbs/wcstoll_l.c +++ b/wcsmbs/wcstoll_l.c @@ -17,7 +17,6 @@ License along with the GNU C Library; if not, see . */ -#define __need_wchar_t #include #include diff --git a/wcsmbs/wcstoul_l.c b/wcsmbs/wcstoul_l.c index 540ff9c8171..cba6eff09ca 100644 --- a/wcsmbs/wcstoul_l.c +++ b/wcsmbs/wcstoul_l.c @@ -17,7 +17,6 @@ License along with the GNU C Library; if not, see . */ -#define __need_wchar_t #include #include diff --git a/wcsmbs/wcstoull_l.c b/wcsmbs/wcstoull_l.c index aa93c1b06f0..e3eef71ec89 100644 --- a/wcsmbs/wcstoull_l.c +++ b/wcsmbs/wcstoull_l.c @@ -17,7 +17,6 @@ License along with the GNU C Library; if not, see . */ -#define __need_wchar_t #include #include