]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Add bits/types/ wrappers for stddef.h and stdarg.h types.
authorZack Weinberg <zackw@panix.com>
Tue, 28 May 2019 17:59:08 +0000 (13:59 -0400)
committerZack Weinberg <zackw@panix.com>
Wed, 8 Jan 2020 18:41:32 +0000 (13:41 -0500)
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.

107 files changed:
bits/socket.h
bits/types/stack_t.h
debug/wcpcpy_chk.c
dirent/dirent.h
dlfcn/dlfcn.h
grp/grp.h
gshadow/gshadow.h
hurd/hurd/ioctl.h
hurd/hurd/signal.h
hurd/hurd/sigpreempt.h
hurd/hurd/userlink.h
iconv/gconv.h
iconv/iconv.h
iconv/loop.c
iconv/skeleton.c
include/bits/NULL.h [new file with mode: 0644]
include/bits/types/__va_list.h [new file with mode: 0644]
include/bits/types/ptrdiff_t.h [new file with mode: 0644]
include/bits/types/size_t.h [new file with mode: 0644]
include/bits/types/va_list.h [new file with mode: 0644]
include/bits/types/wchar_t.h [new file with mode: 0644]
include/set-hooks.h
include/stdio.h
intl/gettext.c
intl/libintl.h
intl/ngettext.c
libio/bits/types/struct_FILE.h
libio/libio.h
libio/stdio.h
locale/locale.h
malloc/malloc.h
malloc/tst-malloc-thread-fail.c
malloc/tst-malloc_info.c
misc/bits/types/struct_iovec.h
misc/err.h
misc/search.h
misc/sys/mman.h
misc/sys/param.h
misc/syslog.h
posix/glob.h
posix/sched.h
posix/sys/types.h
posix/unistd.h
posix/wordexp.h
pwd/pwd.h
scripts/check-obsolete-constructs.py
shadow/shadow.h
signal/sighold.c
signal/signal.h
signal/sigrelse.c
socket/sys/socket.h
stdio-common/printf.h
stdio-common/tempname.c
stdio-common/tst-vfprintf-user-type.c
stdlib/Makefile
stdlib/alloca.h
stdlib/bits/NULL.h [new file with mode: 0644]
stdlib/bits/types/__va_list.h [new file with mode: 0644]
stdlib/bits/types/ptrdiff_t.h [new file with mode: 0644]
stdlib/bits/types/size_t.h [new file with mode: 0644]
stdlib/bits/types/va_list.h [new file with mode: 0644]
stdlib/bits/types/wchar_t.h [new file with mode: 0644]
stdlib/inttypes.h
stdlib/monetary.h
stdlib/stdlib.h
string/string.h
string/strings.h
string/tst-cmp.c
sunrpc/rpc/netdb.h
sysdeps/generic/ldsodefs.h
sysdeps/htl/bits/types/struct___pthread_attr.h
sysdeps/mach/hurd/bits/socket.h
sysdeps/nptl/libc-lock.h
sysdeps/nptl/libc-lockP.h
sysdeps/posix/sigignore.c
sysdeps/posix/sigset.c
sysdeps/posix/waitid.c
sysdeps/unix/sysv/linux/aarch64/sys/user.h
sysdeps/unix/sysv/linux/alpha/sys/user.h
sysdeps/unix/sysv/linux/arm/sys/user.h
sysdeps/unix/sysv/linux/bits/sigcontext.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/ia64/sys/user.h
sysdeps/unix/sysv/linux/m68k/sys/user.h
sysdeps/unix/sysv/linux/microblaze/sys/user.h
sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h
sysdeps/unix/sysv/linux/mips/sys/user.h
sysdeps/unix/sysv/linux/nios2/sys/user.h
sysdeps/unix/sysv/linux/powerpc/sys/user.h
sysdeps/unix/sysv/linux/s390/sys/user.h
sysdeps/unix/sysv/linux/scsi/sg.h
sysdeps/unix/sysv/linux/sh/sys/user.h
sysdeps/unix/sysv/linux/sparc/sys/user.h
sysdeps/unix/sysv/linux/sys/sysctl.h
sysdeps/unix/sysv/linux/x86/sys/user.h
sysvipc/sys/msg.h
sysvipc/sys/sem.h
sysvipc/sys/shm.h
time/time.h
wcsmbs/uchar.h
wcsmbs/wchar.h
wcsmbs/wcstol_l.c
wcsmbs/wcstoll_l.c
wcsmbs/wcstoul_l.c
wcsmbs/wcstoull_l.c

index e72dcfda40bad1c329ee141e6c2f8768a4c9761b..c844429ab85bb1e7df524928a0d087714caf7f37 100644 (file)
 # error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
 #endif
 
-#define        __need_size_t
-#include <stddef.h>
-
 #include <bits/wordsize.h>
 #include <bits/types.h>
+#include <bits/types/size_t.h>
 #include <bits/types/socklen_t.h>
 
 /* Types of sockets.  */
index a5aac932bbe193ba68f5cc80721f2a505e5b59b4..0cd11ea59c4c0635f9aa59762ba982029dcd84b2 100644 (file)
@@ -19,8 +19,7 @@
 #ifndef __stack_t_defined
 #define __stack_t_defined 1
 
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 
 /* Structure describing a signal stack.  */
 typedef struct
index ff489b4e46113c7894336d084b8878a37141715d..0dbdedb41cbec46f152348984def4a07f0b72b83 100644 (file)
@@ -17,8 +17,6 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <wchar.h>
-
-#define __need_ptrdiff_t
 #include <stddef.h>
 
 
index 0886b6d30d194c005545e5125b0f0c9b8800bdbc..4dca152e535e8e5eed50c06fb2b9bd00c175e635 100644 (file)
@@ -233,8 +233,7 @@ extern int dirfd (DIR *__dirp) __THROW __nonnull ((1));
 #  endif
 # endif
 
-# define __need_size_t
-# include <stddef.h>
+# include <bits/types/size_t.h>
 
 /* Scan the directory DIR, calling SELECTOR on each directory entry.
    Entries for which SELECT returns nonzero are individually malloc'd,
index c629fc7f42032a9fba4362baf26486e029214280..5eb2f6854212d16667500cc9e5af1bb0b60d67c4 100644 (file)
@@ -20,8 +20,8 @@
 #define        _DLFCN_H 1
 
 #include <features.h>
-#define __need_size_t
-#include <stddef.h>
+
+#include <bits/types/size_t.h>
 
 /* Collect various system dependent definitions and declarations.  */
 #include <bits/dlfcn.h>
index 5ef235ef210dd38ab8fbf1d08fffb568e18feaaf..a2c20a493f7dc6d30636a5d8fd642bab11f0b23d 100644 (file)
--- a/grp/grp.h
+++ b/grp/grp.h
@@ -27,9 +27,7 @@
 __BEGIN_DECLS
 
 #include <bits/types.h>
-
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 
 /* 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 <stddef.h>
-
 /* Set the group set for the current user to GROUPS (N of them).  */
 extern int setgroups (size_t __n, const __gid_t *__groups) __THROW;
 
index 9bcb473ce56942dd4be5172371810cb6532c1995..8dec35d4f8c25eb1921f2b4fe8f45afe64a5d82c 100644 (file)
@@ -23,9 +23,7 @@
 #include <features.h>
 #include <paths.h>
 #include <bits/types/FILE.h>
-
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 
 /* Path to the user database files.  */
 #define        GSHADOW _PATH_GSHADOW
index bc136d8b7fd3a595026efd97504476cf8efe7b64..83c3e8c13b04499360f29d11bd27d9bb1521fcb1 100644 (file)
@@ -19,8 +19,6 @@
 #ifndef        _HURD_IOCTL_H
 #define        _HURD_IOCTL_H   1
 
-#define        __need___va_list
-#include <stdarg.h>
 #include <bits/ioctls.h>
 #include <mach/port.h>
 
index 6583dcb5b1e9fa1075d0f7a4d7d818bcdec4c63e..22de146adbd3f4e93068b77d1eaee8bb71970ad6 100644 (file)
 #define        _HURD_SIGNAL_H  1
 #include <features.h>
 
-#define __need_size_t
-#define __need_NULL
-#include <stddef.h>
-
 #include <mach/mach_types.h>
 #include <mach/port.h>
 #include <mach/message.h>
@@ -34,6 +30,7 @@
 #include <bits/types/error_t.h>
 #include <bits/types/stack_t.h>
 #include <bits/types/sigset_t.h>
+#include <bits/types/size_t.h>
 #include <bits/sigaction.h>
 #include <hurd/msg.h>
 
@@ -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
index 2591c472d34b6c3527887bab8d8b0409d9996c17..42d5e8b27c6e91cb20a7eb83ec154220f444acc8 100644 (file)
@@ -19,8 +19,7 @@
 #ifndef        _HURD_SIGPREEMPT_H
 
 #define        _HURD_SIGPREEMPT_H      1
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 #include <errno.h>
 #include <bits/types/error_t.h>
 #include <signal.h>            /* For sighandler_t, SIG_ERR.  */
index 7c008a81bce5006e120f833f94a57a097ca79d18..1b8cce964905da526b1f639deb28705a747a6f9d 100644 (file)
    <https://www.gnu.org/licenses/>.  */
 
 #ifndef        _HURD_USERLINK_H
-
 #define        _HURD_USERLINK_H        1
-#include <features.h>
 
-#define __need_NULL
-#include <stddef.h>
+#include <features.h>
+#include <setjmp.h>
 
 #if defined __USE_EXTERN_INLINES && defined _LIBC
 # if IS_IN (libc)
 #  include <hurd/signal.h>
 # endif
 #endif
-#include <setjmp.h>
-
 
 /* 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
index 6add596642723e870e4e0cdbfe6a62e742184afe..041989e595ffc076ec3a4ba79fd30d5aef0a17fe 100644 (file)
 
 #include <features.h>
 #include <bits/types/__mbstate_t.h>
+#include <bits/types/size_t.h>
+#include <bits/types/wchar_t.h>
 #include <bits/types/wint_t.h>
 
-#define __need_size_t
-#define __need_wchar_t
-#include <stddef.h>
-
 /* ISO 10646 value used to signal invalid value.  */
 #define __UNKNOWN_10646_CHAR   ((wchar_t) 0xfffd)
 
index a457001c0cafbb3f6dc23a181ad3bf7b553f17df..b421cb07c152890497f9a454f0be2a116830b5f1 100644 (file)
@@ -19,8 +19,7 @@
 #define _ICONV_H       1
 
 #include <features.h>
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 
 
 __BEGIN_DECLS
index 9f7570d591564f4b22043cd075ebe0f5dcc4cf63..cfae4a5e62aeec6d7fc123677b9f23f6379f8384 100644 (file)
@@ -54,7 +54,6 @@
 #include <string.h>
 #include <wchar.h>
 #include <sys/param.h>         /* For MIN.  */
-#define __need_size_t
 #include <stddef.h>
 #include <libc-diag.h>
 
index 1dc642e2fc97b30fb11902edc0e43838f2375296..0ca3498694c971a22ed648c768427abd41a58faf 100644 (file)
 #include <assert.h>
 #include <iconv/gconv_int.h>
 #include <string.h>
-#define __need_size_t
-#define __need_NULL
 #include <stddef.h>
 
 #ifndef STATIC_GCONV
diff --git a/include/bits/NULL.h b/include/bits/NULL.h
new file mode 100644 (file)
index 0000000..0584572
--- /dev/null
@@ -0,0 +1 @@
+#include <stdlib/bits/NULL.h>
diff --git a/include/bits/types/__va_list.h b/include/bits/types/__va_list.h
new file mode 100644 (file)
index 0000000..436e6ed
--- /dev/null
@@ -0,0 +1 @@
+#include <stdlib/bits/types/__va_list.h>
diff --git a/include/bits/types/ptrdiff_t.h b/include/bits/types/ptrdiff_t.h
new file mode 100644 (file)
index 0000000..d16c0d3
--- /dev/null
@@ -0,0 +1 @@
+#include <stdlib/bits/types/ptrdiff_t.h>
diff --git a/include/bits/types/size_t.h b/include/bits/types/size_t.h
new file mode 100644 (file)
index 0000000..feaa043
--- /dev/null
@@ -0,0 +1 @@
+#include <stdlib/bits/types/size_t.h>
diff --git a/include/bits/types/va_list.h b/include/bits/types/va_list.h
new file mode 100644 (file)
index 0000000..dbc749a
--- /dev/null
@@ -0,0 +1 @@
+#include <stdlib/bits/types/va_list.h>
diff --git a/include/bits/types/wchar_t.h b/include/bits/types/wchar_t.h
new file mode 100644 (file)
index 0000000..343bd58
--- /dev/null
@@ -0,0 +1 @@
+#include <stdlib/bits/types/wchar_t.h>
index dba382c3a8c99ef6fc21cf35d67c762e31cc3fd2..90db3b3b8462b49426ee561439f0e4dd0e42cdf1 100644 (file)
@@ -19,8 +19,7 @@
 #ifndef _SET_HOOKS_H
 #define _SET_HOOKS_H 1
 
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 #include <sys/cdefs.h>
 #include <libc-symbols.h>
 
index dffa7765dd66a2bd830124e3adea909d97ba9e41..5cd38eaeedfdd92bfd4a81902442cc2a97f30ed0 100644 (file)
@@ -84,9 +84,7 @@ libc_hidden_proto (__isoc99_vfscanf)
 extern FILE *__new_tmpfile (void);
 extern FILE *__old_tmpfile (void);
 
-#  define __need_size_t
-#  include <stddef.h>
-
+#  include <bits/types/size_t.h>
 #  include <bits/types/wint_t.h>
 
 /* Generate a unique file name (and possibly open it).  */
index b8c98ae19c43ae378635f4aaf3e4a6b12c92ddf4..da2ae6c3a5193721c45e6283ac174703a0555e6f 100644 (file)
 # include <config.h>
 #endif
 
-#ifdef _LIBC
-# define __need_NULL
-# include <stddef.h>
-#else
-# include <stdlib.h>           /* Just for NULL.  */
-#endif
+#include <stddef.h>            /* Just for NULL.  */
 
 #include "gettextP.h"
 #ifdef _LIBC
index 2fd0a31e8e6149eb15d30650456176ba833cdac0..e4b5c725877d94f1031e0b2c47103fd4bbf2f6b1 100644 (file)
@@ -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 <stddef.h>
-
 /* We need LC_MESSAGES for `dgettext'.  */
 # include <locale.h>
 
@@ -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)
index 47f93ad698d99eada78e07ac41a623711131eeaf..8fcf908cc92ec3ebf1090bdf418070700e1d0cde 100644 (file)
 # include <config.h>
 #endif
 
-#ifdef _LIBC
-# define __need_NULL
-# include <stddef.h>
-#else
-# include <stdlib.h>           /* Just for NULL.  */
-#endif
+#include <stddef.h>            /* Just for NULL.  */
 
 #include "gettextP.h"
 #ifdef _LIBC
index 06feadf3123983f11bac5f2b64632762fb69bb69..881c2339819d766bf1e469f84ec5765d91cfe212 100644 (file)
@@ -31,6 +31,7 @@
 #endif
 
 #include <bits/types.h>
+#include <bits/types/size_t.h>
 
 struct _IO_FILE;
 struct _IO_marker;
index 3781b296e3f53d4343e7079cc7fcb6f866d195b0..37bc8f25c1f6e03865793a471f7105cefc21e0de 100644 (file)
 # error "Someone forgot to include stdio-lock.h"
 #endif
 
-#define __need_wchar_t
-#include <stddef.h>
-
 #include <bits/types/__mbstate_t.h>
+#include <bits/types/wchar_t.h>
 #include <bits/types/wint_t.h>
 #include <gconv.h>
 
index cf99970f90b1c286ebead9c175751e0bc3f05230..1a2cd4046bd5f33494e937db882ab64ded0f2ca4 100644 (file)
 
 __BEGIN_DECLS
 
-#define __need_size_t
-#define __need_NULL
-#include <stddef.h>
-
-#define __need___va_list
-#include <stdarg.h>
-
 #include <bits/types.h>
 #include <bits/types/__fpos_t.h>
 #include <bits/types/__fpos64_t.h>
 #include <bits/types/__FILE.h>
+#include <bits/types/__va_list.h>
 #include <bits/types/FILE.h>
 #include <bits/types/struct_FILE.h>
+#include <bits/types/size_t.h>
+#include <bits/NULL.h>
 
 #ifdef __USE_GNU
 # include <bits/types/cookie_io_functions_t.h>
 #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 <stdarg.h>
-# endif
+# include <bits/types/va_list.h>
 #endif
 
 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
index b013c8bb0240151dbbeb3ce9e8fa06c13cd6b5ab..0ef9a391a6e5eb74214d229a0f88b1eb11443252 100644 (file)
@@ -24,9 +24,8 @@
 
 #include <features.h>
 
-#define __need_NULL
-#include <stddef.h>
 #include <bits/locale.h>
+#include <bits/NULL.h>
 
 __BEGIN_DECLS
 
index 0c7626442136c0869458b57e71ac9b02d76a6cb5..85985248f9858f7ddc3536fefcc6be48837ac454 100644 (file)
 #define _MALLOC_H 1
 
 #include <features.h>
-#include <stddef.h>
-#include <stdio.h>
+
+#include <bits/NULL.h>
+#include <bits/types/size_t.h>
+#include <bits/types/ptrdiff_t.h>
+#include <bits/types/FILE.h>
 
 #ifdef _LIBC
 # define __MALLOC_HOOK_VOLATILE
index 30a154f2ee0b172104323fd79e2d790c2b2b0315..226e551d0f56400e0a2630c40ac5ca63adc1c398 100644 (file)
@@ -20,6 +20,7 @@
    related to allocation failures, notably switching to a different
    arena, and falling back to mmap (via sysmalloc).  */
 
+#include <stddef.h>
 #include <errno.h>
 #include <malloc.h>
 #include <pthread.h>
index d92cccff8b437ebd34fe4cfdfa547bbfc2a393b4..de97bff8cb63919cab0cda2a3de1ab14de53e1e5 100644 (file)
@@ -22,6 +22,7 @@
 #include <array_length.h>
 #include <malloc.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <support/support.h>
 #include <support/xthread.h>
 
index 793258b4811ec9c5660751d0e92663c599c55a69..c92ae0d91a6120076855d862d1e58733547462cc 100644 (file)
@@ -19,8 +19,7 @@
 #ifndef __iovec_defined
 #define __iovec_defined 1
 
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 
 /* Structure for scatter/gather I/O.  */
 struct iovec
index f6fd72945f746cf28c1fe4163ad78ca9dd9ceaaf..5503c4e175c7fed2655a6b8619bf98ff056ff86e 100644 (file)
 
 #include <features.h>
 
-#define        __need___va_list
-#include <stdarg.h>
-#ifndef        __GNUC_VA_LIST
-# define __gnuc_va_list        void *
-#endif
+#include <bits/types/__va_list.h>
 
 __BEGIN_DECLS
 
index a075570179ef6b0f09cd029f4c097f78bb7b1adb..3b5c03f4f1d009d2582819cb8d2164203f68c7e5 100644 (file)
@@ -21,8 +21,7 @@
 
 #include <features.h>
 
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 
 __BEGIN_DECLS
 
index 01cc6407045b2a878d00bf0ffece6bcae459555c..38f2e37b842feef1aea795f3ee5f65fcd3836a04 100644 (file)
 #define        _SYS_MMAN_H     1
 
 #include <features.h>
-#include <bits/types.h>
-
-#define __need_size_t
-#include <stddef.h>
 
-#include <bits/types/off_t.h>
+#include <bits/types.h>
 #include <bits/types/mode_t.h>
+#include <bits/types/off_t.h>
+#include <bits/types/size_t.h>
 
 #include <bits/mman.h>
 
index d7c319b1571493c97b2e742eb37f88b293748de7..eca50cf9bf48a67d8cd539f8402497a365810789 100644 (file)
 #ifndef _SYS_PARAM_H
 #define _SYS_PARAM_H    1
 
-#define __need_NULL
-#include <stddef.h>
+#include <features.h>
 
 #include <sys/types.h>
 #include <limits.h>
 #include <endian.h>                     /* Define BYTE_ORDER et al.  */
 #include <signal.h>                     /* Define NSIG.  */
+#include <bits/NULL.h>
 
 /* This file defines some things in system-specific ways.  */
 #include <bits/param.h>
index 406133ba71ddcb47d9dbbbdaa2dba9303a275cac..f7b7a6743fd9f4d3b136cfbfbdcf2d123ab54bf6 100644 (file)
@@ -33,8 +33,7 @@
 #define _SYSLOG_H 1
 
 #include <features.h>
-#define __need___va_list
-#include <stdarg.h>
+#include <bits/types/__va_list.h>
 
 /* This file defines _PATH_LOG.  */
 #include <bits/syslog-path.h>
index e647ba813a1615d250cf5930baf90717ac9b1880..c913238a30c4485f9e14f014c698023e0abd642c 100644 (file)
@@ -29,8 +29,7 @@ __BEGIN_DECLS
    a different purpose.  */
 
 #if defined __USE_XOPEN || defined __USE_XOPEN2K8
-# define __need_size_t
-# include <stddef.h>
+#include <bits/types/size_t.h>
 typedef size_t __gsize_t;
 #elif defined __SIZE_TYPE__
 typedef __SIZE_TYPE__ __gsize_t;
index bb7e727da0877117e8ad1e104da40f2aeeccaec7..d4465256c621938dc78651cfb387052a0b9d1ea8 100644 (file)
 #include <features.h>
 
 /* Get type definitions.  */
+#include <bits/NULL.h>
 #include <bits/types.h>
-
-#define __need_size_t
-#define __need_NULL
-#include <stddef.h>
-
+#include <bits/types/pid_t.h>
+#include <bits/types/size_t.h>
 #include <bits/types/time_t.h>
 #include <bits/types/struct_timespec.h>
 #ifndef __USE_XOPEN2K
 # include <time.h>
 #endif
-#include <bits/types/pid_t.h>
 
 /* Get system specific constant and data structure definitions.  */
 #include <bits/sched.h>
index ba8e72a2150b3fadeafdd0bd5bd7d6672ab3eaf4..64fa01011456d63d2498c46525f313673ec7b640 100644 (file)
@@ -28,9 +28,6 @@ __BEGIN_DECLS
 
 #include <bits/types.h>
 
-#define __need_size_t
-#include <stddef.h>
-
 #include <bits/types/blkcnt_t.h>
 #include <bits/types/clockid_t.h>
 #include <bits/types/dev_t.h>
@@ -42,6 +39,7 @@ __BEGIN_DECLS
 #include <bits/types/nlink_t.h>
 #include <bits/types/off_t.h>
 #include <bits/types/pid_t.h>
+#include <bits/types/size_t.h>
 #include <bits/types/ssize_t.h>
 #include <bits/types/time_t.h>
 #include <bits/types/timer_t.h>
index e5958e3d36ce6529e0bda36c890b5332b9d78cbd..386b4e59a33340ae9a30a0f6f1a5f79c4b3d3a28 100644 (file)
@@ -214,13 +214,11 @@ __BEGIN_DECLS
 
 /* All functions that are not declared anywhere else.  */
 
+#include <bits/NULL.h>
 #include <bits/types.h>
+#include <bits/types/size_t.h>
 #include <bits/types/ssize_t.h>
 
-#define        __need_size_t
-#define __need_NULL
-#include <stddef.h>
-
 #if defined __USE_XOPEN || defined __USE_XOPEN2K
 /* The Single Unix specification says that some more types are
    available here.  */
index 4e52ace50f311b3c70d3b088739fb0826c2ca2fe..f94796cb24e6775551344ad30cee48b5bee49755 100644 (file)
@@ -19,8 +19,7 @@
 #define        _WORDEXP_H      1
 
 #include <features.h>
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 
 __BEGIN_DECLS
 
index 7f490f57debb629f4164ec15d5adb60d10745263..8f49ea22f01a3afd198461a40885b2856786ee96 100644 (file)
--- a/pwd/pwd.h
+++ b/pwd/pwd.h
@@ -27,9 +27,7 @@
 __BEGIN_DECLS
 
 #include <bits/types.h>
-
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 
 #if defined __USE_XOPEN || defined __USE_XOPEN2K
 /* The Single Unix specification says that some more types are
index 8b52463cfb07d7c194bc0b2c4fe87004e2b247c1..5d4faac0f0b7b38ae1d766c5bedf60ac98cd6c0b 100755 (executable)
@@ -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
index cb17ef62e349d13247313f493c1923e9b9398e45..20bcde32e4d27a47a2e78de16391bca476cb658e 100644 (file)
 
 #include <paths.h>
 
-#define __need_size_t
-#include <stddef.h>
-
 #include <bits/types/FILE.h>
+#include <bits/types/size_t.h>
 
 /* Paths to the user database files.  */
 #define        SHADOW _PATH_SHADOW
index 9fe97912811c021ea72c111f1fcfe761b849754a..53f9eea307705637bd0f83fa20d7d613d8a72fd8 100644 (file)
@@ -17,7 +17,6 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define __need_NULL
 #include <stddef.h>
 #include <signal.h>
 
index f7f50c82d4fd67823604e070cb15d2944feac733..ae40b903914e8db37a17acf50d98ea3b06a5c62e 100644 (file)
@@ -289,9 +289,7 @@ extern int sigreturn (struct sigcontext *__scp) __THROW;
 
 
 #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-# define __need_size_t
-# include <stddef.h>
-
+# include <bits/types/size_t.h>
 # include <bits/types/stack_t.h>
 # if defined __USE_XOPEN || defined __USE_XOPEN2K8
 /* This will define `ucontext_t' and `mcontext_t'.  */
index ad257714df136add313f4c3a3ae0be7ee502c927..e4bc638e69192f34dcedd07cc77092536477dc70 100644 (file)
@@ -17,7 +17,6 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define __need_NULL
 #include <stddef.h>
 #include <signal.h>
 
index 7780c00ecbd25e2cb8a78f667d28006d71b716f2..0c158d1e931ec05c1b81311fe25d867e63fb8936 100644 (file)
@@ -23,9 +23,8 @@
 
 __BEGIN_DECLS
 
+#include <bits/types/size_t.h>
 #include <bits/types/struct_iovec.h>
-#define        __need_size_t
-#include <stddef.h>
 
 /* This operating system-specific header file defines the SOCK_*, PF_*,
    AF_*, MSG_*, SOL_*, and SO_* constants, and the `struct sockaddr',
index ad3c8a4254907be5b7229e2b0b28ce0d02df9a94..1ac342d0e5fe69ffaac00a3e8915728485ab033b 100644 (file)
 __BEGIN_DECLS
 
 #include <bits/types/FILE.h>
-
-#define        __need_size_t
-#define __need_wchar_t
-#include <stddef.h>
-
-#include <stdarg.h>
+#include <bits/types/size_t.h>
+#include <bits/types/wchar_t.h>
+#include <bits/types/__va_list.h>
 
 
 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
index fac978d61859ac7d88ec321fb7337b58e9f24a00..07bbf8d06851bce5f3bd0c84a533f3cdd112771b 100644 (file)
@@ -15,7 +15,6 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define __need_size_t
 #include <stddef.h>
 #include <stdio.h>
 #include <errno.h>
index 6c840fe04b382f053f27fa1dd542962c91a603a8..cf5c483b75a5538f6620117e047ec3c4d4e52610 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <locale.h>
 #include <printf.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index 45214b59e4ddb79b2982e76dfc8d227e6caba8db..6f8e6ba31d26ed29a297e426422948ba6f249cd7 100644 (file)
@@ -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                                                  \
index bd44688720840981438ff74d5734836c32f37b0f..a5b0b7a7bf9bbed5f701159ee91a715b5b431bbb 100644 (file)
@@ -20,8 +20,7 @@
 
 #include <features.h>
 
-#define        __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 
 __BEGIN_DECLS
 
diff --git a/stdlib/bits/NULL.h b/stdlib/bits/NULL.h
new file mode 100644 (file)
index 0000000..79285bd
--- /dev/null
@@ -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 <stddef.h>
+
+#endif
diff --git a/stdlib/bits/types/__va_list.h b/stdlib/bits/types/__va_list.h
new file mode 100644 (file)
index 0000000..e3c53c3
--- /dev/null
@@ -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 <stdarg.h>
+#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 (file)
index 0000000..23a8b98
--- /dev/null
@@ -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 <stddef.h>
+#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 (file)
index 0000000..e151458
--- /dev/null
@@ -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 <stddef.h>
+#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 (file)
index 0000000..6f3acac
--- /dev/null
@@ -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 <bits/types/__va_list.h>
+
+/* 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 (file)
index 0000000..1e44e15
--- /dev/null
@@ -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 <stddef.h>
+#undef __need_wchar_t
+
+#endif
index c5ec307c5c63fbf10fdc8ae9ff88c98a3e762ffe..f42cea5d80b8982077aa70167c8d98798ec03c15 100644 (file)
@@ -32,8 +32,7 @@
 #elif defined __WCHAR_TYPE__
 typedef __WCHAR_TYPE__ __gwchar_t;
 #else
-# define __need_wchar_t
-# include <stddef.h>
+#include <bits/types/wchar_t.h>
 typedef wchar_t __gwchar_t;
 #endif
 
index 8f268a0060a328336eb406df1b0b6692065ad34c..80f4ea107c472efd0058e3d844704be93a78c574 100644 (file)
@@ -22,9 +22,8 @@
 #include <features.h>
 
 /* Get needed types.  */
-#define __need_size_t
-#include <stddef.h>
 #include <bits/types.h>
+#include <bits/types/size_t.h>
 #include <bits/types/ssize_t.h>
 
 __BEGIN_DECLS
index 9f1f1b80e3dfaf892dc50a9cdfa068fc2312dbd2..3e3351ef71d7aea3511aa1ea1c0d6797f4aec409 100644 (file)
  */
 
 #ifndef        _STDLIB_H
+#define        _STDLIB_H       1
 
 #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
 #include <bits/libc-header-start.h>
 
-/* Get size_t, wchar_t and NULL from <stddef.h>.  */
-#define __need_size_t
-#define __need_wchar_t
-#define __need_NULL
-#include <stddef.h>
+#include <bits/types/size_t.h>
+#include <bits/types/wchar_t.h>
+#include <bits/NULL.h>
 
 __BEGIN_DECLS
 
-#define        _STDLIB_H       1
-
 #if (defined __USE_XOPEN || defined __USE_XOPEN2K8) && !defined _SYS_WAIT_H
 /* XPG requires a few symbols from <sys/wait.h> being defined.  */
 # include <bits/waitflags.h>
index a0f2860cc2f992862b7fcc380a9638bd0f595e2c..234ee91d4a326cc81cd674bb2324a9fba5a61e16 100644 (file)
 
 __BEGIN_DECLS
 
-/* Get size_t and NULL from <stddef.h>.  */
-#define        __need_size_t
-#define        __need_NULL
-#include <stddef.h>
+#include <bits/types/size_t.h>
+#include <bits/NULL.h>
 
 /* Tell the caller that we provide correct C++ prototypes.  */
 #if defined __cplusplus && (__GNUC_PREREQ (4, 4) \
index 87882ec0a75cfa080d56b3ad0abe00246a571c59..65dfca89357b92531378bd7e72d6904e86b4f247 100644 (file)
@@ -19,8 +19,7 @@
 #define        _STRINGS_H      1
 
 #include <features.h>
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 
 /* Tell the caller that we provide correct C++ prototypes.  */
 #if defined __cplusplus && __GNUC_PREREQ (4, 4)
index 13af0fcb83ecdaa2f872d1c161dfd948166a7c6c..5b2a72068f30ff34181ebf3f1636aa1e2643017e 100644 (file)
@@ -23,6 +23,7 @@
 #include <limits.h>
 #include <malloc.h>
 #include <stdbool.h>
+#include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
index 529a4ada218a25de05296ac623dc1d371ee588f2..a5aa340e1a011ed8f9d4980d8685b22521795b9b 100644 (file)
@@ -38,8 +38,7 @@
 
 #include <features.h>
 
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 
 __BEGIN_DECLS
 
index 497938ffa202ef260d942d153159a97550ac7fa1..0ca43f3ca11b8603a2b8324288d6e5093851ec60 100644 (file)
@@ -22,8 +22,6 @@
 #include <features.h>
 
 #include <stdbool.h>
-#define __need_size_t
-#define __need_NULL
 #include <stddef.h>
 #include <string.h>
 #include <stdint.h>
index 482e10b2546006ebe9553f7a71eacc20669858ed..7558db185e92666588869ae7370fd2c459f1d787 100644 (file)
 #ifndef _BITS_TYPES_STRUCT___PTHREAD_ATTR
 #define _BITS_TYPES_STRUCT___PTHREAD_ATTR      1
 
+#include <bits/types/size_t.h>
 #include <bits/types/struct_sched_param.h>
 
-#define __need_size_t
-#include <stddef.h>
-
 enum __pthread_detachstate;
 enum __pthread_inheritsched;
 enum __pthread_contentionscope;
index 06a731184b4ecddbfc7309215d524f6139b76109..f7c6f562988abb336ccf915b8d856357f68d5eac 100644 (file)
 # error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
 #endif
 
-#define        __need_size_t
-#include <stddef.h>
 
-#include <bits/wordsize.h>
 #include <sys/types.h>
+#include <bits/types/size_t.h>
 #include <bits/types/socklen_t.h>
+#include <bits/wordsize.h>
 
 /* Types of sockets.  */
 enum __socket_type
index bfeee32eaff1ebd3574d15f456a7631bbe31fe52..bf61365557645a04f64a44e51984818af8961813 100644 (file)
@@ -20,7 +20,6 @@
 #define _LIBC_LOCK_H 1
 
 #include <pthread.h>
-#define __need_NULL
 #include <stddef.h>
 
 
index 86d903dddc3af92da6411df8bc664942d8e4df06..15156df7ac6d17079c7bca52ec5d7cf2e2a861a1 100644 (file)
@@ -20,7 +20,6 @@
 #define _LIBC_LOCKP_H 1
 
 #include <pthread.h>
-#define __need_NULL
 #include <stddef.h>
 
 
index 33bf67aacaaf1a9d0817aab08cc13e2473a4d789..0172094e44d7caa9606ed3aa83e4e79a3602d567 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#define __need_NULL
 #include <stddef.h>
 #include <signal.h>
-#include <string.h>    /* For the real memset prototype.  */
 #include <sigsetops.h>
 
 int
index df965d1c637e91b89989a943b1dd7a9cd60ed63d..fea6fbf166df99cfb1f36444f244a8a227182cbd 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#define __need_NULL
 #include <stddef.h>
 #include <signal.h>
-#include <string.h>    /* For the real memset prototype.  */
 #include <sigsetops.h>
 
 /* Set the disposition for SIG.  */
index f7520767356f53933d8fffc9bdac6bd7cc1202f1..faca7fd4dce0e8d55fb70d1815599e64f8332e2e 100644 (file)
@@ -20,7 +20,6 @@
 #include <assert.h>
 #include <errno.h>
 #include <signal.h>
-#define __need_NULL
 #include <stddef.h>
 #include <sys/wait.h>
 #include <sys/types.h>
index 2288220fe1f8f3349ca5f43ae691bf66a9578808..dab30192a14b974b37659c4f81454108a9eaa5b9 100644 (file)
@@ -19,6 +19,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H    1
 
+#include <features.h>
+
 struct user_regs_struct
 {
   unsigned long long regs[31];
index 9a0179ff6d36029660aea7568417d73cfb2a9fac..c1a0f1915f05cbe476d3c1148d01276b6041154b 100644 (file)
 #ifndef _SYS_USER_H
 #define _SYS_USER_H    1
 
+#include <features.h>
+#include <bits/types/size_t.h>
+
+#include <asm/reg.h>
+
 /* 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 <asm/reg.h>
-#include <stddef.h>
-
 struct user
 {
   unsigned long        int regs[EF_SIZE / 8 + 32];     /* integer and fp regs */
index 555bfde3d70421b7237c0ceff3402e3ee0a53b85..77a28aebb1691b2c1a4939177898c1da6cb5b9b0 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H    1
 
+#include <features.h>
+
 /* 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.  */
index 83b173872ac6579b81970a7782833568deedb170..79667e4339dff8b014e8e12be016cacf468c4f60 100644 (file)
 
 #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 <asm/sigcontext.h>
 
-/* The Linux kernel headers redefine NULL wrongly, so cleanup afterwards.  */
-# define __need_NULL
-# include <stddef.h>
+/* 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 <bits/NULL.h>
 #endif
 
 #endif /* bits/sigcontext.h */
index f275b33499333b5e98245dcd770dbb85ba77c6e4..65c72198ef83ee5616186bef093ee150892f8e70 100644 (file)
 # error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
 #endif
 
-#define __need_size_t
-#include <stddef.h>
 
 #include <sys/types.h>
+#include <bits/types/size_t.h>
 #include <bits/types/socklen_t.h>
 
 /* Get the architecture-dependent definition of enum __socket_type.  */
index 82b9e496a3082c7a7b2c1d2569afc53e85cf8045..6f40ecbd7ff1c95bf07aff5887717c16a7209cc9 100644 (file)
@@ -19,8 +19,7 @@
 #ifndef __stack_t_defined
 #define __stack_t_defined 1
 
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 
 /* Structure describing a signal stack.  */
 typedef struct
index 54f23166579e0958e92d31831fd3ebaa1942544e..252eff321c90ff3e35263fd4e90b0dd06d47ae1a 100644 (file)
 # error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
 #endif
 
-#define __need_size_t
-#include <stddef.h>
-#include <bits/sigstack.h>
+#include <bits/types/size_t.h>
 #include <bits/types/struct_sigstack.h>
 #include <bits/types/stack_t.h>
+#include <bits/sigstack.h>
 #include <bits/ss_flags.h>
 
 struct __ia64_fpreg
index 469c502aba7d1d18eb3ab82e968988cddceeea8c..24e6af8494ddf271325fdb3e146308cf2d33262f 100644 (file)
@@ -19,7 +19,7 @@
 #define _SYS_USER_H    1
 
 #include <features.h>
-#include <sys/types.h>
+#include <bits/types/size_t.h>
 
 /* This definition comes directly from the kernel headers.  If
    anything changes in them this header has to be changed, too.  */
index 7226b68fe0dab31896220ea4fa2e8d992ccee29f..b21f8a0393e0c4afd812e3249599e237f6015988 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H    1
 
+#include <features.h>
+
 /* 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.  */
index cccbe6399854986e7e3feccce6cb78ab84f710b6..1ab0bb3f4b2696d5eb464664243da8eacec365fa 100644 (file)
@@ -19,6 +19,8 @@
 #ifndef _SYS_USER_H
 # define _SYS_USER_H   1
 
+#include <features.h>
+
 /* 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.  */
index a62ed164e520ef8b713347edceb0c5ecc475cf98..9ca7a81dd215ca74cd8e83e7525f8bb42f77dd47 100644 (file)
@@ -19,8 +19,7 @@
 #ifndef __stack_t_defined
 #define __stack_t_defined 1
 
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
 
 /* Structure describing a signal stack.  */
 typedef struct
index 1eb336a0940acb89439654e53092868253a3bb52..400688c4741dac6816c1f991b5bd686a90435ce9 100644 (file)
 #ifndef _SYS_USER_H
 #define _SYS_USER_H    1
 
+#include <features.h>
+#include <bits/types/size_t.h>
+
 #include <sgidefs.h>
-#include <stddef.h>
 
 /* 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
index 17d48d2c2860296f6e794df8dec99ec2b0ea2777..883f9efe498c04f9547a897bbaea1ce0b3a43ff5 100644 (file)
@@ -19,6 +19,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H    1
 
+#include <features.h>
+
 /* 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.  */
index 71db79c0193cd6dd727676d7930de63981fb5fed..d22634e108ecc7e934c2a4b7000987f2fdd98487 100644 (file)
    <https://www.gnu.org/licenses/>.  */
 
 #ifndef _SYS_USER_H
-
 #define _SYS_USER_H    1
-#include <stddef.h>
+
 #include <features.h>
+#include <bits/types/size_t.h>
 
 #include <asm/ptrace.h>
 
index bc88aae11e695d0fd6fee8468e944e7d3ae002cc..93c095f864a2223649826b0a83cb948f3c123116 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H    1
 
+#include <features.h>
+
 /* 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.  */
index aae939973dcce4c64d1229ec19eef3cd8166381c..639bd972bfc303aea539318898dd2c9ef6361ab1 100644 (file)
@@ -26,9 +26,7 @@
 #define _SCSI_SG_H     1
 
 #include <features.h>
-#define __need_size_t
-#include <stddef.h>
-
+#include <bits/types/size_t.h>
 
 /* New interface introduced in the 3.x SG drivers follows */
 
index 5d3e04a2f6cf8c0b5395ef585b02e294a62c47ae..b8bcc8411b2db6454153101bd89ed47939d0f684 100644 (file)
 #ifndef _SYS_USER_H
 #define _SYS_USER_H    1
 
+#include <features.h>
+#include <bits/types/size_t.h>
+
 #include <asm/ptrace.h>
-#include <stddef.h>
+
 
 /* asm/ptrace.h polutes the namespace.  */
 #undef PTRACE_GETREGS
index 7aaa170b720a9ad3eda8e65ec40628ba63a44e71..400b89bb1186701952825d831b6af3b3881b9005 100644 (file)
@@ -18,7 +18,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H    1
 
-#include <stddef.h>
+#include <features.h>
+#include <bits/types/size_t.h>
 
 struct sunos_regs
 {
index 1ead597244f34c048eefb183b57b59aa27f5badb..c5d06d1a48b26dcba81b747f05c0fb6678729263 100644 (file)
@@ -21,8 +21,8 @@
 #warning "The <sys/sysctl.h> header is deprecated and will be removed."
 
 #include <features.h>
-#define __need_size_t
-#include <stddef.h>
+#include <bits/types/size_t.h>
+
 /* Prevent more kernel headers than necessary to be included.  */
 #ifndef _LINUX_KERNEL_H
 # define _LINUX_KERNEL_H       1
index fd4646773daf14385ea4c2b04db72d058bbf123a..a1de03de83c43cdf17a8453c2f93a565440480ab 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef _SYS_USER_H
 #define _SYS_USER_H    1
 
+#include <features.h>
+
 /* 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.  */
index b110e16eff5e3142b4304a51e582a05dcca4b2f1..8bd4f8144740ce1578dbccee96500cf37038ffb6 100644 (file)
 
 #include <features.h>
 
-#define __need_size_t
-#include <stddef.h>
-
 /* Get common definition of System V style IPC.  */
 #include <sys/ipc.h>
 
-/* Get system dependent definition of `struct msqid_ds' and more.  */
-#include <bits/msq.h>
-
 /* Define types required by the standard.  */
 #include <bits/types/time_t.h>
 #include <bits/types/pid_t.h>
+#include <bits/types/size_t.h>
 #include <bits/types/ssize_t.h>
 
+/* Get system dependent definition of `struct msqid_ds' and more.  */
+#include <bits/msq.h>
+
 /* The following System V style IPC functions implement a message queue
    system.  The definition is found in XPG2.  */
 
index 4ede2dd6ef0011840bf5f31fc466116a5b06331c..852c8a019326120b876b6b6bb39cb0b3dd3cb156 100644 (file)
 
 #include <features.h>
 
-#define __need_size_t
-#include <stddef.h>
-
 /* Get common definition of System V style IPC.  */
 #include <sys/ipc.h>
 
-/* Get system dependent definition of `struct semid_ds' and more.  */
-#include <bits/sem.h>
-
+/* Define types required by the standard.  */
+#include <bits/types/size_t.h>
 #ifdef __USE_GNU
 # include <bits/types/struct_timespec.h>
 #endif
 
+/* Get system dependent definition of `struct semid_ds' and more.  */
+#include <bits/sem.h>
+
 /* The following System V style IPC functions implement a semaphore
    handling.  The definition is found in XPG2.  */
 
index c1cc2951c4a7578e0ec5deee65a24e08447e57f6..f8c57fc56d8ce0c89dab567d0fbce72598df0a92 100644 (file)
 
 #include <features.h>
 
-#define __need_size_t
-#include <stddef.h>
-
 /* Get common definition of System V style IPC.  */
 #include <sys/ipc.h>
 
-/* Get system dependent definition of `struct shmid_ds' and more.  */
-#include <bits/shm.h>
-
 /* Define types required by the standard.  */
+#include <bits/types/size_t.h>
 #include <bits/types/time_t.h>
 #ifdef __USE_XOPEN
 # include <bits/types/pid_t.h>
 #endif
 
+/* Get system dependent definition of `struct shmid_ds' and more.  */
+#include <bits/shm.h>
+
 __BEGIN_DECLS
 
 /* The following System V style IPC functions implement a shared memory
index c12d5e2fb385eb71a9b96cc32d178baa119f201e..d645492ce9117e89530a15b35f853f05cd4fb8d6 100644 (file)
 
 #include <features.h>
 
-#define __need_size_t
-#define __need_NULL
-#include <stddef.h>
-
 /* This defines CLOCKS_PER_SEC, which is the number of processor clock
    ticks per second, and possibly a number of other constants.   */
 #include <bits/time.h>
 
-/* 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 <bits/NULL.h>
 #include <bits/types/clock_t.h>
+#include <bits/types/size_t.h>
 #include <bits/types/time_t.h>
 #include <bits/types/struct_tm.h>
 
index f1108edc6a64173e1b2567d14b5601bb9bcee7f1..1189f05fd07bdb34fe7e4b0f5d803148be2f48c9 100644 (file)
 
 #include <features.h>
 
-#define __need_size_t
-#include <stddef.h>
-
 #include <bits/types.h>
+#include <bits/types/size_t.h>
 #include <bits/types/mbstate_t.h>
 
 #ifndef __USE_ISOCXX11
index 5e0d65b14e55cdafcc3e7fd6fe2d5de608324f4e..71e53c8b4c4f72b439f391bd90d5d461beaa65cd 100644 (file)
 #include <bits/libc-header-start.h>
 
 /* Gather machine dependent type support.  */
-#include <bits/floatn.h>
-
-#define __need_size_t
-#define __need_wchar_t
-#define __need_NULL
-#include <stddef.h>
-
-#define __need___va_list
-#include <stdarg.h>
+#include <bits/types/__FILE.h>
+#include <bits/types/__va_list.h>
+#include <bits/types/mbstate_t.h>
+#include <bits/types/size_t.h>
+#include <bits/types/wchar_t.h>
+#include <bits/types/wint_t.h>
 
+#include <bits/NULL.h>
+#include <bits/floatn.h>
 #include <bits/wchar.h>
-#include <bits/types/wint_t.h>
-#include <bits/types/mbstate_t.h>
-#include <bits/types/__FILE.h>
 
 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
 # include <bits/types/FILE.h>
index 33625c18542c8a738852c6353c97b931ef4bfb0c..3cf1fba3d205698930ff228c69588116db4f0ff0 100644 (file)
@@ -17,7 +17,6 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define __need_wchar_t
 #include <stddef.h>
 #include <locale.h>
 
index 63d7d01b768714cd9fb23c5d2a5781038771a5f8..6a93a754f3f854b0f55f88d08e3de5fc79c5c259 100644 (file)
@@ -17,7 +17,6 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define __need_wchar_t
 #include <stddef.h>
 #include <locale.h>
 
index 540ff9c8171afe960c2b39afe132c387a9e50a93..cba6eff09ca34d8684f8218e3cab19906b3d7df5 100644 (file)
@@ -17,7 +17,6 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define __need_wchar_t
 #include <stddef.h>
 #include <locale.h>
 
index aa93c1b06f0511701cf28423e65d68b44be53bad..e3eef71ec89a23249b929821f385db038cfccc8b 100644 (file)
@@ -17,7 +17,6 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define __need_wchar_t
 #include <stddef.h>
 #include <locale.h>