public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/zack/no-nested-includes] Create bits/types headers for most remaining __T_defined macros.
@ 2019-05-26 16:36 Zack Weinberg
0 siblings, 0 replies; 4+ messages in thread
From: Zack Weinberg @ 2019-05-26 16:36 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c0a0bc0fc0ea68e9b3710257a4cbe401e2b6917e
commit c0a0bc0fc0ea68e9b3710257a4cbe401e2b6917e
Author: Zack Weinberg <zackw@panix.com>
Date: Sat Mar 9 20:54:02 2019 -0500
Create bits/types headers for most remaining __T_defined macros.
This doesn't exactly fit the theme but as long as I'm tinkering with
sys/types.h it makes sense to go through and create single-declaration
bits/types/ headers for all of the remaining cases where we have
two or more headers declaring a public type.
The remaining uses of the original __T_defined idiom are:
__error_t_defined in files shared with gnulib, which probably has to
remain as is; ____gwchar_t_defined in inttypes.h, which may not be
necessary anymore and should be addressed separately, and
__ldiv_t_defined and __lldiv_t_defined in stdlib.h, ditto.
Our handling of LFS types is a little inconsistent: some headers
declare both off_t and off64_t (for instance) when
_LARGEFILE64_SOURCE, others will only declare off_t regardless of
_LARGEFILE64_SOURCE. I don't know if this was intentional or not.
I am tempted to centralize responsibility for _LARGEFILE64_SOURCE as
well as _FILE_OFFSET_BITS=64 in bits/types/off_t.h (etc) so that any
header that declares off_t will automatically also declare off64_t
when _LARGEFILE64_SOURCE.
sunrpc/rpc/types.h is special, because it is included in files
compiled by the *build* compiler (cross-rpcgen-objs), and therefore it
cannot unconditionally assume bits/types headers are available. What
I did was have it include the appropriate bits/types headers only if
including sys/types.h did not cause __BIT_TYPES_DEFINED__ to be
defined. This will do the right thing when an installed rpc/types.h
is included by application code compiled without __USE_MISC in effect.
During the build, we rely on the fact that we compile all of our own
code with __USE_MISC in effect. This is fragile, but should be
acceptable for code that's no longer built by default anyway.
scripts/check-obsolete-constructs.py ensures that only sys/types.h and
rpc/types.h include the bits/types/ headers that define obsolete types.
* posix/bits/types/blkcnt64_t.h
* posix/bits/types/blkcnt_t.h
* posix/bits/types/blksize_t.h
* posix/bits/types/dev_t.h
* posix/bits/types/fsblkcnt64_t.h
* posix/bits/types/fsblkcnt_t.h
* posix/bits/types/fsfilcnt64_t.h
* posix/bits/types/fsfilcnt_t.h
* posix/bits/types/fsid_t.h
* posix/bits/types/gid_t.h
* posix/bits/types/id_t.h
* posix/bits/types/ino64_t.h
* posix/bits/types/ino_t.h
* posix/bits/types/intptr_t.h
* posix/bits/types/key_t.h
* posix/bits/types/loff_t.h
* posix/bits/types/mode_t.h
* posix/bits/types/nlink_t.h
* posix/bits/types/off64_t.h
* posix/bits/types/off_t.h
* posix/bits/types/pid_t.h
* posix/bits/types/socklen_t.h
* posix/bits/types/ssize_t.h
* posix/bits/types/suseconds_t.h
* posix/bits/types/uid_t.h
* posix/bits/types/useconds_t.h:
New single-declaration headers for standard types canonically
defined by sys/types.h, sys/socket.h, or inttypes.h but also
exposed by other headers under some circumstances. Code moved
from posix/sys/types.h, socket/sys/socket.h, stdlib/inttypes.h
as appropriate.
* posix/bits/types/uint.h
* posix/bits/types/u_int.h
* posix/bits/types/u_intN_t.h
* posix/bits/types/caddr_t.h
* posix/bits/types/daddr_t.h
* posix/bits/types/loff_t.h
* posix/bits/types/register_t.h:
Similarly, but for obsolete BSD-derived types whose canonical
home is sys/types.h. Some of these headers define more than
one type.
* posix/Makefile (headers): Install the above new headers.
Rewrap the list.
* posix/sys/types.h: All definitions of public types now
accomplished using the above new headers. Consolidate
groups of definitions controlled by the same feature
selection macros.
* inet/arpa/inet.h, bits/socket.h
* sysdeps/mach/hurd/bits/socket.h
* sysdeps/unix/sysv/linux/bits/socket.h:
Use bits/types/socklen_t.h.
* dirent/dirent.h: Use bits/types/ino_t.h and bits/types/ino64_t.h.
* grp/grp.h: Use bits/types/gid_t.h.
* io/fcntl.h: Use bits/types/mode_t.h, bits/types/off_t.h,
bits/types/pid_t.h, and bits/types/off64_t.h.
* io/sys/stat.h: Use bits/types/dev_t.h, bits/types/gid_t.h,
bits/types/ino_t.h, bits/types/mode_t.h, bits/types/nlink_t.h,
bits/types/off_t.h, bits/types/uid_t.h, and bits/types/blkcnt_t.h.
* libio/stdio.h: Use bits/types/off_t.h, bits/types/off64_t.h,
and bits/types/ssize_t.h.
* misc/sys/mman.h: Use bits/types/off_t.h and bits/types/mode_t.h.
* misc/sys/select.h: Use bits/types/suseconds_t.h.
* posix/sched.h: Use bits/types/pid_t.h.
* posix/sys/wait.h: Use bits/types/pid_t.h and bits/types/id_t.h.
* posix/unistd.h: Use bits/types/gid_t.h, bits/types/uid_t.h,
bits/types/off_t.h, bits/types/off64_t.h, bits/types/useconds_t.h,
bits/types/intptr_t.h, and bits/types/socklen_t.h.
* pwd/pwd.h: Use bits/types/gid_t.h and bits/types/uid_t.h.
* resource/sys/resource.h: Use bits/types/id_t.h.
* signal/signal.h: Use bits/types/pid_t.h and bits/types/uid_t.h.
* stdlib/monetary.h: Use bits/types/ssize_t.h.
* sysdeps/gnu/utmpx.h: Use bits/types/pid_t.h.
* sysvipc/sys/ipc.h: Use bits/types/uid_t.h, bits/types/gid_t.h,
bits/types/mode_t.h, and bits/types/key_t.h.
* sysvipc/sys/msg.h: Use bits/types/pid_t.h and bits/types/ssize_t.h.
* sysvipc/sys/shm.h: Use bits/types/pid_t.h.
* termios/termios.h: Use bits/types/pid_t.h.
* time/sys/time.h: Use bits/types/suseconds_t.h.
* time/time.h: Use bits/types/pid_t.h.
* sunrpc/rpc/types.h: Consolidate all #includes at the top of
the file. If __BIT_TYPES_DEFINED__ is not defined after
including sys/types.h, also include bits/types/caddr_t.h,
bits/types/daddr_t.h, bits/types/fsid_t.h, and bits/types/u_int.h.
* scripts/check-obsolete-constructs.py (OBSOLETE_TYPE_HDR_RE_): New.
(ObsoleteIndirectDefinitionsAllowed): New; allows inclusion of
bits/types/ headers that define obsolete typedefs, but not
direct definitions of those types.
(ObsoleteNotAllowed, ObsoletePrivateDefinitionsAllowed)
(ObsoletePublicDefinitionsAllowed): Do not allow inclusion of
bits/types/ headers that define obsolete typedefs.
* include/bits/types/blkcnt64_t.h
* include/bits/types/blkcnt_t.h
* include/bits/types/blksize_t.h
* include/bits/types/caddr_t.h
* include/bits/types/daddr_t.h
* include/bits/types/dev_t.h
* include/bits/types/fsblkcnt64_t.h
* include/bits/types/fsblkcnt_t.h
* include/bits/types/fsfilcnt64_t.h
* include/bits/types/fsfilcnt_t.h
* include/bits/types/fsid_t.h
* include/bits/types/gid_t.h
* include/bits/types/id_t.h
* include/bits/types/ino64_t.h
* include/bits/types/ino_t.h
* include/bits/types/intptr_t.h
* include/bits/types/key_t.h
* include/bits/types/loff_t.h
* include/bits/types/mode_t.h
* include/bits/types/nlink_t.h
* include/bits/types/off64_t.h
* include/bits/types/off_t.h
* include/bits/types/pid_t.h
* include/bits/types/register_t.h
* include/bits/types/socklen_t.h
* include/bits/types/ssize_t.h
* include/bits/types/suseconds_t.h
* include/bits/types/u_char.h
* include/bits/types/u_intN_t.h
* include/bits/types/uchar.h
* include/bits/types/uid_t.h
* include/bits/types/useconds_t.h: New wrappers.
Diff:
---
bits/socket.h | 8 +-
dirent/dirent.h | 14 +--
grp/grp.h | 6 +-
include/bits/types/blkcnt64_t.h | 1 +
include/bits/types/blkcnt_t.h | 1 +
include/bits/types/blksize_t.h | 1 +
include/bits/types/caddr_t.h | 1 +
include/bits/types/daddr_t.h | 1 +
include/bits/types/dev_t.h | 1 +
include/bits/types/fsblkcnt64_t.h | 1 +
include/bits/types/fsblkcnt_t.h | 1 +
include/bits/types/fsfilcnt64_t.h | 1 +
include/bits/types/fsfilcnt_t.h | 1 +
include/bits/types/fsid_t.h | 1 +
include/bits/types/gid_t.h | 1 +
include/bits/types/id_t.h | 1 +
include/bits/types/ino64_t.h | 1 +
include/bits/types/ino_t.h | 1 +
include/bits/types/intptr_t.h | 1 +
include/bits/types/key_t.h | 1 +
include/bits/types/loff_t.h | 1 +
include/bits/types/mode_t.h | 1 +
include/bits/types/nlink_t.h | 1 +
include/bits/types/off64_t.h | 1 +
include/bits/types/off_t.h | 1 +
include/bits/types/pid_t.h | 1 +
include/bits/types/register_t.h | 1 +
include/bits/types/socklen_t.h | 1 +
include/bits/types/ssize_t.h | 1 +
include/bits/types/suseconds_t.h | 1 +
include/bits/types/u_int.h | 1 +
include/bits/types/u_intN_t.h | 1 +
include/bits/types/uid_t.h | 1 +
include/bits/types/uint.h | 1 +
include/bits/types/useconds_t.h | 1 +
inet/arpa/inet.h | 7 +-
io/fcntl.h | 27 +----
io/sys/stat.h | 66 ++---------
io/sys/statvfs.h | 21 +---
libio/stdio.h | 19 +--
misc/sys/mman.h | 16 +--
misc/sys/select.h | 7 +-
posix/Makefile | 37 ++++--
posix/bits/types/blkcnt64_t.h | 9 ++
posix/bits/types/blkcnt_t.h | 13 +++
posix/bits/types/blksize_t.h | 9 ++
posix/bits/types/caddr_t.h | 9 ++
posix/bits/types/daddr_t.h | 9 ++
posix/bits/types/dev_t.h | 9 ++
posix/bits/types/fsblkcnt64_t.h | 9 ++
posix/bits/types/fsblkcnt_t.h | 13 +++
posix/bits/types/fsfilcnt64_t.h | 9 ++
posix/bits/types/fsfilcnt_t.h | 13 +++
posix/bits/types/fsid_t.h | 9 ++
posix/bits/types/gid_t.h | 9 ++
posix/bits/types/id_t.h | 10 ++
posix/bits/types/ino64_t.h | 9 ++
posix/bits/types/ino_t.h | 13 +++
posix/bits/types/intptr_t.h | 10 ++
posix/bits/types/key_t.h | 9 ++
posix/bits/types/loff_t.h | 9 ++
posix/bits/types/mode_t.h | 9 ++
posix/bits/types/nlink_t.h | 9 ++
posix/bits/types/off64_t.h | 9 ++
posix/bits/types/off_t.h | 13 +++
posix/bits/types/pid_t.h | 9 ++
posix/bits/types/register_t.h | 9 ++
posix/bits/types/socklen_t.h | 9 ++
posix/bits/types/ssize_t.h | 9 ++
posix/bits/types/suseconds_t.h | 9 ++
posix/bits/types/u_int.h | 15 +++
posix/bits/types/u_intN_t.h | 17 +++
posix/bits/types/uid_t.h | 9 ++
posix/bits/types/uint.h | 10 ++
posix/bits/types/useconds_t.h | 9 ++
posix/sched.h | 6 +-
posix/sys/types.h | 212 +++++++---------------------------
posix/sys/wait.h | 11 +-
posix/unistd.h | 54 ++-------
pwd/pwd.h | 11 +-
resource/sys/resource.h | 6 +-
scripts/check-obsolete-constructs.py | 74 ++++++++++--
signal/signal.h | 12 +-
stdlib/monetary.h | 7 +-
stdlib/stdint.h | 5 +-
sunrpc/rpc/types.h | 44 +++----
sysdeps/gnu/utmpx.h | 5 +-
sysdeps/mach/hurd/bits/socket.h | 8 +-
sysdeps/unix/sysv/linux/bits/socket.h | 7 +-
sysvipc/sys/ipc.h | 24 +---
sysvipc/sys/msg.h | 12 +-
sysvipc/sys/shm.h | 9 +-
termios/termios.h | 8 +-
time/sys/time.h | 6 +-
time/time.h | 5 +-
95 files changed, 571 insertions(+), 540 deletions(-)
diff --git a/bits/socket.h b/bits/socket.h
index fdcf015..6687a47 100644
--- a/bits/socket.h
+++ b/bits/socket.h
@@ -28,13 +28,7 @@
#include <bits/wordsize.h>
#include <bits/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
-
+#include <bits/types/socklen_t.h>
/* Types of sockets. */
enum __socket_type
diff --git a/dirent/dirent.h b/dirent/dirent.h
index fc4d485..9639ae9 100644
--- a/dirent/dirent.h
+++ b/dirent/dirent.h
@@ -29,17 +29,9 @@ __BEGIN_DECLS
#include <bits/types.h>
#ifdef __USE_XOPEN
-# ifndef __ino_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __ino_t ino_t;
-# else
-typedef __ino64_t ino_t;
-# endif
-# define __ino_t_defined
-# endif
-# if defined __USE_LARGEFILE64 && !defined __ino64_t_defined
-typedef __ino64_t ino64_t;
-# define __ino64_t_defined
+# include <bits/types/ino_t.h>
+# ifdef __USE_LARGEFILE64
+# include <bits/types/ino64_t.h>
# endif
#endif
diff --git a/grp/grp.h b/grp/grp.h
index 0663c8f..d8f7683 100644
--- a/grp/grp.h
+++ b/grp/grp.h
@@ -31,11 +31,9 @@ __BEGIN_DECLS
#define __need_size_t
#include <stddef.h>
-
/* For the Single Unix specification we must define this type here. */
-#if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
+#if defined __USE_XOPEN || defined __USE_XOPEN2K
+# include <bits/types/gid_t.h>
#endif
/* The group structure. */
diff --git a/include/bits/types/blkcnt64_t.h b/include/bits/types/blkcnt64_t.h
new file mode 100644
index 0000000..c0c2ced
--- /dev/null
+++ b/include/bits/types/blkcnt64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/blkcnt64_t.h>
diff --git a/include/bits/types/blkcnt_t.h b/include/bits/types/blkcnt_t.h
new file mode 100644
index 0000000..ad8ed24
--- /dev/null
+++ b/include/bits/types/blkcnt_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/blkcnt_t.h>
diff --git a/include/bits/types/blksize_t.h b/include/bits/types/blksize_t.h
new file mode 100644
index 0000000..d6ed861
--- /dev/null
+++ b/include/bits/types/blksize_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/blksize_t.h>
diff --git a/include/bits/types/caddr_t.h b/include/bits/types/caddr_t.h
new file mode 100644
index 0000000..9d499e7
--- /dev/null
+++ b/include/bits/types/caddr_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/caddr_t.h>
diff --git a/include/bits/types/daddr_t.h b/include/bits/types/daddr_t.h
new file mode 100644
index 0000000..90050fa
--- /dev/null
+++ b/include/bits/types/daddr_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/daddr_t.h>
diff --git a/include/bits/types/dev_t.h b/include/bits/types/dev_t.h
new file mode 100644
index 0000000..f0451c0
--- /dev/null
+++ b/include/bits/types/dev_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/dev_t.h>
diff --git a/include/bits/types/fsblkcnt64_t.h b/include/bits/types/fsblkcnt64_t.h
new file mode 100644
index 0000000..b5951d5
--- /dev/null
+++ b/include/bits/types/fsblkcnt64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsblkcnt64_t.h>
diff --git a/include/bits/types/fsblkcnt_t.h b/include/bits/types/fsblkcnt_t.h
new file mode 100644
index 0000000..9fc9e41
--- /dev/null
+++ b/include/bits/types/fsblkcnt_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsblkcnt_t.h>
diff --git a/include/bits/types/fsfilcnt64_t.h b/include/bits/types/fsfilcnt64_t.h
new file mode 100644
index 0000000..d3152d4
--- /dev/null
+++ b/include/bits/types/fsfilcnt64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsfilcnt64_t.h>
diff --git a/include/bits/types/fsfilcnt_t.h b/include/bits/types/fsfilcnt_t.h
new file mode 100644
index 0000000..fc092c5
--- /dev/null
+++ b/include/bits/types/fsfilcnt_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsfilcnt_t.h>
diff --git a/include/bits/types/fsid_t.h b/include/bits/types/fsid_t.h
new file mode 100644
index 0000000..9d1e517
--- /dev/null
+++ b/include/bits/types/fsid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsid_t.h>
diff --git a/include/bits/types/gid_t.h b/include/bits/types/gid_t.h
new file mode 100644
index 0000000..d8cf23b
--- /dev/null
+++ b/include/bits/types/gid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/gid_t.h>
diff --git a/include/bits/types/id_t.h b/include/bits/types/id_t.h
new file mode 100644
index 0000000..5eaae0b
--- /dev/null
+++ b/include/bits/types/id_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/id_t.h>
diff --git a/include/bits/types/ino64_t.h b/include/bits/types/ino64_t.h
new file mode 100644
index 0000000..4203764
--- /dev/null
+++ b/include/bits/types/ino64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/ino64_t.h>
diff --git a/include/bits/types/ino_t.h b/include/bits/types/ino_t.h
new file mode 100644
index 0000000..2624ae5
--- /dev/null
+++ b/include/bits/types/ino_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/ino_t.h>
diff --git a/include/bits/types/intptr_t.h b/include/bits/types/intptr_t.h
new file mode 100644
index 0000000..455151b
--- /dev/null
+++ b/include/bits/types/intptr_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/intptr_t.h>
diff --git a/include/bits/types/key_t.h b/include/bits/types/key_t.h
new file mode 100644
index 0000000..c4d96aa
--- /dev/null
+++ b/include/bits/types/key_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/key_t.h>
diff --git a/include/bits/types/loff_t.h b/include/bits/types/loff_t.h
new file mode 100644
index 0000000..933175c
--- /dev/null
+++ b/include/bits/types/loff_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/loff_t.h>
diff --git a/include/bits/types/mode_t.h b/include/bits/types/mode_t.h
new file mode 100644
index 0000000..58602b5
--- /dev/null
+++ b/include/bits/types/mode_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/mode_t.h>
diff --git a/include/bits/types/nlink_t.h b/include/bits/types/nlink_t.h
new file mode 100644
index 0000000..f330ae2
--- /dev/null
+++ b/include/bits/types/nlink_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/nlink_t.h>
diff --git a/include/bits/types/off64_t.h b/include/bits/types/off64_t.h
new file mode 100644
index 0000000..002d920
--- /dev/null
+++ b/include/bits/types/off64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/off64_t.h>
diff --git a/include/bits/types/off_t.h b/include/bits/types/off_t.h
new file mode 100644
index 0000000..1f18d15
--- /dev/null
+++ b/include/bits/types/off_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/off_t.h>
diff --git a/include/bits/types/pid_t.h b/include/bits/types/pid_t.h
new file mode 100644
index 0000000..6de6aff
--- /dev/null
+++ b/include/bits/types/pid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/pid_t.h>
diff --git a/include/bits/types/register_t.h b/include/bits/types/register_t.h
new file mode 100644
index 0000000..6828620
--- /dev/null
+++ b/include/bits/types/register_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/register_t.h>
diff --git a/include/bits/types/socklen_t.h b/include/bits/types/socklen_t.h
new file mode 100644
index 0000000..229f676
--- /dev/null
+++ b/include/bits/types/socklen_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/socklen_t.h>
diff --git a/include/bits/types/ssize_t.h b/include/bits/types/ssize_t.h
new file mode 100644
index 0000000..374e438
--- /dev/null
+++ b/include/bits/types/ssize_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/ssize_t.h>
diff --git a/include/bits/types/suseconds_t.h b/include/bits/types/suseconds_t.h
new file mode 100644
index 0000000..85f0dbe
--- /dev/null
+++ b/include/bits/types/suseconds_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/suseconds_t.h>
diff --git a/include/bits/types/u_int.h b/include/bits/types/u_int.h
new file mode 100644
index 0000000..2b17d5b
--- /dev/null
+++ b/include/bits/types/u_int.h
@@ -0,0 +1 @@
+#include <posix/bits/types/u_int.h>
diff --git a/include/bits/types/u_intN_t.h b/include/bits/types/u_intN_t.h
new file mode 100644
index 0000000..ffb17bc
--- /dev/null
+++ b/include/bits/types/u_intN_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/u_intN_t.h>
diff --git a/include/bits/types/uid_t.h b/include/bits/types/uid_t.h
new file mode 100644
index 0000000..1e2b106
--- /dev/null
+++ b/include/bits/types/uid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/uid_t.h>
diff --git a/include/bits/types/uint.h b/include/bits/types/uint.h
new file mode 100644
index 0000000..a446b7f
--- /dev/null
+++ b/include/bits/types/uint.h
@@ -0,0 +1 @@
+#include <posix/bits/types/uint.h>
diff --git a/include/bits/types/useconds_t.h b/include/bits/types/useconds_t.h
new file mode 100644
index 0000000..71f720b
--- /dev/null
+++ b/include/bits/types/useconds_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/useconds_t.h>
diff --git a/inet/arpa/inet.h b/inet/arpa/inet.h
index 4db2087..facee27 100644
--- a/inet/arpa/inet.h
+++ b/inet/arpa/inet.h
@@ -20,12 +20,7 @@
#include <features.h>
#include <netinet/in.h> /* To define `struct in_addr'. */
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
+#include <bits/types/socklen_t.h>
__BEGIN_DECLS
diff --git a/io/fcntl.h b/io/fcntl.h
index 7af8dfb..2e973e6 100644
--- a/io/fcntl.h
+++ b/io/fcntl.h
@@ -46,28 +46,11 @@ __BEGIN_DECLS
/* POSIX.1-2001 specifies that these types are defined by <fcntl.h>.
Earlier POSIX standards permitted any type ending in `_t' to be defined
by any POSIX header, so we don't conditionalize the definitions here. */
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
-
-#ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-#endif
-
-#if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
-#endif
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
+#include <bits/types/mode_t.h>
+#include <bits/types/off_t.h>
+#include <bits/types/pid_t.h>
+#ifdef __USE_LARGEFILE64
+#include <bits/types/off64_t.h>
#endif
/* For XPG all symbols from <sys/stat.h> should also be available. */
diff --git a/io/sys/stat.h b/io/sys/stat.h
index 2de5eb6..e05985e 100644
--- a/io/sys/stat.h
+++ b/io/sys/stat.h
@@ -33,67 +33,19 @@
#if defined __USE_XOPEN || defined __USE_XOPEN2K
/* The Single Unix specification says that some more types are
available here. */
-
# include <bits/types/time_t.h>
-
-# ifndef __dev_t_defined
-typedef __dev_t dev_t;
-# define __dev_t_defined
-# endif
-
-# ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-# endif
-
-# ifndef __ino_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __ino_t ino_t;
-# else
-typedef __ino64_t ino_t;
-# endif
-# define __ino_t_defined
-# endif
-
-# ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-# endif
-
-# ifndef __nlink_t_defined
-typedef __nlink_t nlink_t;
-# define __nlink_t_defined
-# endif
-
-# ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-# endif
-
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
+# include <bits/types/dev_t.h>
+# include <bits/types/gid_t.h>
+# include <bits/types/ino_t.h>
+# include <bits/types/mode_t.h>
+# include <bits/types/nlink_t.h>
+# include <bits/types/off_t.h>
+# include <bits/types/uid_t.h>
#endif /* X/Open */
#ifdef __USE_UNIX98
-# ifndef __blkcnt_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __blkcnt_t blkcnt_t;
-# else
-typedef __blkcnt64_t blkcnt_t;
-# endif
-# define __blkcnt_t_defined
-# endif
-
-# ifndef __blksize_t_defined
-typedef __blksize_t blksize_t;
-# define __blksize_t_defined
-# endif
+# include <bits/types/blkcnt_t.h>
+# include <bits/types/blksize_t.h>
#endif /* Unix98 */
__BEGIN_DECLS
diff --git a/io/sys/statvfs.h b/io/sys/statvfs.h
index 89abf02..d7283dd 100644
--- a/io/sys/statvfs.h
+++ b/io/sys/statvfs.h
@@ -24,25 +24,8 @@
/* Get the system-specific definition of `struct statfs'. */
#include <bits/statvfs.h>
-#ifndef __USE_FILE_OFFSET64
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#else
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt64_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt64_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#endif
+#include <bits/types/fsblkcnt_t.h>
+#include <bits/types/fsfilcnt_t.h>
__BEGIN_DECLS
diff --git a/libio/stdio.h b/libio/stdio.h
index b63ee88..6fabdbe 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -58,25 +58,14 @@ typedef __gnuc_va_list va_list;
#endif
#if defined __USE_UNIX98 || defined __USE_XOPEN2K
-# ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-# endif
-# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
+# include <bits/types/off_t.h>
+# ifdef __USE_LARGEFILE64
+# include <bits/types/off64_t.h>
# endif
#endif
#ifdef __USE_XOPEN2K8
-# ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-# endif
+# include <bits/types/ssize_t.h>
#endif
/* The type of the second argument to `fgetpos' and `fsetpos'. */
diff --git a/misc/sys/mman.h b/misc/sys/mman.h
index b275120..43552c3 100644
--- a/misc/sys/mman.h
+++ b/misc/sys/mman.h
@@ -21,22 +21,12 @@
#include <features.h>
#include <bits/types.h>
+
#define __need_size_t
#include <stddef.h>
-#ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-#endif
-
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
+#include <bits/types/off_t.h>
+#include <bits/types/mode_t.h>
#include <bits/mman.h>
diff --git a/misc/sys/select.h b/misc/sys/select.h
index 8b10702..84e2ae3 100644
--- a/misc/sys/select.h
+++ b/misc/sys/select.h
@@ -38,12 +38,7 @@
#ifdef __USE_XOPEN2K
# include <bits/types/struct_timespec.h>
#endif
-
-#ifndef __suseconds_t_defined
-typedef __suseconds_t suseconds_t;
-# define __suseconds_t_defined
-#endif
-
+#include <bits/types/suseconds_t.h>
/* The fd_set member is required to be an array of longs. */
typedef long int __fd_mask;
diff --git a/posix/Makefile b/posix/Makefile
index 8ac6743..882f78c 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -22,17 +22,32 @@ subdir := posix
include ../Makeconfig
-headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \
- glob.h regex.h wordexp.h fnmatch.h \
- getopt.h bits/getopt_core.h bits/getopt_ext.h bits/getopt_posix.h \
- bits/types.h bits/typesizes.h bits/pthreadtypes.h \
- bits/pthreadtypes-arch.h bits/thread-shared-types.h \
- bits/posix1_lim.h bits/posix2_lim.h bits/posix_opt.h \
- bits/local_lim.h tar.h bits/utsname.h bits/confname.h \
- bits/waitflags.h bits/waitstatus.h sys/unistd.h sched.h \
- bits/sched.h bits/cpu-set.h re_comp.h wait.h bits/environments.h \
- cpio.h spawn.h bits/unistd.h bits/types/struct_sched_param.h \
- bits/unistd_ext.h
+headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \
+ glob.h regex.h wordexp.h fnmatch.h getopt.h \
+ bits/getopt_core.h bits/getopt_ext.h bits/getopt_posix.h \
+ bits/types.h bits/typesizes.h bits/pthreadtypes.h \
+ bits/pthreadtypes-arch.h bits/thread-shared-types.h \
+ bits/posix1_lim.h bits/posix2_lim.h bits/posix_opt.h \
+ bits/local_lim.h tar.h bits/utsname.h bits/confname.h \
+ bits/waitflags.h bits/waitstatus.h sys/unistd.h sched.h \
+ bits/sched.h bits/cpu-set.h re_comp.h wait.h \
+ bits/environments.h cpio.h spawn.h bits/unistd.h \
+ bits/types/struct_sched_param.h bits/unistd_ext.h \
+ bits/types/blkcnt64_t.h bits/types/blkcnt_t.h \
+ bits/types/blksize_t.h bits/types/caddr_t.h \
+ bits/types/daddr_t.h bits/types/dev_t.h \
+ bits/types/fsblkcnt64_t.h bits/types/fsblkcnt_t.h \
+ bits/types/fsfilcnt64_t.h bits/types/fsfilcnt_t.h \
+ bits/types/fsid_t.h bits/types/gid_t.h bits/types/id_t.h \
+ bits/types/ino64_t.h bits/types/ino_t.h \
+ bits/types/intptr_t.h bits/types/key_t.h \
+ bits/types/loff_t.h bits/types/mode_t.h \
+ bits/types/nlink_t.h bits/types/off64_t.h \
+ bits/types/off_t.h bits/types/pid_t.h \
+ bits/types/register_t.h bits/types/ssize_t.h \
+ bits/types/socklen_t.h bits/types/suseconds_t.h \
+ bits/types/uid_t.h bits/types/uint.h bits/types/u_int.h \
+ bits/types/u_intN_t.h bits/types/useconds_t.h
routines := \
uname \
diff --git a/posix/bits/types/blkcnt64_t.h b/posix/bits/types/blkcnt64_t.h
new file mode 100644
index 0000000..d5d81e7
--- /dev/null
+++ b/posix/bits/types/blkcnt64_t.h
@@ -0,0 +1,9 @@
+#ifndef __blkcnt64_t_defined
+#define __blkcnt64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count disk blocks (LFS). */
+typedef __blkcnt64_t blkcnt64_t;
+
+#endif
diff --git a/posix/bits/types/blkcnt_t.h b/posix/bits/types/blkcnt_t.h
new file mode 100644
index 0000000..badcd47
--- /dev/null
+++ b/posix/bits/types/blkcnt_t.h
@@ -0,0 +1,13 @@
+#ifndef __blkcnt_t_defined
+#define __blkcnt_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count number of disk blocks (POSIX). */
+#ifndef __USE_FILE_OFFSET64
+typedef __blkcnt_t blkcnt_t;
+#else
+typedef __blkcnt64_t blkcnt_t;
+#endif
+
+#endif
diff --git a/posix/bits/types/blksize_t.h b/posix/bits/types/blksize_t.h
new file mode 100644
index 0000000..9d6ada4
--- /dev/null
+++ b/posix/bits/types/blksize_t.h
@@ -0,0 +1,9 @@
+#ifndef __blksize_t_defined
+#define __blksize_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for sizes of disk blocks (POSIX). */
+typedef __blksize_t blksize_t;
+
+#endif
diff --git a/posix/bits/types/caddr_t.h b/posix/bits/types/caddr_t.h
new file mode 100644
index 0000000..fc010bd
--- /dev/null
+++ b/posix/bits/types/caddr_t.h
@@ -0,0 +1,9 @@
+#ifndef __caddr_t_defined
+#define __caddr_t_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete type for a memory address (BSD). */
+typedef __caddr_t caddr_t;
+
+#endif
diff --git a/posix/bits/types/daddr_t.h b/posix/bits/types/daddr_t.h
new file mode 100644
index 0000000..59f0b1b
--- /dev/null
+++ b/posix/bits/types/daddr_t.h
@@ -0,0 +1,9 @@
+#ifndef __daddr_t_defined
+#define __daddr_t_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete type for a disk address (BSD). */
+typedef __daddr_t daddr_t;
+
+#endif
diff --git a/posix/bits/types/dev_t.h b/posix/bits/types/dev_t.h
new file mode 100644
index 0000000..0b45f91
--- /dev/null
+++ b/posix/bits/types/dev_t.h
@@ -0,0 +1,9 @@
+#ifndef __dev_t_defined
+#define __dev_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for device IDs (POSIX). */
+typedef __dev_t dev_t;
+
+#endif
diff --git a/posix/bits/types/fsblkcnt64_t.h b/posix/bits/types/fsblkcnt64_t.h
new file mode 100644
index 0000000..690d601
--- /dev/null
+++ b/posix/bits/types/fsblkcnt64_t.h
@@ -0,0 +1,9 @@
+#ifndef __fsblkcnt64_t_defined
+#define __fsblkcnt64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system blocks (LFS). */
+typedef __fsblkcnt64_t fsblkcnt64_t;
+
+#endif
diff --git a/posix/bits/types/fsblkcnt_t.h b/posix/bits/types/fsblkcnt_t.h
new file mode 100644
index 0000000..2c7e80d
--- /dev/null
+++ b/posix/bits/types/fsblkcnt_t.h
@@ -0,0 +1,13 @@
+#ifndef __fsblkcnt_t_defined
+#define __fsblkcnt_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system blocks (POSIX). */
+#ifndef __USE_FILE_OFFSET64
+typedef __fsblkcnt_t fsblkcnt_t;
+#else
+typedef __fsblkcnt64_t fsblkcnt_t;
+#endif
+
+#endif
diff --git a/posix/bits/types/fsfilcnt64_t.h b/posix/bits/types/fsfilcnt64_t.h
new file mode 100644
index 0000000..56fcbc7
--- /dev/null
+++ b/posix/bits/types/fsfilcnt64_t.h
@@ -0,0 +1,9 @@
+#ifndef __fsfilcnt64_t_defined
+#define __fsfilcnt64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system inodes (LFS). */
+typedef __fsfilcnt64_t fsfilcnt64_t;
+
+#endif
diff --git a/posix/bits/types/fsfilcnt_t.h b/posix/bits/types/fsfilcnt_t.h
new file mode 100644
index 0000000..18d0f7e
--- /dev/null
+++ b/posix/bits/types/fsfilcnt_t.h
@@ -0,0 +1,13 @@
+#ifndef __fsfilcnt_t_defined
+#define __fsfilcnt_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system inodes (POSIX). */
+#ifndef __USE_FILE_OFFSET64
+typedef __fsfilcnt_t fsfilcnt_t;
+#else
+typedef __fsfilcnt64_t fsfilcnt_t;
+#endif
+
+#endif
diff --git a/posix/bits/types/fsid_t.h b/posix/bits/types/fsid_t.h
new file mode 100644
index 0000000..a198d30
--- /dev/null
+++ b/posix/bits/types/fsid_t.h
@@ -0,0 +1,9 @@
+#ifndef __fsid_t_defined
+#define __fsid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for a file system ID (BSD). */
+typedef __fsid_t fsid_t;
+
+#endif
diff --git a/posix/bits/types/gid_t.h b/posix/bits/types/gid_t.h
new file mode 100644
index 0000000..52974a1
--- /dev/null
+++ b/posix/bits/types/gid_t.h
@@ -0,0 +1,9 @@
+#ifndef __gid_t_defined
+#define __gid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for group IDs (POSIX). */
+typedef __gid_t gid_t;
+
+#endif
diff --git a/posix/bits/types/id_t.h b/posix/bits/types/id_t.h
new file mode 100644
index 0000000..1cb3b76
--- /dev/null
+++ b/posix/bits/types/id_t.h
@@ -0,0 +1,10 @@
+#ifndef __id_t_defined
+#define __id_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for a general identifier, can hold any pid_t, uid_t, or gid_t
+ value (POSIX). */
+typedef __id_t id_t;
+
+#endif
diff --git a/posix/bits/types/ino64_t.h b/posix/bits/types/ino64_t.h
new file mode 100644
index 0000000..e61e75a
--- /dev/null
+++ b/posix/bits/types/ino64_t.h
@@ -0,0 +1,9 @@
+#ifndef __ino64_t_defined
+#define __ino64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file serial numbers (LFS). */
+typedef __ino64_t ino64_t;
+
+#endif
diff --git a/posix/bits/types/ino_t.h b/posix/bits/types/ino_t.h
new file mode 100644
index 0000000..808821f
--- /dev/null
+++ b/posix/bits/types/ino_t.h
@@ -0,0 +1,13 @@
+#ifndef __ino_t_defined
+#define __ino_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file serial numbers (POSIX). */
+# ifndef __USE_FILE_OFFSET64
+typedef __ino_t ino_t;
+# else
+typedef __ino64_t ino_t;
+# endif
+
+#endif
diff --git a/posix/bits/types/intptr_t.h b/posix/bits/types/intptr_t.h
new file mode 100644
index 0000000..47948f9
--- /dev/null
+++ b/posix/bits/types/intptr_t.h
@@ -0,0 +1,10 @@
+#ifndef __intptr_t_defined
+#define __intptr_t_defined 1
+
+#include <bits/types.h>
+
+/* Signed integral type capable of representing a `void *' without
+ data loss (C1999). */
+typedef __intptr_t intptr_t;
+
+#endif
diff --git a/posix/bits/types/key_t.h b/posix/bits/types/key_t.h
new file mode 100644
index 0000000..424d250
--- /dev/null
+++ b/posix/bits/types/key_t.h
@@ -0,0 +1,9 @@
+#ifndef __key_t_defined
+#define __key_t_defined 1
+
+#include <bits/types.h>
+
+/* Type used by interprocess communication operations (XSI). */
+typedef __key_t key_t;
+
+#endif
diff --git a/posix/bits/types/loff_t.h b/posix/bits/types/loff_t.h
new file mode 100644
index 0000000..ecb9989
--- /dev/null
+++ b/posix/bits/types/loff_t.h
@@ -0,0 +1,9 @@
+#ifndef __loff_t_defined
+#define __loff_t_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete type for file sizes and offsets within a file (BSD). */
+typedef __loff_t loff_t;
+
+#endif
diff --git a/posix/bits/types/mode_t.h b/posix/bits/types/mode_t.h
new file mode 100644
index 0000000..3aaa70d
--- /dev/null
+++ b/posix/bits/types/mode_t.h
@@ -0,0 +1,9 @@
+#ifndef __mode_t_defined
+#define __mode_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file attribute bits (POSIX). */
+typedef __mode_t mode_t;
+
+#endif
diff --git a/posix/bits/types/nlink_t.h b/posix/bits/types/nlink_t.h
new file mode 100644
index 0000000..2f9125b
--- /dev/null
+++ b/posix/bits/types/nlink_t.h
@@ -0,0 +1,9 @@
+#ifndef __nlink_t_defined
+#define __nlink_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for link counts (POSIX). */
+typedef __nlink_t nlink_t;
+
+#endif
diff --git a/posix/bits/types/off64_t.h b/posix/bits/types/off64_t.h
new file mode 100644
index 0000000..f00bd82
--- /dev/null
+++ b/posix/bits/types/off64_t.h
@@ -0,0 +1,9 @@
+#ifndef __off64_t_defined
+#define __off64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file sizes and offsets within a file (LFS). */
+typedef __off64_t off64_t;
+
+#endif
diff --git a/posix/bits/types/off_t.h b/posix/bits/types/off_t.h
new file mode 100644
index 0000000..9ef5395
--- /dev/null
+++ b/posix/bits/types/off_t.h
@@ -0,0 +1,13 @@
+#ifndef __off_t_defined
+#define __off_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file sizes and offsets within a file (POSIX). */
+# ifndef __USE_FILE_OFFSET64
+typedef __off_t off_t;
+# else
+typedef __off64_t off_t;
+# endif
+
+#endif
diff --git a/posix/bits/types/pid_t.h b/posix/bits/types/pid_t.h
new file mode 100644
index 0000000..249e070
--- /dev/null
+++ b/posix/bits/types/pid_t.h
@@ -0,0 +1,9 @@
+#ifndef __pid_t_defined
+#define __pid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for process IDs and process group IDs (POSIX). */
+typedef __pid_t pid_t;
+
+#endif
diff --git a/posix/bits/types/register_t.h b/posix/bits/types/register_t.h
new file mode 100644
index 0000000..099b472
--- /dev/null
+++ b/posix/bits/types/register_t.h
@@ -0,0 +1,9 @@
+#ifndef __register_t_defined
+#define __register_t_defined 1
+
+#include <bits/types.h>
+
+/* Type of a general-purpose integer register (BSD). */
+typedef __register_t register_t;
+
+#endif
diff --git a/posix/bits/types/socklen_t.h b/posix/bits/types/socklen_t.h
new file mode 100644
index 0000000..8369630
--- /dev/null
+++ b/posix/bits/types/socklen_t.h
@@ -0,0 +1,9 @@
+#ifndef __socklen_t_defined
+#define __socklen_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for size of socket addresses (POSIX). */
+typedef __socklen_t socklen_t;
+
+#endif
diff --git a/posix/bits/types/ssize_t.h b/posix/bits/types/ssize_t.h
new file mode 100644
index 0000000..41e1fd7
--- /dev/null
+++ b/posix/bits/types/ssize_t.h
@@ -0,0 +1,9 @@
+#ifndef __ssize_t_defined
+#define __ssize_t_defined 1
+
+#include <bits/types.h>
+
+/* Type used for a count of bytes or an error indication (POSIX). */
+typedef __ssize_t ssize_t;
+
+#endif
diff --git a/posix/bits/types/suseconds_t.h b/posix/bits/types/suseconds_t.h
new file mode 100644
index 0000000..62ded6f
--- /dev/null
+++ b/posix/bits/types/suseconds_t.h
@@ -0,0 +1,9 @@
+#ifndef __suseconds_t_defined
+#define __suseconds_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for time in microseconds (signed) (XSI). */
+typedef __suseconds_t suseconds_t;
+
+#endif
diff --git a/posix/bits/types/u_int.h b/posix/bits/types/u_int.h
new file mode 100644
index 0000000..4c9235f
--- /dev/null
+++ b/posix/bits/types/u_int.h
@@ -0,0 +1,15 @@
+#ifndef __u_int_defined
+#define __u_int_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete shorthand names for unsigned types, used by old BSD
+ networking code and Sun RPC. */
+typedef unsigned char u_char;
+typedef unsigned short int u_short;
+typedef unsigned int u_int;
+typedef unsigned long int u_long;
+typedef __int64_t quad_t;
+typedef __uint64_t u_quad_t;
+
+#endif
diff --git a/posix/bits/types/u_intN_t.h b/posix/bits/types/u_intN_t.h
new file mode 100644
index 0000000..6257674
--- /dev/null
+++ b/posix/bits/types/u_intN_t.h
@@ -0,0 +1,17 @@
+#ifndef __u_intN_t_defined
+#define __u_intN_t_defined 1
+
+#include <bits/types.h>
+
+/* These size-specific names are used by some of the inet code.
+ They were defined by ISO C without the first `_'. */
+typedef __uint8_t u_int8_t;
+typedef __uint16_t u_int16_t;
+typedef __uint32_t u_int32_t;
+typedef __uint64_t u_int64_t;
+
+/* Some code from BIND tests this macro to see if the types above are
+ defined. */
+#define __BIT_TYPES_DEFINED__ 1
+
+#endif
diff --git a/posix/bits/types/uid_t.h b/posix/bits/types/uid_t.h
new file mode 100644
index 0000000..371cb05
--- /dev/null
+++ b/posix/bits/types/uid_t.h
@@ -0,0 +1,9 @@
+#ifndef __uid_t_defined
+#define __uid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for user IDs (POSIX). */
+typedef __uid_t uid_t;
+
+#endif
diff --git a/posix/bits/types/uint.h b/posix/bits/types/uint.h
new file mode 100644
index 0000000..69829c6
--- /dev/null
+++ b/posix/bits/types/uint.h
@@ -0,0 +1,10 @@
+#ifndef __uint_defined
+#define __uint_defined 1
+
+/* Obsolete shorthand names for unsigned types, used by old BSD
+ networking code and Sun RPC. */
+typedef unsigned short int ushort;
+typedef unsigned int uint;
+typedef unsigned long int ulong;
+
+#endif
diff --git a/posix/bits/types/useconds_t.h b/posix/bits/types/useconds_t.h
new file mode 100644
index 0000000..a363558
--- /dev/null
+++ b/posix/bits/types/useconds_t.h
@@ -0,0 +1,9 @@
+#ifndef __useconds_t_defined
+#define __useconds_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for time in microseconds (unsigned) (XSI). */
+typedef __useconds_t useconds_t;
+
+#endif
diff --git a/posix/sched.h b/posix/sched.h
index 90ef6fc..56c1470 100644
--- a/posix/sched.h
+++ b/posix/sched.h
@@ -33,11 +33,7 @@
#ifndef __USE_XOPEN2K
# include <time.h>
#endif
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
+#include <bits/types/pid_t.h>
/* Get system specific constant and data structure definitions. */
#include <bits/sched.h>
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 2d8cfd1..8f6d328 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -28,120 +28,51 @@ __BEGIN_DECLS
#include <bits/types.h>
-#ifdef __USE_MISC
-# ifndef __u_char_defined
-typedef unsigned char u_char;
-typedef unsigned short int u_short;
-typedef unsigned int u_int;
-typedef unsigned long int u_long;
-typedef __int64_t quad_t;
-typedef __uint64_t u_quad_t;
-typedef __fsid_t fsid_t;
-# define __u_char_defined
-# endif
-typedef __loff_t loff_t;
-#endif
-
-#ifndef __ino_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __ino_t ino_t;
-# else
-typedef __ino64_t ino_t;
-# endif
-# define __ino_t_defined
-#endif
-#if defined __USE_LARGEFILE64 && !defined __ino64_t_defined
-typedef __ino64_t ino64_t;
-# define __ino64_t_defined
-#endif
-
-#ifndef __dev_t_defined
-typedef __dev_t dev_t;
-# define __dev_t_defined
-#endif
-
-#ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-#endif
-
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
-
-#ifndef __nlink_t_defined
-typedef __nlink_t nlink_t;
-# define __nlink_t_defined
-#endif
-
-#ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-#endif
-
-#ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-#endif
-#if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
-#endif
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
-
-#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) \
- && !defined __id_t_defined
-typedef __id_t id_t;
-# define __id_t_defined
-#endif
+#define __need_size_t
+#include <stddef.h>
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
+#include <bits/types/blkcnt_t.h>
+#include <bits/types/clockid_t.h>
+#include <bits/types/dev_t.h>
+#include <bits/types/fsblkcnt_t.h>
+#include <bits/types/fsfilcnt_t.h>
+#include <bits/types/gid_t.h>
+#include <bits/types/ino_t.h>
+#include <bits/types/mode_t.h>
+#include <bits/types/nlink_t.h>
+#include <bits/types/off_t.h>
+#include <bits/types/pid_t.h>
+#include <bits/types/ssize_t.h>
+#include <bits/types/time_t.h>
+#include <bits/types/timer_t.h>
+#include <bits/types/uid_t.h>
-#ifdef __USE_MISC
-# ifndef __daddr_t_defined
-typedef __daddr_t daddr_t;
-typedef __caddr_t caddr_t;
-# define __daddr_t_defined
-# endif
+#ifdef __USE_LARGEFILE64
+# include <bits/types/blkcnt64_t.h>
+# include <bits/types/fsblkcnt64_t.h>
+# include <bits/types/fsfilcnt64_t.h>
+# include <bits/types/ino64_t.h>
+# include <bits/types/off64_t.h>
#endif
-#if (defined __USE_MISC || defined __USE_XOPEN) && !defined __key_t_defined
-typedef __key_t key_t;
-# define __key_t_defined
+#ifdef __USE_XOPEN
+# include <bits/types/useconds_t.h>
+# include <bits/types/suseconds_t.h>
#endif
#if defined __USE_XOPEN || defined __USE_XOPEN2K8
# include <bits/types/clock_t.h>
+# include <bits/types/id_t.h>
+# include <bits/types/key_t.h>
#endif
-#include <bits/types/clockid_t.h>
-#include <bits/types/time_t.h>
-#include <bits/types/timer_t.h>
-#ifdef __USE_XOPEN
-# ifndef __useconds_t_defined
-typedef __useconds_t useconds_t;
-# define __useconds_t_defined
-# endif
-# ifndef __suseconds_t_defined
-typedef __suseconds_t suseconds_t;
-# define __suseconds_t_defined
-# endif
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
+#include <bits/types/blksize_t.h>
#endif
-#define __need_size_t
-#include <stddef.h>
+#if defined __USE_POSIX199506 || defined __USE_UNIX98
+# include <bits/pthreadtypes.h>
+#endif
/* POSIX does not require intN_t to be defined in this header, so
technically this ought to be under __USE_MISC, but it doesn't
@@ -150,24 +81,17 @@ typedef __suseconds_t suseconds_t;
#include <bits/stdint-intn.h>
#ifdef __USE_MISC
-/* Old compatibility names for C types. */
-typedef unsigned long int ulong;
-typedef unsigned short int ushort;
-typedef unsigned int uint;
-
-/* These size-specific names are used by some of the inet code.
- They were defined by ISO C without the first `_'. */
-typedef __uint8_t u_int8_t;
-typedef __uint16_t u_int16_t;
-typedef __uint32_t u_int32_t;
-typedef __uint64_t u_int64_t;
-
-/* Type of a general-purpose integer register (BSD). */
-typedef __register_t register_t;
-
-/* Some code from BIND tests this macro to see if the types above are
- defined. */
-#define __BIT_TYPES_DEFINED__ 1
+/* Additional typedefs from BSD, mostly obsolete. */
+# include <bits/types/caddr_t.h>
+# include <bits/types/daddr_t.h>
+# include <bits/types/fsid_t.h>
+# include <bits/types/loff_t.h>
+# include <bits/types/register_t.h>
+
+/* Shorthand unsigned types, mostly superseded by stdint.h. */
+# include <bits/types/uint.h>
+# include <bits/types/u_int.h>
+# include <bits/types/u_intN_t.h>
/* In BSD <sys/types.h> is expected to define BYTE_ORDER. */
# include <endian.h>
@@ -176,54 +100,6 @@ typedef __register_t register_t;
# include <sys/select.h>
#endif /* Use misc. */
-
-#if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) \
- && !defined __blksize_t_defined
-typedef __blksize_t blksize_t;
-# define __blksize_t_defined
-#endif
-
-/* Types from the Large File Support interface. */
-#ifndef __USE_FILE_OFFSET64
-# ifndef __blkcnt_t_defined
-typedef __blkcnt_t blkcnt_t; /* Type to count number of disk blocks. */
-# define __blkcnt_t_defined
-# endif
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#else
-# ifndef __blkcnt_t_defined
-typedef __blkcnt64_t blkcnt_t; /* Type to count number of disk blocks. */
-# define __blkcnt_t_defined
-# endif
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt64_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt64_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#endif
-
-#ifdef __USE_LARGEFILE64
-typedef __blkcnt64_t blkcnt64_t; /* Type to count number of disk blocks. */
-typedef __fsblkcnt64_t fsblkcnt64_t; /* Type to count file system blocks. */
-typedef __fsfilcnt64_t fsfilcnt64_t; /* Type to count file system inodes. */
-#endif
-
-
-/* Now add the thread types. */
-#if defined __USE_POSIX199506 || defined __USE_UNIX98
-# include <bits/pthreadtypes.h>
-#endif
-
__END_DECLS
#endif /* sys/types.h */
diff --git a/posix/sys/wait.h b/posix/sys/wait.h
index 9bd4399..691be27 100644
--- a/posix/sys/wait.h
+++ b/posix/sys/wait.h
@@ -27,10 +27,7 @@
__BEGIN_DECLS
#include <bits/types.h>
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
+#include <bits/types/pid_t.h>
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
# include <signal.h>
@@ -111,11 +108,7 @@ extern __pid_t wait (int *__stat_loc);
extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-# ifndef __id_t_defined
-typedef __id_t id_t;
-# define __id_t_defined
-# endif
-
+# include <bits/types/id_t.h>
# include <bits/types/siginfo_t.h>
/* Wait for a childing matching IDTYPE and ID to change the status and
diff --git a/posix/unistd.h b/posix/unistd.h
index 55a989f..407f2fe 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -215,11 +215,7 @@ __BEGIN_DECLS
/* All functions that are not declared anywhere else. */
#include <bits/types.h>
-
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
+#include <bits/types/ssize_t.h>
#define __need_size_t
#define __need_NULL
@@ -228,52 +224,22 @@ typedef __ssize_t ssize_t;
#if defined __USE_XOPEN || defined __USE_XOPEN2K
/* The Single Unix specification says that some more types are
available here. */
-# ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-# endif
-
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
-
-# ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-# endif
-# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
-# endif
-
-# ifndef __useconds_t_defined
-typedef __useconds_t useconds_t;
-# define __useconds_t_defined
-# endif
-
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
+# include <bits/types/gid_t.h>
+# include <bits/types/uid_t.h>
+# include <bits/types/off_t.h>
+# ifdef __USE_LARGEFILE64
+# include <bits/types/off64_t.h>
# endif
+# include <bits/types/useconds_t.h>
+# include <bits/types/pid_t.h>
#endif /* X/Open */
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
-# ifndef __intptr_t_defined
-typedef __intptr_t intptr_t;
-# define __intptr_t_defined
-# endif
+# include <bits/types/intptr_t.h>
#endif
#if defined __USE_MISC || defined __USE_XOPEN
-# ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-# endif
+# include <bits/types/socklen_t.h>
#endif
/* Values for the second argument to access.
diff --git a/pwd/pwd.h b/pwd/pwd.h
index 1002ed3..ccb3bc0 100644
--- a/pwd/pwd.h
+++ b/pwd/pwd.h
@@ -34,15 +34,8 @@ __BEGIN_DECLS
#if defined __USE_XOPEN || defined __USE_XOPEN2K
/* The Single Unix specification says that some more types are
available here. */
-# ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-# endif
-
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
+# include <bits/types/gid_t.h>
+# include <bits/types/uid_t.h>
#endif
/* A record in the user database. */
diff --git a/resource/sys/resource.h b/resource/sys/resource.h
index 928646b..3ed33c4 100644
--- a/resource/sys/resource.h
+++ b/resource/sys/resource.h
@@ -22,11 +22,7 @@
/* Get the system-dependent definitions of structures and bit values. */
#include <bits/resource.h>
-
-#ifndef __id_t_defined
-typedef __id_t id_t;
-# define __id_t_defined
-#endif
+#include <bits/types/id_t.h>
__BEGIN_DECLS
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 518de75..49338c0 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -28,6 +28,7 @@
import argparse
import collections
+import os.path
import re
import sys
@@ -264,15 +265,40 @@ OBSOLETE_TYPE_RE_ = re.compile(r"""\A
| _(?: char | short | int(?:[0-9]+_t)? | long | quad_t )))
\Z""", re.VERBOSE)
+# The headers that declare them:
+OBSOLETE_TYPE_HDR_RE_ = re.compile(r"""\A
+ [<"] bits/types/
+ (?: [cd]addr_t
+ | loff_t
+ | register_t
+ | uint
+ | u_int
+ | u_intN_t ) \.h [">]
+\Z""", re.VERBOSE)
+
class ObsoleteNotAllowed(ConstructChecker):
- """Don't allow any use of the obsolete typedefs."""
+ """Don't allow any use of the obsolete typedefs,
+ or the headers that declare them."""
def examine(self, tok):
- if OBSOLETE_TYPE_RE_.match(tok.text):
+ if ((tok.kind == "IDENT"
+ and OBSOLETE_TYPE_RE_.match(tok.text))
+ or (tok.kind == "HEADER_NAME"
+ and OBSOLETE_TYPE_HDR_RE_.match(tok.text))):
+ self.reporter.error(tok, "use of {!r}")
+
+class ObsoleteIndirectDefinitionsAllowed(ConstructChecker):
+ """Don't allow any use of the obsolete typedefs,
+ but do allow inclusion of the headers that declare them."""
+ def examine(self, tok):
+ if (tok.kind == "IDENT"
+ and OBSOLETE_TYPE_RE_.match(tok.text)):
self.reporter.error(tok, "use of {!r}")
class ObsoletePrivateDefinitionsAllowed(ConstructChecker):
"""Allow definitions of the private versions of the
obsolete typedefs; that is, 'typedef [anything] __obsolete;'
+ Don't allow inclusion of headers that declare the public
+ versions.
"""
def __init__(self, reporter):
super().__init__(reporter)
@@ -300,10 +326,14 @@ class ObsoletePrivateDefinitionsAllowed(ConstructChecker):
self._check_prev()
def _check_prev(self):
- if (self.prev_token is not None
- and self.prev_token.kind == "IDENT"
- and OBSOLETE_TYPE_RE_.match(self.prev_token.text)):
- self.reporter.error(self.prev_token, "use of {!r}")
+ tok = self.prev_token
+ if tok is None:
+ return
+ if ((tok.kind == "IDENT"
+ and OBSOLETE_TYPE_RE_.match(tok.text))
+ or (tok.kind == "HEADER_NAME"
+ and OBSOLETE_TYPE_HDR_RE_.match(tok.text))):
+ self.reporter.error(tok, "use of {!r}")
class ObsoletePublicDefinitionsAllowed(ConstructChecker):
"""Allow definitions of the public versions of the obsolete
@@ -317,6 +347,9 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
typedef unsigned char u_char;
typedef __int64_t quad_t;
typedef __uint64_t u_quad_t;
+
+ Don't allow inclusion of headers that declare public
+ versions of other obsolete typedefs.
"""
def __init__(self, reporter):
super().__init__(reporter)
@@ -337,6 +370,10 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
elif tok.kind == "PUNCTUATOR" and tok.text == ";":
self._finish()
+ elif tok.kind == "HEADER_NAME":
+ if OBSOLETE_TYPE_HDR_RE_.match(tok.text):
+ self.reporter.error(tok, "use of {!r}")
+
elif self.typedef_tokens:
self.typedef_tokens.append(tok)
@@ -406,19 +443,38 @@ def ObsoleteTypedefChecker(reporter, fname):
or fname.startswith("rpcsvc/")
or "/rpc/" in fname
or "/rpcsvc/" in fname):
+ sys.stderr.write("# No typedef checks for {}\n".format(fname))
return NoCheck(reporter)
# bits/types.h is allowed to define the __-versions of the
# obsolete types.
if (fname == "bits/types.h"
or fname.endswith("/bits/types.h")):
+ sys.stderr.write("# Obsolete private defs allowed for {}\n"
+ .format(fname))
return ObsoletePrivateDefinitionsAllowed(reporter)
- # sys/types.h is allowed to use the __-versions of the
- # obsolete types, but only to define the unprefixed versions.
+ # Certain bits/types/ headers are allowed to define the
+ # unprefixed versions of the obsolete types.
+ if ((fname.startswith("bits/types/")
+ or "/bits/types/" in fname)
+ and os.path.basename(fname) in ("caddr_t.h",
+ "daddr_t.h",
+ "loff_t.h",
+ "register_t.h",
+ "uint.h",
+ "u_int.h",
+ "u_intN_t.h")):
+ sys.stderr.write("# Obsolete public defs allowed for {}\n"
+ .format(fname))
+ return ObsoletePublicDefinitionsAllowed(reporter)
+
+ # sys/types.h is allowed to include the above bits/types/ headers.
if (fname == "sys/types.h"
or fname.endswith("/sys/types.h")):
- return ObsoletePublicDefinitionsAllowed(reporter)
+ sys.stderr.write("# Obsolete indirect defs allowed for {}\n"
+ .format(fname))
+ return ObsoleteIndirectDefinitionsAllowed(reporter)
return ObsoleteNotAllowed(reporter)
diff --git a/signal/signal.h b/signal/signal.h
index 4c0de7f..ec70101 100644
--- a/signal/signal.h
+++ b/signal/signal.h
@@ -36,16 +36,8 @@ __BEGIN_DECLS
#endif
#if defined __USE_XOPEN || defined __USE_XOPEN2K
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
-#ifdef __USE_XOPEN
-# endif
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
+# include <bits/types/pid_t.h>
+# include <bits/types/uid_t.h>
#endif /* Unix98 */
#ifdef __USE_POSIX199309
diff --git a/stdlib/monetary.h b/stdlib/monetary.h
index 1cecd05..1f3347a 100644
--- a/stdlib/monetary.h
+++ b/stdlib/monetary.h
@@ -25,12 +25,7 @@
#define __need_size_t
#include <stddef.h>
#include <bits/types.h>
-
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
-
+#include <bits/types/ssize_t.h>
__BEGIN_DECLS
diff --git a/stdlib/stdint.h b/stdlib/stdint.h
index 8645d91..aca50d1 100644
--- a/stdlib/stdint.h
+++ b/stdlib/stdint.h
@@ -82,10 +82,7 @@ typedef unsigned long long int uint_fast64_t;
/* Types for `void *' pointers. */
-# ifndef __intptr_t_defined
-typedef __intptr_t intptr_t;
-# define __intptr_t_defined
-# endif
+#include <bits/types/intptr_t.h>
typedef __uintptr_t uintptr_t;
/* Largest integral types. */
diff --git a/sunrpc/rpc/types.h b/sunrpc/rpc/types.h
index 99e5f4f..13ef47f 100644
--- a/sunrpc/rpc/types.h
+++ b/sunrpc/rpc/types.h
@@ -34,6 +34,19 @@
#ifndef _RPC_TYPES_H
#define _RPC_TYPES_H 1
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/param.h>
+#include <netinet/in.h>
+
+#ifndef __BIT_TYPES_DEFINED__
+#include <bits/types/caddr_t.h>
+#include <bits/types/daddr_t.h>
+#include <bits/types/fsid_t.h>
+#include <bits/types/u_int.h>
+#endif
+
typedef int bool_t;
typedef int enum_t;
/* This needs to be changed to uint32_t in the future */
@@ -57,7 +70,6 @@ typedef unsigned long rpcport_t;
# define NULL 0
#endif
-#include <stdlib.h> /* For malloc decl. */
#define mem_alloc(bsize) malloc(bsize)
/*
* XXX: This must not use the second argument, or code in xdr_array.c needs
@@ -65,36 +77,6 @@ typedef unsigned long rpcport_t;
*/
#define mem_free(ptr, bsize) free(ptr)
-#ifndef makedev /* ie, we haven't already included it */
-#include <sys/types.h>
-#endif
-
-#if defined __APPLE_CC__ || defined __FreeBSD__
-# define __u_char_defined
-# define __daddr_t_defined
-#endif
-
-#ifndef __u_char_defined
-typedef unsigned char u_char;
-typedef unsigned short int u_short;
-typedef unsigned int u_int;
-typedef unsigned long int u_long;
-typedef __int64_t quad_t;
-typedef __uint64_t u_quad_t;
-typedef __fsid_t fsid_t;
-# define __u_char_defined
-#endif
-#ifndef __daddr_t_defined
-typedef __daddr_t daddr_t;
-typedef __caddr_t caddr_t;
-# define __daddr_t_defined
-#endif
-
-#include <sys/time.h>
-#include <sys/param.h>
-
-#include <netinet/in.h>
-
#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK (u_long)0x7F000001
#endif
diff --git a/sysdeps/gnu/utmpx.h b/sysdeps/gnu/utmpx.h
index 9274102..41c122d 100644
--- a/sysdeps/gnu/utmpx.h
+++ b/sysdeps/gnu/utmpx.h
@@ -22,10 +22,7 @@
#include <sys/time.h>
/* Required according to Unix98. */
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
+#include <bits/types/pid_t.h>
/* Get system dependent values and data structures. */
#include <bits/utmpx.h>
diff --git a/sysdeps/mach/hurd/bits/socket.h b/sysdeps/mach/hurd/bits/socket.h
index f7f3cc4..429e66c 100644
--- a/sysdeps/mach/hurd/bits/socket.h
+++ b/sysdeps/mach/hurd/bits/socket.h
@@ -29,13 +29,7 @@
#include <bits/wordsize.h>
#include <sys/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
-
+#include <bits/types/socklen_t.h>
/* Types of sockets. */
enum __socket_type
diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h
index 99af01d..cf3c03a 100644
--- a/sysdeps/unix/sysv/linux/bits/socket.h
+++ b/sysdeps/unix/sysv/linux/bits/socket.h
@@ -27,12 +27,7 @@
#include <stddef.h>
#include <sys/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
+#include <bits/types/socklen_t.h>
/* Get the architecture-dependent definition of enum __socket_type. */
#include <bits/socket_type.h>
diff --git a/sysvipc/sys/ipc.h b/sysvipc/sys/ipc.h
index 516e275..8aa7f38 100644
--- a/sysvipc/sys/ipc.h
+++ b/sysvipc/sys/ipc.h
@@ -23,26 +23,10 @@
/* Get system dependent definition of `struct ipc_perm' and more. */
#include <bits/ipctypes.h>
#include <bits/ipc.h>
-
-#ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-#endif
-
-#ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-#endif
-
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
-
-#ifndef __key_t_defined
-typedef __key_t key_t;
-# define __key_t_defined
-#endif
+#include <bits/types/uid_t.h>
+#include <bits/types/gid_t.h>
+#include <bits/types/mode_t.h>
+#include <bits/types/key_t.h>
__BEGIN_DECLS
diff --git a/sysvipc/sys/msg.h b/sysvipc/sys/msg.h
index 1ce4672..f2f18f4 100644
--- a/sysvipc/sys/msg.h
+++ b/sysvipc/sys/msg.h
@@ -31,16 +31,8 @@
/* Define types required by the standard. */
#include <bits/types/time_t.h>
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
-
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
+#include <bits/types/pid_t.h>
+#include <bits/types/ssize_t.h>
/* The following System V style IPC functions implement a message queue
system. The definition is found in XPG2. */
diff --git a/sysvipc/sys/shm.h b/sysvipc/sys/shm.h
index c15f419..bf836a7 100644
--- a/sysvipc/sys/shm.h
+++ b/sysvipc/sys/shm.h
@@ -31,14 +31,9 @@
/* Define types required by the standard. */
#include <bits/types/time_t.h>
-
#ifdef __USE_XOPEN
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-# endif
-#endif /* X/Open */
-
+# include <bits/types/pid_t.h>
+#endif
__BEGIN_DECLS
diff --git a/termios/termios.h b/termios/termios.h
index 2234208..b883dc8 100644
--- a/termios/termios.h
+++ b/termios/termios.h
@@ -23,13 +23,9 @@
#define _TERMIOS_H 1
#include <features.h>
+
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-/* We need `pid_t'. */
-# include <bits/types.h>
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-# endif
+# include <bits/types/pid_t.h>
#endif
__BEGIN_DECLS
diff --git a/time/sys/time.h b/time/sys/time.h
index 5dbc7fc..1059d30 100644
--- a/time/sys/time.h
+++ b/time/sys/time.h
@@ -23,11 +23,7 @@
#include <bits/types.h>
#include <bits/types/time_t.h>
#include <bits/types/struct_timeval.h>
-
-#ifndef __suseconds_t_defined
-typedef __suseconds_t suseconds_t;
-# define __suseconds_t_defined
-#endif
+#include <bits/types/suseconds_t.h>
#include <sys/select.h>
diff --git a/time/time.h b/time/time.h
index cba6d15..232531c 100644
--- a/time/time.h
+++ b/time/time.h
@@ -50,10 +50,7 @@ struct sigevent;
#endif
#ifdef __USE_XOPEN2K
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-# endif
+# include <bits/types/pid_t.h>
#endif
#ifdef __USE_XOPEN2K8
^ permalink raw reply [flat|nested] 4+ messages in thread
* [glibc/zack/no-nested-includes] Create bits/types headers for most remaining __T_defined macros.
@ 2020-01-08 19:19 Zack Weinberg
0 siblings, 0 replies; 4+ messages in thread
From: Zack Weinberg @ 2020-01-08 19:19 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d5ebebf969165c51e6a9fcff3a21b6591269eaea
commit d5ebebf969165c51e6a9fcff3a21b6591269eaea
Author: Zack Weinberg <zackw@panix.com>
Date: Sat Mar 9 20:54:02 2019 -0500
Create bits/types headers for most remaining __T_defined macros.
This doesn't exactly fit the theme but as long as I'm tinkering with
sys/types.h it makes sense to go through and create single-declaration
bits/types/ headers for all of the remaining cases where we have
two or more headers declaring a public type.
The remaining uses of the original __T_defined idiom are:
__error_t_defined in files shared with gnulib, which probably has to
remain as is; ____gwchar_t_defined in inttypes.h, which may not be
necessary anymore and should be addressed separately, and
__ldiv_t_defined and __lldiv_t_defined in stdlib.h, ditto.
Our handling of LFS types is a little inconsistent: some headers
declare both off_t and off64_t (for instance) when
_LARGEFILE64_SOURCE, others will only declare off_t regardless of
_LARGEFILE64_SOURCE. I don't know if this was intentional or not.
I am tempted to centralize responsibility for _LARGEFILE64_SOURCE as
well as _FILE_OFFSET_BITS=64 in bits/types/off_t.h (etc) so that any
header that declares off_t will automatically also declare off64_t
when _LARGEFILE64_SOURCE.
sunrpc/rpc/types.h is special, because it is included in files
compiled by the *build* compiler (cross-rpcgen-objs), and therefore it
cannot unconditionally assume bits/types headers are available. What
I did was have it include the appropriate bits/types headers only if
including sys/types.h did not cause __BIT_TYPES_DEFINED__ to be
defined. This will do the right thing when an installed rpc/types.h
is included by application code compiled without __USE_MISC in effect.
During the build, we rely on the fact that we compile all of our own
code with __USE_MISC in effect. This is fragile, but should be
acceptable for code that's no longer built by default anyway.
scripts/check-obsolete-constructs.py ensures that only sys/types.h and
rpc/types.h include the bits/types/ headers that define obsolete types.
* posix/bits/types/blkcnt64_t.h
* posix/bits/types/blkcnt_t.h
* posix/bits/types/blksize_t.h
* posix/bits/types/dev_t.h
* posix/bits/types/fsblkcnt64_t.h
* posix/bits/types/fsblkcnt_t.h
* posix/bits/types/fsfilcnt64_t.h
* posix/bits/types/fsfilcnt_t.h
* posix/bits/types/fsid_t.h
* posix/bits/types/gid_t.h
* posix/bits/types/id_t.h
* posix/bits/types/ino64_t.h
* posix/bits/types/ino_t.h
* posix/bits/types/intptr_t.h
* posix/bits/types/key_t.h
* posix/bits/types/loff_t.h
* posix/bits/types/mode_t.h
* posix/bits/types/nlink_t.h
* posix/bits/types/off64_t.h
* posix/bits/types/off_t.h
* posix/bits/types/pid_t.h
* posix/bits/types/socklen_t.h
* posix/bits/types/ssize_t.h
* posix/bits/types/suseconds_t.h
* posix/bits/types/uid_t.h
* posix/bits/types/useconds_t.h:
New single-declaration headers for standard types canonically
defined by sys/types.h, sys/socket.h, or inttypes.h but also
exposed by other headers under some circumstances. Code moved
from posix/sys/types.h, socket/sys/socket.h, stdlib/inttypes.h
as appropriate.
* posix/bits/types/uint.h
* posix/bits/types/u_int.h
* posix/bits/types/u_intN_t.h
* posix/bits/types/caddr_t.h
* posix/bits/types/daddr_t.h
* posix/bits/types/loff_t.h
* posix/bits/types/register_t.h:
Similarly, but for obsolete BSD-derived types whose canonical
home is sys/types.h. Some of these headers define more than
one type.
* posix/Makefile (headers): Install the above new headers.
Rewrap the list.
* posix/sys/types.h: All definitions of public types now
accomplished using the above new headers. Consolidate
groups of definitions controlled by the same feature
selection macros.
* inet/arpa/inet.h, bits/socket.h
* sysdeps/mach/hurd/bits/socket.h
* sysdeps/unix/sysv/linux/bits/socket.h:
Use bits/types/socklen_t.h.
* dirent/dirent.h: Use bits/types/ino_t.h and bits/types/ino64_t.h.
* grp/grp.h: Use bits/types/gid_t.h.
* io/fcntl.h: Use bits/types/mode_t.h, bits/types/off_t.h,
bits/types/pid_t.h, and bits/types/off64_t.h.
* io/sys/stat.h: Use bits/types/dev_t.h, bits/types/gid_t.h,
bits/types/ino_t.h, bits/types/mode_t.h, bits/types/nlink_t.h,
bits/types/off_t.h, bits/types/uid_t.h, and bits/types/blkcnt_t.h.
* libio/stdio.h: Use bits/types/off_t.h, bits/types/off64_t.h,
and bits/types/ssize_t.h.
* misc/sys/mman.h: Use bits/types/off_t.h and bits/types/mode_t.h.
* misc/sys/select.h: Use bits/types/suseconds_t.h.
* posix/sched.h: Use bits/types/pid_t.h.
* posix/sys/wait.h: Use bits/types/pid_t.h and bits/types/id_t.h.
* posix/unistd.h: Use bits/types/gid_t.h, bits/types/uid_t.h,
bits/types/off_t.h, bits/types/off64_t.h, bits/types/useconds_t.h,
bits/types/intptr_t.h, and bits/types/socklen_t.h.
* pwd/pwd.h: Use bits/types/gid_t.h and bits/types/uid_t.h.
* resource/sys/resource.h: Use bits/types/id_t.h.
* signal/signal.h: Use bits/types/pid_t.h and bits/types/uid_t.h.
* stdlib/monetary.h: Use bits/types/ssize_t.h.
* sysdeps/gnu/utmpx.h: Use bits/types/pid_t.h.
* sysvipc/sys/ipc.h: Use bits/types/uid_t.h, bits/types/gid_t.h,
bits/types/mode_t.h, and bits/types/key_t.h.
* sysvipc/sys/msg.h: Use bits/types/pid_t.h and bits/types/ssize_t.h.
* sysvipc/sys/shm.h: Use bits/types/pid_t.h.
* termios/termios.h: Use bits/types/pid_t.h.
* time/sys/time.h: Use bits/types/suseconds_t.h.
* time/time.h: Use bits/types/pid_t.h.
* sunrpc/rpc/types.h: Consolidate all #includes at the top of
the file. If __BIT_TYPES_DEFINED__ is not defined after
including sys/types.h, also include bits/types/caddr_t.h,
bits/types/daddr_t.h, bits/types/fsid_t.h, and bits/types/u_int.h.
* scripts/check-obsolete-constructs.py (OBSOLETE_TYPE_HDR_RE_): New.
(ObsoleteIndirectDefinitionsAllowed): New; allows inclusion of
bits/types/ headers that define obsolete typedefs, but not
direct definitions of those types.
(ObsoleteNotAllowed, ObsoletePrivateDefinitionsAllowed)
(ObsoletePublicDefinitionsAllowed): Do not allow inclusion of
bits/types/ headers that define obsolete typedefs.
* include/bits/types/blkcnt64_t.h
* include/bits/types/blkcnt_t.h
* include/bits/types/blksize_t.h
* include/bits/types/caddr_t.h
* include/bits/types/daddr_t.h
* include/bits/types/dev_t.h
* include/bits/types/fsblkcnt64_t.h
* include/bits/types/fsblkcnt_t.h
* include/bits/types/fsfilcnt64_t.h
* include/bits/types/fsfilcnt_t.h
* include/bits/types/fsid_t.h
* include/bits/types/gid_t.h
* include/bits/types/id_t.h
* include/bits/types/ino64_t.h
* include/bits/types/ino_t.h
* include/bits/types/intptr_t.h
* include/bits/types/key_t.h
* include/bits/types/loff_t.h
* include/bits/types/mode_t.h
* include/bits/types/nlink_t.h
* include/bits/types/off64_t.h
* include/bits/types/off_t.h
* include/bits/types/pid_t.h
* include/bits/types/register_t.h
* include/bits/types/socklen_t.h
* include/bits/types/ssize_t.h
* include/bits/types/suseconds_t.h
* include/bits/types/u_char.h
* include/bits/types/u_intN_t.h
* include/bits/types/uchar.h
* include/bits/types/uid_t.h
* include/bits/types/useconds_t.h: New wrappers.
Diff:
---
bits/socket.h | 8 +-
dirent/dirent.h | 14 +--
grp/grp.h | 6 +-
include/bits/types/blkcnt64_t.h | 1 +
include/bits/types/blkcnt_t.h | 1 +
include/bits/types/blksize_t.h | 1 +
include/bits/types/caddr_t.h | 1 +
include/bits/types/daddr_t.h | 1 +
include/bits/types/dev_t.h | 1 +
include/bits/types/fsblkcnt64_t.h | 1 +
include/bits/types/fsblkcnt_t.h | 1 +
include/bits/types/fsfilcnt64_t.h | 1 +
include/bits/types/fsfilcnt_t.h | 1 +
include/bits/types/fsid_t.h | 1 +
include/bits/types/gid_t.h | 1 +
include/bits/types/id_t.h | 1 +
include/bits/types/ino64_t.h | 1 +
include/bits/types/ino_t.h | 1 +
include/bits/types/intptr_t.h | 1 +
include/bits/types/key_t.h | 1 +
include/bits/types/loff_t.h | 1 +
include/bits/types/mode_t.h | 1 +
include/bits/types/nlink_t.h | 1 +
include/bits/types/off64_t.h | 1 +
include/bits/types/off_t.h | 1 +
include/bits/types/pid_t.h | 1 +
include/bits/types/register_t.h | 1 +
include/bits/types/socklen_t.h | 1 +
include/bits/types/ssize_t.h | 1 +
include/bits/types/suseconds_t.h | 1 +
include/bits/types/u_int.h | 1 +
include/bits/types/u_intN_t.h | 1 +
include/bits/types/uid_t.h | 1 +
include/bits/types/uint.h | 1 +
include/bits/types/useconds_t.h | 1 +
inet/arpa/inet.h | 7 +-
io/fcntl.h | 27 +----
io/sys/stat.h | 66 ++---------
io/sys/statvfs.h | 21 +---
libio/stdio.h | 19 +--
misc/sys/mman.h | 16 +--
misc/sys/select.h | 7 +-
posix/Makefile | 37 ++++--
posix/bits/types/blkcnt64_t.h | 9 ++
posix/bits/types/blkcnt_t.h | 13 +++
posix/bits/types/blksize_t.h | 9 ++
posix/bits/types/caddr_t.h | 9 ++
posix/bits/types/daddr_t.h | 9 ++
posix/bits/types/dev_t.h | 9 ++
posix/bits/types/fsblkcnt64_t.h | 9 ++
posix/bits/types/fsblkcnt_t.h | 13 +++
posix/bits/types/fsfilcnt64_t.h | 9 ++
posix/bits/types/fsfilcnt_t.h | 13 +++
posix/bits/types/fsid_t.h | 9 ++
posix/bits/types/gid_t.h | 9 ++
posix/bits/types/id_t.h | 10 ++
posix/bits/types/ino64_t.h | 9 ++
posix/bits/types/ino_t.h | 13 +++
posix/bits/types/intptr_t.h | 10 ++
posix/bits/types/key_t.h | 9 ++
posix/bits/types/loff_t.h | 9 ++
posix/bits/types/mode_t.h | 9 ++
posix/bits/types/nlink_t.h | 9 ++
posix/bits/types/off64_t.h | 9 ++
posix/bits/types/off_t.h | 13 +++
posix/bits/types/pid_t.h | 9 ++
posix/bits/types/register_t.h | 9 ++
posix/bits/types/socklen_t.h | 9 ++
posix/bits/types/ssize_t.h | 9 ++
posix/bits/types/suseconds_t.h | 9 ++
posix/bits/types/u_int.h | 15 +++
posix/bits/types/u_intN_t.h | 17 +++
posix/bits/types/uid_t.h | 9 ++
posix/bits/types/uint.h | 10 ++
posix/bits/types/useconds_t.h | 9 ++
posix/sched.h | 6 +-
posix/sys/types.h | 212 +++++++---------------------------
posix/sys/wait.h | 11 +-
posix/unistd.h | 54 ++-------
pwd/pwd.h | 11 +-
resource/sys/resource.h | 6 +-
scripts/check-obsolete-constructs.py | 74 ++++++++++--
signal/signal.h | 12 +-
stdlib/monetary.h | 7 +-
stdlib/stdint.h | 5 +-
sunrpc/rpc/types.h | 44 +++----
sysdeps/gnu/utmpx.h | 5 +-
sysdeps/mach/hurd/bits/socket.h | 8 +-
sysdeps/unix/sysv/linux/bits/socket.h | 7 +-
sysvipc/sys/ipc.h | 24 +---
sysvipc/sys/msg.h | 12 +-
sysvipc/sys/shm.h | 9 +-
termios/termios.h | 8 +-
time/sys/time.h | 6 +-
time/time.h | 5 +-
95 files changed, 571 insertions(+), 540 deletions(-)
diff --git a/bits/socket.h b/bits/socket.h
index bebb2e7..e72dcfd 100644
--- a/bits/socket.h
+++ b/bits/socket.h
@@ -28,13 +28,7 @@
#include <bits/wordsize.h>
#include <bits/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
-
+#include <bits/types/socklen_t.h>
/* Types of sockets. */
enum __socket_type
diff --git a/dirent/dirent.h b/dirent/dirent.h
index 92d0925..0886b6d 100644
--- a/dirent/dirent.h
+++ b/dirent/dirent.h
@@ -29,17 +29,9 @@ __BEGIN_DECLS
#include <bits/types.h>
#ifdef __USE_XOPEN
-# ifndef __ino_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __ino_t ino_t;
-# else
-typedef __ino64_t ino_t;
-# endif
-# define __ino_t_defined
-# endif
-# if defined __USE_LARGEFILE64 && !defined __ino64_t_defined
-typedef __ino64_t ino64_t;
-# define __ino64_t_defined
+# include <bits/types/ino_t.h>
+# ifdef __USE_LARGEFILE64
+# include <bits/types/ino64_t.h>
# endif
#endif
diff --git a/grp/grp.h b/grp/grp.h
index 396ef05..5ef235e 100644
--- a/grp/grp.h
+++ b/grp/grp.h
@@ -31,11 +31,9 @@ __BEGIN_DECLS
#define __need_size_t
#include <stddef.h>
-
/* For the Single Unix specification we must define this type here. */
-#if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
+#if defined __USE_XOPEN || defined __USE_XOPEN2K
+# include <bits/types/gid_t.h>
#endif
/* The group structure. */
diff --git a/include/bits/types/blkcnt64_t.h b/include/bits/types/blkcnt64_t.h
new file mode 100644
index 0000000..c0c2ced
--- /dev/null
+++ b/include/bits/types/blkcnt64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/blkcnt64_t.h>
diff --git a/include/bits/types/blkcnt_t.h b/include/bits/types/blkcnt_t.h
new file mode 100644
index 0000000..ad8ed24
--- /dev/null
+++ b/include/bits/types/blkcnt_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/blkcnt_t.h>
diff --git a/include/bits/types/blksize_t.h b/include/bits/types/blksize_t.h
new file mode 100644
index 0000000..d6ed861
--- /dev/null
+++ b/include/bits/types/blksize_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/blksize_t.h>
diff --git a/include/bits/types/caddr_t.h b/include/bits/types/caddr_t.h
new file mode 100644
index 0000000..9d499e7
--- /dev/null
+++ b/include/bits/types/caddr_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/caddr_t.h>
diff --git a/include/bits/types/daddr_t.h b/include/bits/types/daddr_t.h
new file mode 100644
index 0000000..90050fa
--- /dev/null
+++ b/include/bits/types/daddr_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/daddr_t.h>
diff --git a/include/bits/types/dev_t.h b/include/bits/types/dev_t.h
new file mode 100644
index 0000000..f0451c0
--- /dev/null
+++ b/include/bits/types/dev_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/dev_t.h>
diff --git a/include/bits/types/fsblkcnt64_t.h b/include/bits/types/fsblkcnt64_t.h
new file mode 100644
index 0000000..b5951d5
--- /dev/null
+++ b/include/bits/types/fsblkcnt64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsblkcnt64_t.h>
diff --git a/include/bits/types/fsblkcnt_t.h b/include/bits/types/fsblkcnt_t.h
new file mode 100644
index 0000000..9fc9e41
--- /dev/null
+++ b/include/bits/types/fsblkcnt_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsblkcnt_t.h>
diff --git a/include/bits/types/fsfilcnt64_t.h b/include/bits/types/fsfilcnt64_t.h
new file mode 100644
index 0000000..d3152d4
--- /dev/null
+++ b/include/bits/types/fsfilcnt64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsfilcnt64_t.h>
diff --git a/include/bits/types/fsfilcnt_t.h b/include/bits/types/fsfilcnt_t.h
new file mode 100644
index 0000000..fc092c5
--- /dev/null
+++ b/include/bits/types/fsfilcnt_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsfilcnt_t.h>
diff --git a/include/bits/types/fsid_t.h b/include/bits/types/fsid_t.h
new file mode 100644
index 0000000..9d1e517
--- /dev/null
+++ b/include/bits/types/fsid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsid_t.h>
diff --git a/include/bits/types/gid_t.h b/include/bits/types/gid_t.h
new file mode 100644
index 0000000..d8cf23b
--- /dev/null
+++ b/include/bits/types/gid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/gid_t.h>
diff --git a/include/bits/types/id_t.h b/include/bits/types/id_t.h
new file mode 100644
index 0000000..5eaae0b
--- /dev/null
+++ b/include/bits/types/id_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/id_t.h>
diff --git a/include/bits/types/ino64_t.h b/include/bits/types/ino64_t.h
new file mode 100644
index 0000000..4203764
--- /dev/null
+++ b/include/bits/types/ino64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/ino64_t.h>
diff --git a/include/bits/types/ino_t.h b/include/bits/types/ino_t.h
new file mode 100644
index 0000000..2624ae5
--- /dev/null
+++ b/include/bits/types/ino_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/ino_t.h>
diff --git a/include/bits/types/intptr_t.h b/include/bits/types/intptr_t.h
new file mode 100644
index 0000000..455151b
--- /dev/null
+++ b/include/bits/types/intptr_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/intptr_t.h>
diff --git a/include/bits/types/key_t.h b/include/bits/types/key_t.h
new file mode 100644
index 0000000..c4d96aa
--- /dev/null
+++ b/include/bits/types/key_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/key_t.h>
diff --git a/include/bits/types/loff_t.h b/include/bits/types/loff_t.h
new file mode 100644
index 0000000..933175c
--- /dev/null
+++ b/include/bits/types/loff_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/loff_t.h>
diff --git a/include/bits/types/mode_t.h b/include/bits/types/mode_t.h
new file mode 100644
index 0000000..58602b5
--- /dev/null
+++ b/include/bits/types/mode_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/mode_t.h>
diff --git a/include/bits/types/nlink_t.h b/include/bits/types/nlink_t.h
new file mode 100644
index 0000000..f330ae2
--- /dev/null
+++ b/include/bits/types/nlink_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/nlink_t.h>
diff --git a/include/bits/types/off64_t.h b/include/bits/types/off64_t.h
new file mode 100644
index 0000000..002d920
--- /dev/null
+++ b/include/bits/types/off64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/off64_t.h>
diff --git a/include/bits/types/off_t.h b/include/bits/types/off_t.h
new file mode 100644
index 0000000..1f18d15
--- /dev/null
+++ b/include/bits/types/off_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/off_t.h>
diff --git a/include/bits/types/pid_t.h b/include/bits/types/pid_t.h
new file mode 100644
index 0000000..6de6aff
--- /dev/null
+++ b/include/bits/types/pid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/pid_t.h>
diff --git a/include/bits/types/register_t.h b/include/bits/types/register_t.h
new file mode 100644
index 0000000..6828620
--- /dev/null
+++ b/include/bits/types/register_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/register_t.h>
diff --git a/include/bits/types/socklen_t.h b/include/bits/types/socklen_t.h
new file mode 100644
index 0000000..229f676
--- /dev/null
+++ b/include/bits/types/socklen_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/socklen_t.h>
diff --git a/include/bits/types/ssize_t.h b/include/bits/types/ssize_t.h
new file mode 100644
index 0000000..374e438
--- /dev/null
+++ b/include/bits/types/ssize_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/ssize_t.h>
diff --git a/include/bits/types/suseconds_t.h b/include/bits/types/suseconds_t.h
new file mode 100644
index 0000000..85f0dbe
--- /dev/null
+++ b/include/bits/types/suseconds_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/suseconds_t.h>
diff --git a/include/bits/types/u_int.h b/include/bits/types/u_int.h
new file mode 100644
index 0000000..2b17d5b
--- /dev/null
+++ b/include/bits/types/u_int.h
@@ -0,0 +1 @@
+#include <posix/bits/types/u_int.h>
diff --git a/include/bits/types/u_intN_t.h b/include/bits/types/u_intN_t.h
new file mode 100644
index 0000000..ffb17bc
--- /dev/null
+++ b/include/bits/types/u_intN_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/u_intN_t.h>
diff --git a/include/bits/types/uid_t.h b/include/bits/types/uid_t.h
new file mode 100644
index 0000000..1e2b106
--- /dev/null
+++ b/include/bits/types/uid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/uid_t.h>
diff --git a/include/bits/types/uint.h b/include/bits/types/uint.h
new file mode 100644
index 0000000..a446b7f
--- /dev/null
+++ b/include/bits/types/uint.h
@@ -0,0 +1 @@
+#include <posix/bits/types/uint.h>
diff --git a/include/bits/types/useconds_t.h b/include/bits/types/useconds_t.h
new file mode 100644
index 0000000..71f720b
--- /dev/null
+++ b/include/bits/types/useconds_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/useconds_t.h>
diff --git a/inet/arpa/inet.h b/inet/arpa/inet.h
index 651fc69..0883724 100644
--- a/inet/arpa/inet.h
+++ b/inet/arpa/inet.h
@@ -20,12 +20,7 @@
#include <features.h>
#include <netinet/in.h> /* To define `struct in_addr'. */
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
+#include <bits/types/socklen_t.h>
__BEGIN_DECLS
diff --git a/io/fcntl.h b/io/fcntl.h
index 21b60c2..0ca71e3 100644
--- a/io/fcntl.h
+++ b/io/fcntl.h
@@ -46,28 +46,11 @@ __BEGIN_DECLS
/* POSIX.1-2001 specifies that these types are defined by <fcntl.h>.
Earlier POSIX standards permitted any type ending in `_t' to be defined
by any POSIX header, so we don't conditionalize the definitions here. */
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
-
-#ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-#endif
-
-#if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
-#endif
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
+#include <bits/types/mode_t.h>
+#include <bits/types/off_t.h>
+#include <bits/types/pid_t.h>
+#ifdef __USE_LARGEFILE64
+#include <bits/types/off64_t.h>
#endif
/* For XPG all symbols from <sys/stat.h> should also be available. */
diff --git a/io/sys/stat.h b/io/sys/stat.h
index ce014d0..cbadf67 100644
--- a/io/sys/stat.h
+++ b/io/sys/stat.h
@@ -33,67 +33,19 @@
#if defined __USE_XOPEN || defined __USE_XOPEN2K
/* The Single Unix specification says that some more types are
available here. */
-
# include <bits/types/time_t.h>
-
-# ifndef __dev_t_defined
-typedef __dev_t dev_t;
-# define __dev_t_defined
-# endif
-
-# ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-# endif
-
-# ifndef __ino_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __ino_t ino_t;
-# else
-typedef __ino64_t ino_t;
-# endif
-# define __ino_t_defined
-# endif
-
-# ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-# endif
-
-# ifndef __nlink_t_defined
-typedef __nlink_t nlink_t;
-# define __nlink_t_defined
-# endif
-
-# ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-# endif
-
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
+# include <bits/types/dev_t.h>
+# include <bits/types/gid_t.h>
+# include <bits/types/ino_t.h>
+# include <bits/types/mode_t.h>
+# include <bits/types/nlink_t.h>
+# include <bits/types/off_t.h>
+# include <bits/types/uid_t.h>
#endif /* X/Open */
#ifdef __USE_UNIX98
-# ifndef __blkcnt_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __blkcnt_t blkcnt_t;
-# else
-typedef __blkcnt64_t blkcnt_t;
-# endif
-# define __blkcnt_t_defined
-# endif
-
-# ifndef __blksize_t_defined
-typedef __blksize_t blksize_t;
-# define __blksize_t_defined
-# endif
+# include <bits/types/blkcnt_t.h>
+# include <bits/types/blksize_t.h>
#endif /* Unix98 */
__BEGIN_DECLS
diff --git a/io/sys/statvfs.h b/io/sys/statvfs.h
index 568e264..41cb379 100644
--- a/io/sys/statvfs.h
+++ b/io/sys/statvfs.h
@@ -24,25 +24,8 @@
/* Get the system-specific definition of `struct statfs'. */
#include <bits/statvfs.h>
-#ifndef __USE_FILE_OFFSET64
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#else
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt64_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt64_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#endif
+#include <bits/types/fsblkcnt_t.h>
+#include <bits/types/fsfilcnt_t.h>
__BEGIN_DECLS
diff --git a/libio/stdio.h b/libio/stdio.h
index 5a10a4d..cf99970 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -58,25 +58,14 @@ typedef __gnuc_va_list va_list;
#endif
#if defined __USE_UNIX98 || defined __USE_XOPEN2K
-# ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-# endif
-# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
+# include <bits/types/off_t.h>
+# ifdef __USE_LARGEFILE64
+# include <bits/types/off64_t.h>
# endif
#endif
#ifdef __USE_XOPEN2K8
-# ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-# endif
+# include <bits/types/ssize_t.h>
#endif
/* The type of the second argument to `fgetpos' and `fsetpos'. */
diff --git a/misc/sys/mman.h b/misc/sys/mman.h
index 02abf58..01cc640 100644
--- a/misc/sys/mman.h
+++ b/misc/sys/mman.h
@@ -21,22 +21,12 @@
#include <features.h>
#include <bits/types.h>
+
#define __need_size_t
#include <stddef.h>
-#ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-#endif
-
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
+#include <bits/types/off_t.h>
+#include <bits/types/mode_t.h>
#include <bits/mman.h>
diff --git a/misc/sys/select.h b/misc/sys/select.h
index 29d011c..c7d1a95 100644
--- a/misc/sys/select.h
+++ b/misc/sys/select.h
@@ -38,12 +38,7 @@
#ifdef __USE_XOPEN2K
# include <bits/types/struct_timespec.h>
#endif
-
-#ifndef __suseconds_t_defined
-typedef __suseconds_t suseconds_t;
-# define __suseconds_t_defined
-#endif
-
+#include <bits/types/suseconds_t.h>
/* The fd_set member is required to be an array of longs. */
typedef long int __fd_mask;
diff --git a/posix/Makefile b/posix/Makefile
index 4507d84..64fad14 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -22,17 +22,32 @@ subdir := posix
include ../Makeconfig
-headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \
- glob.h regex.h wordexp.h fnmatch.h \
- getopt.h bits/getopt_core.h bits/getopt_ext.h bits/getopt_posix.h \
- bits/types.h bits/typesizes.h bits/pthreadtypes.h \
- bits/pthreadtypes-arch.h bits/thread-shared-types.h \
- bits/posix1_lim.h bits/posix2_lim.h bits/posix_opt.h \
- bits/local_lim.h tar.h bits/utsname.h bits/confname.h \
- bits/waitflags.h bits/waitstatus.h sys/unistd.h sched.h \
- bits/sched.h bits/cpu-set.h re_comp.h wait.h bits/environments.h \
- cpio.h spawn.h bits/unistd.h bits/types/struct_sched_param.h \
- bits/unistd_ext.h
+headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \
+ glob.h regex.h wordexp.h fnmatch.h getopt.h \
+ bits/getopt_core.h bits/getopt_ext.h bits/getopt_posix.h \
+ bits/types.h bits/typesizes.h bits/pthreadtypes.h \
+ bits/pthreadtypes-arch.h bits/thread-shared-types.h \
+ bits/posix1_lim.h bits/posix2_lim.h bits/posix_opt.h \
+ bits/local_lim.h tar.h bits/utsname.h bits/confname.h \
+ bits/waitflags.h bits/waitstatus.h sys/unistd.h sched.h \
+ bits/sched.h bits/cpu-set.h re_comp.h wait.h \
+ bits/environments.h cpio.h spawn.h bits/unistd.h \
+ bits/types/struct_sched_param.h bits/unistd_ext.h \
+ bits/types/blkcnt64_t.h bits/types/blkcnt_t.h \
+ bits/types/blksize_t.h bits/types/caddr_t.h \
+ bits/types/daddr_t.h bits/types/dev_t.h \
+ bits/types/fsblkcnt64_t.h bits/types/fsblkcnt_t.h \
+ bits/types/fsfilcnt64_t.h bits/types/fsfilcnt_t.h \
+ bits/types/fsid_t.h bits/types/gid_t.h bits/types/id_t.h \
+ bits/types/ino64_t.h bits/types/ino_t.h \
+ bits/types/intptr_t.h bits/types/key_t.h \
+ bits/types/loff_t.h bits/types/mode_t.h \
+ bits/types/nlink_t.h bits/types/off64_t.h \
+ bits/types/off_t.h bits/types/pid_t.h \
+ bits/types/register_t.h bits/types/ssize_t.h \
+ bits/types/socklen_t.h bits/types/suseconds_t.h \
+ bits/types/uid_t.h bits/types/uint.h bits/types/u_int.h \
+ bits/types/u_intN_t.h bits/types/useconds_t.h
routines := \
uname \
diff --git a/posix/bits/types/blkcnt64_t.h b/posix/bits/types/blkcnt64_t.h
new file mode 100644
index 0000000..d5d81e7
--- /dev/null
+++ b/posix/bits/types/blkcnt64_t.h
@@ -0,0 +1,9 @@
+#ifndef __blkcnt64_t_defined
+#define __blkcnt64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count disk blocks (LFS). */
+typedef __blkcnt64_t blkcnt64_t;
+
+#endif
diff --git a/posix/bits/types/blkcnt_t.h b/posix/bits/types/blkcnt_t.h
new file mode 100644
index 0000000..badcd47
--- /dev/null
+++ b/posix/bits/types/blkcnt_t.h
@@ -0,0 +1,13 @@
+#ifndef __blkcnt_t_defined
+#define __blkcnt_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count number of disk blocks (POSIX). */
+#ifndef __USE_FILE_OFFSET64
+typedef __blkcnt_t blkcnt_t;
+#else
+typedef __blkcnt64_t blkcnt_t;
+#endif
+
+#endif
diff --git a/posix/bits/types/blksize_t.h b/posix/bits/types/blksize_t.h
new file mode 100644
index 0000000..9d6ada4
--- /dev/null
+++ b/posix/bits/types/blksize_t.h
@@ -0,0 +1,9 @@
+#ifndef __blksize_t_defined
+#define __blksize_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for sizes of disk blocks (POSIX). */
+typedef __blksize_t blksize_t;
+
+#endif
diff --git a/posix/bits/types/caddr_t.h b/posix/bits/types/caddr_t.h
new file mode 100644
index 0000000..fc010bd
--- /dev/null
+++ b/posix/bits/types/caddr_t.h
@@ -0,0 +1,9 @@
+#ifndef __caddr_t_defined
+#define __caddr_t_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete type for a memory address (BSD). */
+typedef __caddr_t caddr_t;
+
+#endif
diff --git a/posix/bits/types/daddr_t.h b/posix/bits/types/daddr_t.h
new file mode 100644
index 0000000..59f0b1b
--- /dev/null
+++ b/posix/bits/types/daddr_t.h
@@ -0,0 +1,9 @@
+#ifndef __daddr_t_defined
+#define __daddr_t_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete type for a disk address (BSD). */
+typedef __daddr_t daddr_t;
+
+#endif
diff --git a/posix/bits/types/dev_t.h b/posix/bits/types/dev_t.h
new file mode 100644
index 0000000..0b45f91
--- /dev/null
+++ b/posix/bits/types/dev_t.h
@@ -0,0 +1,9 @@
+#ifndef __dev_t_defined
+#define __dev_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for device IDs (POSIX). */
+typedef __dev_t dev_t;
+
+#endif
diff --git a/posix/bits/types/fsblkcnt64_t.h b/posix/bits/types/fsblkcnt64_t.h
new file mode 100644
index 0000000..690d601
--- /dev/null
+++ b/posix/bits/types/fsblkcnt64_t.h
@@ -0,0 +1,9 @@
+#ifndef __fsblkcnt64_t_defined
+#define __fsblkcnt64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system blocks (LFS). */
+typedef __fsblkcnt64_t fsblkcnt64_t;
+
+#endif
diff --git a/posix/bits/types/fsblkcnt_t.h b/posix/bits/types/fsblkcnt_t.h
new file mode 100644
index 0000000..2c7e80d
--- /dev/null
+++ b/posix/bits/types/fsblkcnt_t.h
@@ -0,0 +1,13 @@
+#ifndef __fsblkcnt_t_defined
+#define __fsblkcnt_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system blocks (POSIX). */
+#ifndef __USE_FILE_OFFSET64
+typedef __fsblkcnt_t fsblkcnt_t;
+#else
+typedef __fsblkcnt64_t fsblkcnt_t;
+#endif
+
+#endif
diff --git a/posix/bits/types/fsfilcnt64_t.h b/posix/bits/types/fsfilcnt64_t.h
new file mode 100644
index 0000000..56fcbc7
--- /dev/null
+++ b/posix/bits/types/fsfilcnt64_t.h
@@ -0,0 +1,9 @@
+#ifndef __fsfilcnt64_t_defined
+#define __fsfilcnt64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system inodes (LFS). */
+typedef __fsfilcnt64_t fsfilcnt64_t;
+
+#endif
diff --git a/posix/bits/types/fsfilcnt_t.h b/posix/bits/types/fsfilcnt_t.h
new file mode 100644
index 0000000..18d0f7e
--- /dev/null
+++ b/posix/bits/types/fsfilcnt_t.h
@@ -0,0 +1,13 @@
+#ifndef __fsfilcnt_t_defined
+#define __fsfilcnt_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system inodes (POSIX). */
+#ifndef __USE_FILE_OFFSET64
+typedef __fsfilcnt_t fsfilcnt_t;
+#else
+typedef __fsfilcnt64_t fsfilcnt_t;
+#endif
+
+#endif
diff --git a/posix/bits/types/fsid_t.h b/posix/bits/types/fsid_t.h
new file mode 100644
index 0000000..a198d30
--- /dev/null
+++ b/posix/bits/types/fsid_t.h
@@ -0,0 +1,9 @@
+#ifndef __fsid_t_defined
+#define __fsid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for a file system ID (BSD). */
+typedef __fsid_t fsid_t;
+
+#endif
diff --git a/posix/bits/types/gid_t.h b/posix/bits/types/gid_t.h
new file mode 100644
index 0000000..52974a1
--- /dev/null
+++ b/posix/bits/types/gid_t.h
@@ -0,0 +1,9 @@
+#ifndef __gid_t_defined
+#define __gid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for group IDs (POSIX). */
+typedef __gid_t gid_t;
+
+#endif
diff --git a/posix/bits/types/id_t.h b/posix/bits/types/id_t.h
new file mode 100644
index 0000000..1cb3b76
--- /dev/null
+++ b/posix/bits/types/id_t.h
@@ -0,0 +1,10 @@
+#ifndef __id_t_defined
+#define __id_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for a general identifier, can hold any pid_t, uid_t, or gid_t
+ value (POSIX). */
+typedef __id_t id_t;
+
+#endif
diff --git a/posix/bits/types/ino64_t.h b/posix/bits/types/ino64_t.h
new file mode 100644
index 0000000..e61e75a
--- /dev/null
+++ b/posix/bits/types/ino64_t.h
@@ -0,0 +1,9 @@
+#ifndef __ino64_t_defined
+#define __ino64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file serial numbers (LFS). */
+typedef __ino64_t ino64_t;
+
+#endif
diff --git a/posix/bits/types/ino_t.h b/posix/bits/types/ino_t.h
new file mode 100644
index 0000000..808821f
--- /dev/null
+++ b/posix/bits/types/ino_t.h
@@ -0,0 +1,13 @@
+#ifndef __ino_t_defined
+#define __ino_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file serial numbers (POSIX). */
+# ifndef __USE_FILE_OFFSET64
+typedef __ino_t ino_t;
+# else
+typedef __ino64_t ino_t;
+# endif
+
+#endif
diff --git a/posix/bits/types/intptr_t.h b/posix/bits/types/intptr_t.h
new file mode 100644
index 0000000..47948f9
--- /dev/null
+++ b/posix/bits/types/intptr_t.h
@@ -0,0 +1,10 @@
+#ifndef __intptr_t_defined
+#define __intptr_t_defined 1
+
+#include <bits/types.h>
+
+/* Signed integral type capable of representing a `void *' without
+ data loss (C1999). */
+typedef __intptr_t intptr_t;
+
+#endif
diff --git a/posix/bits/types/key_t.h b/posix/bits/types/key_t.h
new file mode 100644
index 0000000..424d250
--- /dev/null
+++ b/posix/bits/types/key_t.h
@@ -0,0 +1,9 @@
+#ifndef __key_t_defined
+#define __key_t_defined 1
+
+#include <bits/types.h>
+
+/* Type used by interprocess communication operations (XSI). */
+typedef __key_t key_t;
+
+#endif
diff --git a/posix/bits/types/loff_t.h b/posix/bits/types/loff_t.h
new file mode 100644
index 0000000..ecb9989
--- /dev/null
+++ b/posix/bits/types/loff_t.h
@@ -0,0 +1,9 @@
+#ifndef __loff_t_defined
+#define __loff_t_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete type for file sizes and offsets within a file (BSD). */
+typedef __loff_t loff_t;
+
+#endif
diff --git a/posix/bits/types/mode_t.h b/posix/bits/types/mode_t.h
new file mode 100644
index 0000000..3aaa70d
--- /dev/null
+++ b/posix/bits/types/mode_t.h
@@ -0,0 +1,9 @@
+#ifndef __mode_t_defined
+#define __mode_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file attribute bits (POSIX). */
+typedef __mode_t mode_t;
+
+#endif
diff --git a/posix/bits/types/nlink_t.h b/posix/bits/types/nlink_t.h
new file mode 100644
index 0000000..2f9125b
--- /dev/null
+++ b/posix/bits/types/nlink_t.h
@@ -0,0 +1,9 @@
+#ifndef __nlink_t_defined
+#define __nlink_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for link counts (POSIX). */
+typedef __nlink_t nlink_t;
+
+#endif
diff --git a/posix/bits/types/off64_t.h b/posix/bits/types/off64_t.h
new file mode 100644
index 0000000..f00bd82
--- /dev/null
+++ b/posix/bits/types/off64_t.h
@@ -0,0 +1,9 @@
+#ifndef __off64_t_defined
+#define __off64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file sizes and offsets within a file (LFS). */
+typedef __off64_t off64_t;
+
+#endif
diff --git a/posix/bits/types/off_t.h b/posix/bits/types/off_t.h
new file mode 100644
index 0000000..9ef5395
--- /dev/null
+++ b/posix/bits/types/off_t.h
@@ -0,0 +1,13 @@
+#ifndef __off_t_defined
+#define __off_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file sizes and offsets within a file (POSIX). */
+# ifndef __USE_FILE_OFFSET64
+typedef __off_t off_t;
+# else
+typedef __off64_t off_t;
+# endif
+
+#endif
diff --git a/posix/bits/types/pid_t.h b/posix/bits/types/pid_t.h
new file mode 100644
index 0000000..249e070
--- /dev/null
+++ b/posix/bits/types/pid_t.h
@@ -0,0 +1,9 @@
+#ifndef __pid_t_defined
+#define __pid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for process IDs and process group IDs (POSIX). */
+typedef __pid_t pid_t;
+
+#endif
diff --git a/posix/bits/types/register_t.h b/posix/bits/types/register_t.h
new file mode 100644
index 0000000..099b472
--- /dev/null
+++ b/posix/bits/types/register_t.h
@@ -0,0 +1,9 @@
+#ifndef __register_t_defined
+#define __register_t_defined 1
+
+#include <bits/types.h>
+
+/* Type of a general-purpose integer register (BSD). */
+typedef __register_t register_t;
+
+#endif
diff --git a/posix/bits/types/socklen_t.h b/posix/bits/types/socklen_t.h
new file mode 100644
index 0000000..8369630
--- /dev/null
+++ b/posix/bits/types/socklen_t.h
@@ -0,0 +1,9 @@
+#ifndef __socklen_t_defined
+#define __socklen_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for size of socket addresses (POSIX). */
+typedef __socklen_t socklen_t;
+
+#endif
diff --git a/posix/bits/types/ssize_t.h b/posix/bits/types/ssize_t.h
new file mode 100644
index 0000000..41e1fd7
--- /dev/null
+++ b/posix/bits/types/ssize_t.h
@@ -0,0 +1,9 @@
+#ifndef __ssize_t_defined
+#define __ssize_t_defined 1
+
+#include <bits/types.h>
+
+/* Type used for a count of bytes or an error indication (POSIX). */
+typedef __ssize_t ssize_t;
+
+#endif
diff --git a/posix/bits/types/suseconds_t.h b/posix/bits/types/suseconds_t.h
new file mode 100644
index 0000000..62ded6f
--- /dev/null
+++ b/posix/bits/types/suseconds_t.h
@@ -0,0 +1,9 @@
+#ifndef __suseconds_t_defined
+#define __suseconds_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for time in microseconds (signed) (XSI). */
+typedef __suseconds_t suseconds_t;
+
+#endif
diff --git a/posix/bits/types/u_int.h b/posix/bits/types/u_int.h
new file mode 100644
index 0000000..4c9235f
--- /dev/null
+++ b/posix/bits/types/u_int.h
@@ -0,0 +1,15 @@
+#ifndef __u_int_defined
+#define __u_int_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete shorthand names for unsigned types, used by old BSD
+ networking code and Sun RPC. */
+typedef unsigned char u_char;
+typedef unsigned short int u_short;
+typedef unsigned int u_int;
+typedef unsigned long int u_long;
+typedef __int64_t quad_t;
+typedef __uint64_t u_quad_t;
+
+#endif
diff --git a/posix/bits/types/u_intN_t.h b/posix/bits/types/u_intN_t.h
new file mode 100644
index 0000000..6257674
--- /dev/null
+++ b/posix/bits/types/u_intN_t.h
@@ -0,0 +1,17 @@
+#ifndef __u_intN_t_defined
+#define __u_intN_t_defined 1
+
+#include <bits/types.h>
+
+/* These size-specific names are used by some of the inet code.
+ They were defined by ISO C without the first `_'. */
+typedef __uint8_t u_int8_t;
+typedef __uint16_t u_int16_t;
+typedef __uint32_t u_int32_t;
+typedef __uint64_t u_int64_t;
+
+/* Some code from BIND tests this macro to see if the types above are
+ defined. */
+#define __BIT_TYPES_DEFINED__ 1
+
+#endif
diff --git a/posix/bits/types/uid_t.h b/posix/bits/types/uid_t.h
new file mode 100644
index 0000000..371cb05
--- /dev/null
+++ b/posix/bits/types/uid_t.h
@@ -0,0 +1,9 @@
+#ifndef __uid_t_defined
+#define __uid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for user IDs (POSIX). */
+typedef __uid_t uid_t;
+
+#endif
diff --git a/posix/bits/types/uint.h b/posix/bits/types/uint.h
new file mode 100644
index 0000000..69829c6
--- /dev/null
+++ b/posix/bits/types/uint.h
@@ -0,0 +1,10 @@
+#ifndef __uint_defined
+#define __uint_defined 1
+
+/* Obsolete shorthand names for unsigned types, used by old BSD
+ networking code and Sun RPC. */
+typedef unsigned short int ushort;
+typedef unsigned int uint;
+typedef unsigned long int ulong;
+
+#endif
diff --git a/posix/bits/types/useconds_t.h b/posix/bits/types/useconds_t.h
new file mode 100644
index 0000000..a363558
--- /dev/null
+++ b/posix/bits/types/useconds_t.h
@@ -0,0 +1,9 @@
+#ifndef __useconds_t_defined
+#define __useconds_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for time in microseconds (unsigned) (XSI). */
+typedef __useconds_t useconds_t;
+
+#endif
diff --git a/posix/sched.h b/posix/sched.h
index 60c9c3c..bb7e727 100644
--- a/posix/sched.h
+++ b/posix/sched.h
@@ -33,11 +33,7 @@
#ifndef __USE_XOPEN2K
# include <time.h>
#endif
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
+#include <bits/types/pid_t.h>
/* Get system specific constant and data structure definitions. */
#include <bits/sched.h>
diff --git a/posix/sys/types.h b/posix/sys/types.h
index f7452ae..ba8e72a 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -28,120 +28,51 @@ __BEGIN_DECLS
#include <bits/types.h>
-#ifdef __USE_MISC
-# ifndef __u_char_defined
-typedef unsigned char u_char;
-typedef unsigned short int u_short;
-typedef unsigned int u_int;
-typedef unsigned long int u_long;
-typedef __int64_t quad_t;
-typedef __uint64_t u_quad_t;
-typedef __fsid_t fsid_t;
-# define __u_char_defined
-# endif
-typedef __loff_t loff_t;
-#endif
-
-#ifndef __ino_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __ino_t ino_t;
-# else
-typedef __ino64_t ino_t;
-# endif
-# define __ino_t_defined
-#endif
-#if defined __USE_LARGEFILE64 && !defined __ino64_t_defined
-typedef __ino64_t ino64_t;
-# define __ino64_t_defined
-#endif
-
-#ifndef __dev_t_defined
-typedef __dev_t dev_t;
-# define __dev_t_defined
-#endif
-
-#ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-#endif
-
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
-
-#ifndef __nlink_t_defined
-typedef __nlink_t nlink_t;
-# define __nlink_t_defined
-#endif
-
-#ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-#endif
-
-#ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-#endif
-#if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
-#endif
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
-
-#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) \
- && !defined __id_t_defined
-typedef __id_t id_t;
-# define __id_t_defined
-#endif
+#define __need_size_t
+#include <stddef.h>
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
+#include <bits/types/blkcnt_t.h>
+#include <bits/types/clockid_t.h>
+#include <bits/types/dev_t.h>
+#include <bits/types/fsblkcnt_t.h>
+#include <bits/types/fsfilcnt_t.h>
+#include <bits/types/gid_t.h>
+#include <bits/types/ino_t.h>
+#include <bits/types/mode_t.h>
+#include <bits/types/nlink_t.h>
+#include <bits/types/off_t.h>
+#include <bits/types/pid_t.h>
+#include <bits/types/ssize_t.h>
+#include <bits/types/time_t.h>
+#include <bits/types/timer_t.h>
+#include <bits/types/uid_t.h>
-#ifdef __USE_MISC
-# ifndef __daddr_t_defined
-typedef __daddr_t daddr_t;
-typedef __caddr_t caddr_t;
-# define __daddr_t_defined
-# endif
+#ifdef __USE_LARGEFILE64
+# include <bits/types/blkcnt64_t.h>
+# include <bits/types/fsblkcnt64_t.h>
+# include <bits/types/fsfilcnt64_t.h>
+# include <bits/types/ino64_t.h>
+# include <bits/types/off64_t.h>
#endif
-#if (defined __USE_MISC || defined __USE_XOPEN) && !defined __key_t_defined
-typedef __key_t key_t;
-# define __key_t_defined
+#ifdef __USE_XOPEN
+# include <bits/types/useconds_t.h>
+# include <bits/types/suseconds_t.h>
#endif
#if defined __USE_XOPEN || defined __USE_XOPEN2K8
# include <bits/types/clock_t.h>
+# include <bits/types/id_t.h>
+# include <bits/types/key_t.h>
#endif
-#include <bits/types/clockid_t.h>
-#include <bits/types/time_t.h>
-#include <bits/types/timer_t.h>
-#ifdef __USE_XOPEN
-# ifndef __useconds_t_defined
-typedef __useconds_t useconds_t;
-# define __useconds_t_defined
-# endif
-# ifndef __suseconds_t_defined
-typedef __suseconds_t suseconds_t;
-# define __suseconds_t_defined
-# endif
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
+#include <bits/types/blksize_t.h>
#endif
-#define __need_size_t
-#include <stddef.h>
+#if defined __USE_POSIX199506 || defined __USE_UNIX98
+# include <bits/pthreadtypes.h>
+#endif
/* POSIX does not require intN_t to be defined in this header, so
technically this ought to be under __USE_MISC, but it doesn't
@@ -150,24 +81,17 @@ typedef __suseconds_t suseconds_t;
#include <bits/stdint-intn.h>
#ifdef __USE_MISC
-/* Old compatibility names for C types. */
-typedef unsigned long int ulong;
-typedef unsigned short int ushort;
-typedef unsigned int uint;
-
-/* These size-specific names are used by some of the inet code.
- They were defined by ISO C without the first `_'. */
-typedef __uint8_t u_int8_t;
-typedef __uint16_t u_int16_t;
-typedef __uint32_t u_int32_t;
-typedef __uint64_t u_int64_t;
-
-/* Type of a general-purpose integer register (BSD). */
-typedef __register_t register_t;
-
-/* Some code from BIND tests this macro to see if the types above are
- defined. */
-#define __BIT_TYPES_DEFINED__ 1
+/* Additional typedefs from BSD, mostly obsolete. */
+# include <bits/types/caddr_t.h>
+# include <bits/types/daddr_t.h>
+# include <bits/types/fsid_t.h>
+# include <bits/types/loff_t.h>
+# include <bits/types/register_t.h>
+
+/* Shorthand unsigned types, mostly superseded by stdint.h. */
+# include <bits/types/uint.h>
+# include <bits/types/u_int.h>
+# include <bits/types/u_intN_t.h>
/* In BSD <sys/types.h> is expected to define BYTE_ORDER. */
# include <endian.h>
@@ -176,54 +100,6 @@ typedef __register_t register_t;
# include <sys/select.h>
#endif /* Use misc. */
-
-#if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) \
- && !defined __blksize_t_defined
-typedef __blksize_t blksize_t;
-# define __blksize_t_defined
-#endif
-
-/* Types from the Large File Support interface. */
-#ifndef __USE_FILE_OFFSET64
-# ifndef __blkcnt_t_defined
-typedef __blkcnt_t blkcnt_t; /* Type to count number of disk blocks. */
-# define __blkcnt_t_defined
-# endif
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#else
-# ifndef __blkcnt_t_defined
-typedef __blkcnt64_t blkcnt_t; /* Type to count number of disk blocks. */
-# define __blkcnt_t_defined
-# endif
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt64_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt64_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#endif
-
-#ifdef __USE_LARGEFILE64
-typedef __blkcnt64_t blkcnt64_t; /* Type to count number of disk blocks. */
-typedef __fsblkcnt64_t fsblkcnt64_t; /* Type to count file system blocks. */
-typedef __fsfilcnt64_t fsfilcnt64_t; /* Type to count file system inodes. */
-#endif
-
-
-/* Now add the thread types. */
-#if defined __USE_POSIX199506 || defined __USE_UNIX98
-# include <bits/pthreadtypes.h>
-#endif
-
__END_DECLS
#endif /* sys/types.h */
diff --git a/posix/sys/wait.h b/posix/sys/wait.h
index a42e16c..d4646ac 100644
--- a/posix/sys/wait.h
+++ b/posix/sys/wait.h
@@ -27,10 +27,7 @@
__BEGIN_DECLS
#include <bits/types.h>
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
+#include <bits/types/pid_t.h>
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
# include <signal.h>
@@ -111,11 +108,7 @@ extern __pid_t wait (int *__stat_loc);
extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-# ifndef __id_t_defined
-typedef __id_t id_t;
-# define __id_t_defined
-# endif
-
+# include <bits/types/id_t.h>
# include <bits/types/siginfo_t.h>
/* Wait for a childing matching IDTYPE and ID to change the status and
diff --git a/posix/unistd.h b/posix/unistd.h
index 0dd4200..e5958e3 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -215,11 +215,7 @@ __BEGIN_DECLS
/* All functions that are not declared anywhere else. */
#include <bits/types.h>
-
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
+#include <bits/types/ssize_t.h>
#define __need_size_t
#define __need_NULL
@@ -228,52 +224,22 @@ typedef __ssize_t ssize_t;
#if defined __USE_XOPEN || defined __USE_XOPEN2K
/* The Single Unix specification says that some more types are
available here. */
-# ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-# endif
-
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
-
-# ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-# endif
-# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
-# endif
-
-# ifndef __useconds_t_defined
-typedef __useconds_t useconds_t;
-# define __useconds_t_defined
-# endif
-
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
+# include <bits/types/gid_t.h>
+# include <bits/types/uid_t.h>
+# include <bits/types/off_t.h>
+# ifdef __USE_LARGEFILE64
+# include <bits/types/off64_t.h>
# endif
+# include <bits/types/useconds_t.h>
+# include <bits/types/pid_t.h>
#endif /* X/Open */
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
-# ifndef __intptr_t_defined
-typedef __intptr_t intptr_t;
-# define __intptr_t_defined
-# endif
+# include <bits/types/intptr_t.h>
#endif
#if defined __USE_MISC || defined __USE_XOPEN
-# ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-# endif
+# include <bits/types/socklen_t.h>
#endif
/* Values for the second argument to access.
diff --git a/pwd/pwd.h b/pwd/pwd.h
index bbc2947..7f490f5 100644
--- a/pwd/pwd.h
+++ b/pwd/pwd.h
@@ -34,15 +34,8 @@ __BEGIN_DECLS
#if defined __USE_XOPEN || defined __USE_XOPEN2K
/* The Single Unix specification says that some more types are
available here. */
-# ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-# endif
-
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
+# include <bits/types/gid_t.h>
+# include <bits/types/uid_t.h>
#endif
/* A record in the user database. */
diff --git a/resource/sys/resource.h b/resource/sys/resource.h
index 4edafb5..5355da8 100644
--- a/resource/sys/resource.h
+++ b/resource/sys/resource.h
@@ -22,11 +22,7 @@
/* Get the system-dependent definitions of structures and bit values. */
#include <bits/resource.h>
-
-#ifndef __id_t_defined
-typedef __id_t id_t;
-# define __id_t_defined
-#endif
+#include <bits/types/id_t.h>
__BEGIN_DECLS
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index ae74099..e458e2b 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -28,6 +28,7 @@
import argparse
import collections
+import os.path
import re
import sys
@@ -264,15 +265,40 @@ OBSOLETE_TYPE_RE_ = re.compile(r"""\A
| _(?: char | short | int(?:[0-9]+_t)? | long | quad_t )))
\Z""", re.VERBOSE)
+# The headers that declare them:
+OBSOLETE_TYPE_HDR_RE_ = re.compile(r"""\A
+ [<"] bits/types/
+ (?: [cd]addr_t
+ | loff_t
+ | register_t
+ | uint
+ | u_int
+ | u_intN_t ) \.h [">]
+\Z""", re.VERBOSE)
+
class ObsoleteNotAllowed(ConstructChecker):
- """Don't allow any use of the obsolete typedefs."""
+ """Don't allow any use of the obsolete typedefs,
+ or the headers that declare them."""
def examine(self, tok):
- if OBSOLETE_TYPE_RE_.match(tok.text):
+ if ((tok.kind == "IDENT"
+ and OBSOLETE_TYPE_RE_.match(tok.text))
+ or (tok.kind == "HEADER_NAME"
+ and OBSOLETE_TYPE_HDR_RE_.match(tok.text))):
+ self.reporter.error(tok, "use of {!r}")
+
+class ObsoleteIndirectDefinitionsAllowed(ConstructChecker):
+ """Don't allow any use of the obsolete typedefs,
+ but do allow inclusion of the headers that declare them."""
+ def examine(self, tok):
+ if (tok.kind == "IDENT"
+ and OBSOLETE_TYPE_RE_.match(tok.text)):
self.reporter.error(tok, "use of {!r}")
class ObsoletePrivateDefinitionsAllowed(ConstructChecker):
"""Allow definitions of the private versions of the
obsolete typedefs; that is, 'typedef [anything] __obsolete;'
+ Don't allow inclusion of headers that declare the public
+ versions.
"""
def __init__(self, reporter):
super().__init__(reporter)
@@ -300,10 +326,14 @@ class ObsoletePrivateDefinitionsAllowed(ConstructChecker):
self._check_prev()
def _check_prev(self):
- if (self.prev_token is not None
- and self.prev_token.kind == "IDENT"
- and OBSOLETE_TYPE_RE_.match(self.prev_token.text)):
- self.reporter.error(self.prev_token, "use of {!r}")
+ tok = self.prev_token
+ if tok is None:
+ return
+ if ((tok.kind == "IDENT"
+ and OBSOLETE_TYPE_RE_.match(tok.text))
+ or (tok.kind == "HEADER_NAME"
+ and OBSOLETE_TYPE_HDR_RE_.match(tok.text))):
+ self.reporter.error(tok, "use of {!r}")
class ObsoletePublicDefinitionsAllowed(ConstructChecker):
"""Allow definitions of the public versions of the obsolete
@@ -317,6 +347,9 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
typedef unsigned char u_char;
typedef __int64_t quad_t;
typedef __uint64_t u_quad_t;
+
+ Don't allow inclusion of headers that declare public
+ versions of other obsolete typedefs.
"""
def __init__(self, reporter):
super().__init__(reporter)
@@ -337,6 +370,10 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
elif tok.kind == "PUNCTUATOR" and tok.text == ";":
self._finish()
+ elif tok.kind == "HEADER_NAME":
+ if OBSOLETE_TYPE_HDR_RE_.match(tok.text):
+ self.reporter.error(tok, "use of {!r}")
+
elif self.typedef_tokens:
self.typedef_tokens.append(tok)
@@ -406,19 +443,38 @@ def ObsoleteTypedefChecker(reporter, fname):
or fname.startswith("rpcsvc/")
or "/rpc/" in fname
or "/rpcsvc/" in fname):
+ sys.stderr.write("# No typedef checks for {}\n".format(fname))
return NoCheck(reporter)
# bits/types.h is allowed to define the __-versions of the
# obsolete types.
if (fname == "bits/types.h"
or fname.endswith("/bits/types.h")):
+ sys.stderr.write("# Obsolete private defs allowed for {}\n"
+ .format(fname))
return ObsoletePrivateDefinitionsAllowed(reporter)
- # sys/types.h is allowed to use the __-versions of the
- # obsolete types, but only to define the unprefixed versions.
+ # Certain bits/types/ headers are allowed to define the
+ # unprefixed versions of the obsolete types.
+ if ((fname.startswith("bits/types/")
+ or "/bits/types/" in fname)
+ and os.path.basename(fname) in ("caddr_t.h",
+ "daddr_t.h",
+ "loff_t.h",
+ "register_t.h",
+ "uint.h",
+ "u_int.h",
+ "u_intN_t.h")):
+ sys.stderr.write("# Obsolete public defs allowed for {}\n"
+ .format(fname))
+ return ObsoletePublicDefinitionsAllowed(reporter)
+
+ # sys/types.h is allowed to include the above bits/types/ headers.
if (fname == "sys/types.h"
or fname.endswith("/sys/types.h")):
- return ObsoletePublicDefinitionsAllowed(reporter)
+ sys.stderr.write("# Obsolete indirect defs allowed for {}\n"
+ .format(fname))
+ return ObsoleteIndirectDefinitionsAllowed(reporter)
return ObsoleteNotAllowed(reporter)
diff --git a/signal/signal.h b/signal/signal.h
index 40825e9..f7f50c8 100644
--- a/signal/signal.h
+++ b/signal/signal.h
@@ -36,16 +36,8 @@ __BEGIN_DECLS
#endif
#if defined __USE_XOPEN || defined __USE_XOPEN2K
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
-#ifdef __USE_XOPEN
-# endif
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
+# include <bits/types/pid_t.h>
+# include <bits/types/uid_t.h>
#endif /* Unix98 */
#ifdef __USE_POSIX199309
diff --git a/stdlib/monetary.h b/stdlib/monetary.h
index dfb6ed5..8f268a0 100644
--- a/stdlib/monetary.h
+++ b/stdlib/monetary.h
@@ -25,12 +25,7 @@
#define __need_size_t
#include <stddef.h>
#include <bits/types.h>
-
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
-
+#include <bits/types/ssize_t.h>
__BEGIN_DECLS
diff --git a/stdlib/stdint.h b/stdlib/stdint.h
index 391e3d2..94d6e71 100644
--- a/stdlib/stdint.h
+++ b/stdlib/stdint.h
@@ -82,10 +82,7 @@ typedef unsigned long long int uint_fast64_t;
/* Types for `void *' pointers. */
-# ifndef __intptr_t_defined
-typedef __intptr_t intptr_t;
-# define __intptr_t_defined
-# endif
+#include <bits/types/intptr_t.h>
typedef __uintptr_t uintptr_t;
/* Largest integral types. */
diff --git a/sunrpc/rpc/types.h b/sunrpc/rpc/types.h
index 99e5f4f..13ef47f 100644
--- a/sunrpc/rpc/types.h
+++ b/sunrpc/rpc/types.h
@@ -34,6 +34,19 @@
#ifndef _RPC_TYPES_H
#define _RPC_TYPES_H 1
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/param.h>
+#include <netinet/in.h>
+
+#ifndef __BIT_TYPES_DEFINED__
+#include <bits/types/caddr_t.h>
+#include <bits/types/daddr_t.h>
+#include <bits/types/fsid_t.h>
+#include <bits/types/u_int.h>
+#endif
+
typedef int bool_t;
typedef int enum_t;
/* This needs to be changed to uint32_t in the future */
@@ -57,7 +70,6 @@ typedef unsigned long rpcport_t;
# define NULL 0
#endif
-#include <stdlib.h> /* For malloc decl. */
#define mem_alloc(bsize) malloc(bsize)
/*
* XXX: This must not use the second argument, or code in xdr_array.c needs
@@ -65,36 +77,6 @@ typedef unsigned long rpcport_t;
*/
#define mem_free(ptr, bsize) free(ptr)
-#ifndef makedev /* ie, we haven't already included it */
-#include <sys/types.h>
-#endif
-
-#if defined __APPLE_CC__ || defined __FreeBSD__
-# define __u_char_defined
-# define __daddr_t_defined
-#endif
-
-#ifndef __u_char_defined
-typedef unsigned char u_char;
-typedef unsigned short int u_short;
-typedef unsigned int u_int;
-typedef unsigned long int u_long;
-typedef __int64_t quad_t;
-typedef __uint64_t u_quad_t;
-typedef __fsid_t fsid_t;
-# define __u_char_defined
-#endif
-#ifndef __daddr_t_defined
-typedef __daddr_t daddr_t;
-typedef __caddr_t caddr_t;
-# define __daddr_t_defined
-#endif
-
-#include <sys/time.h>
-#include <sys/param.h>
-
-#include <netinet/in.h>
-
#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK (u_long)0x7F000001
#endif
diff --git a/sysdeps/gnu/utmpx.h b/sysdeps/gnu/utmpx.h
index f50a0db..b1a82a4 100644
--- a/sysdeps/gnu/utmpx.h
+++ b/sysdeps/gnu/utmpx.h
@@ -22,10 +22,7 @@
#include <sys/time.h>
/* Required according to Unix98. */
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
+#include <bits/types/pid_t.h>
/* Get system dependent values and data structures. */
#include <bits/utmpx.h>
diff --git a/sysdeps/mach/hurd/bits/socket.h b/sysdeps/mach/hurd/bits/socket.h
index ff898aa..06a7311 100644
--- a/sysdeps/mach/hurd/bits/socket.h
+++ b/sysdeps/mach/hurd/bits/socket.h
@@ -29,13 +29,7 @@
#include <bits/wordsize.h>
#include <sys/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
-
+#include <bits/types/socklen_t.h>
/* Types of sockets. */
enum __socket_type
diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h
index 50f89db..f275b33 100644
--- a/sysdeps/unix/sysv/linux/bits/socket.h
+++ b/sysdeps/unix/sysv/linux/bits/socket.h
@@ -27,12 +27,7 @@
#include <stddef.h>
#include <sys/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
+#include <bits/types/socklen_t.h>
/* Get the architecture-dependent definition of enum __socket_type. */
#include <bits/socket_type.h>
diff --git a/sysvipc/sys/ipc.h b/sysvipc/sys/ipc.h
index 0c7f356..ca2b989 100644
--- a/sysvipc/sys/ipc.h
+++ b/sysvipc/sys/ipc.h
@@ -23,26 +23,10 @@
/* Get system dependent definition of `struct ipc_perm' and more. */
#include <bits/ipctypes.h>
#include <bits/ipc.h>
-
-#ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-#endif
-
-#ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-#endif
-
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
-
-#ifndef __key_t_defined
-typedef __key_t key_t;
-# define __key_t_defined
-#endif
+#include <bits/types/uid_t.h>
+#include <bits/types/gid_t.h>
+#include <bits/types/mode_t.h>
+#include <bits/types/key_t.h>
__BEGIN_DECLS
diff --git a/sysvipc/sys/msg.h b/sysvipc/sys/msg.h
index c70cfa5..b110e16 100644
--- a/sysvipc/sys/msg.h
+++ b/sysvipc/sys/msg.h
@@ -31,16 +31,8 @@
/* Define types required by the standard. */
#include <bits/types/time_t.h>
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
-
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
+#include <bits/types/pid_t.h>
+#include <bits/types/ssize_t.h>
/* The following System V style IPC functions implement a message queue
system. The definition is found in XPG2. */
diff --git a/sysvipc/sys/shm.h b/sysvipc/sys/shm.h
index 6c58742..c1cc295 100644
--- a/sysvipc/sys/shm.h
+++ b/sysvipc/sys/shm.h
@@ -31,14 +31,9 @@
/* Define types required by the standard. */
#include <bits/types/time_t.h>
-
#ifdef __USE_XOPEN
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-# endif
-#endif /* X/Open */
-
+# include <bits/types/pid_t.h>
+#endif
__BEGIN_DECLS
diff --git a/termios/termios.h b/termios/termios.h
index 41cd79b..0af77e3 100644
--- a/termios/termios.h
+++ b/termios/termios.h
@@ -23,13 +23,9 @@
#define _TERMIOS_H 1
#include <features.h>
+
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-/* We need `pid_t'. */
-# include <bits/types.h>
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-# endif
+# include <bits/types/pid_t.h>
#endif
__BEGIN_DECLS
diff --git a/time/sys/time.h b/time/sys/time.h
index 21fa9ed..3769f85 100644
--- a/time/sys/time.h
+++ b/time/sys/time.h
@@ -23,11 +23,7 @@
#include <bits/types.h>
#include <bits/types/time_t.h>
#include <bits/types/struct_timeval.h>
-
-#ifndef __suseconds_t_defined
-typedef __suseconds_t suseconds_t;
-# define __suseconds_t_defined
-#endif
+#include <bits/types/suseconds_t.h>
#include <sys/select.h>
diff --git a/time/time.h b/time/time.h
index 015bc1c..c12d5e2 100644
--- a/time/time.h
+++ b/time/time.h
@@ -50,10 +50,7 @@ struct sigevent;
#endif
#ifdef __USE_XOPEN2K
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-# endif
+# include <bits/types/pid_t.h>
#endif
#ifdef __USE_XOPEN2K8
^ permalink raw reply [flat|nested] 4+ messages in thread
* [glibc/zack/no-nested-includes] Create bits/types headers for most remaining __T_defined macros.
@ 2019-06-26 15:48 Zack Weinberg
0 siblings, 0 replies; 4+ messages in thread
From: Zack Weinberg @ 2019-06-26 15:48 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=013d777034a422b60fc43c1ede5eb6490b1f79d5
commit 013d777034a422b60fc43c1ede5eb6490b1f79d5
Author: Zack Weinberg <zackw@panix.com>
Date: Sat Mar 9 20:54:02 2019 -0500
Create bits/types headers for most remaining __T_defined macros.
This doesn't exactly fit the theme but as long as I'm tinkering with
sys/types.h it makes sense to go through and create single-declaration
bits/types/ headers for all of the remaining cases where we have
two or more headers declaring a public type.
The remaining uses of the original __T_defined idiom are:
__error_t_defined in files shared with gnulib, which probably has to
remain as is; ____gwchar_t_defined in inttypes.h, which may not be
necessary anymore and should be addressed separately, and
__ldiv_t_defined and __lldiv_t_defined in stdlib.h, ditto.
Our handling of LFS types is a little inconsistent: some headers
declare both off_t and off64_t (for instance) when
_LARGEFILE64_SOURCE, others will only declare off_t regardless of
_LARGEFILE64_SOURCE. I don't know if this was intentional or not.
I am tempted to centralize responsibility for _LARGEFILE64_SOURCE as
well as _FILE_OFFSET_BITS=64 in bits/types/off_t.h (etc) so that any
header that declares off_t will automatically also declare off64_t
when _LARGEFILE64_SOURCE.
sunrpc/rpc/types.h is special, because it is included in files
compiled by the *build* compiler (cross-rpcgen-objs), and therefore it
cannot unconditionally assume bits/types headers are available. What
I did was have it include the appropriate bits/types headers only if
including sys/types.h did not cause __BIT_TYPES_DEFINED__ to be
defined. This will do the right thing when an installed rpc/types.h
is included by application code compiled without __USE_MISC in effect.
During the build, we rely on the fact that we compile all of our own
code with __USE_MISC in effect. This is fragile, but should be
acceptable for code that's no longer built by default anyway.
scripts/check-obsolete-constructs.py ensures that only sys/types.h and
rpc/types.h include the bits/types/ headers that define obsolete types.
* posix/bits/types/blkcnt64_t.h
* posix/bits/types/blkcnt_t.h
* posix/bits/types/blksize_t.h
* posix/bits/types/dev_t.h
* posix/bits/types/fsblkcnt64_t.h
* posix/bits/types/fsblkcnt_t.h
* posix/bits/types/fsfilcnt64_t.h
* posix/bits/types/fsfilcnt_t.h
* posix/bits/types/fsid_t.h
* posix/bits/types/gid_t.h
* posix/bits/types/id_t.h
* posix/bits/types/ino64_t.h
* posix/bits/types/ino_t.h
* posix/bits/types/intptr_t.h
* posix/bits/types/key_t.h
* posix/bits/types/loff_t.h
* posix/bits/types/mode_t.h
* posix/bits/types/nlink_t.h
* posix/bits/types/off64_t.h
* posix/bits/types/off_t.h
* posix/bits/types/pid_t.h
* posix/bits/types/socklen_t.h
* posix/bits/types/ssize_t.h
* posix/bits/types/suseconds_t.h
* posix/bits/types/uid_t.h
* posix/bits/types/useconds_t.h:
New single-declaration headers for standard types canonically
defined by sys/types.h, sys/socket.h, or inttypes.h but also
exposed by other headers under some circumstances. Code moved
from posix/sys/types.h, socket/sys/socket.h, stdlib/inttypes.h
as appropriate.
* posix/bits/types/uint.h
* posix/bits/types/u_int.h
* posix/bits/types/u_intN_t.h
* posix/bits/types/caddr_t.h
* posix/bits/types/daddr_t.h
* posix/bits/types/loff_t.h
* posix/bits/types/register_t.h:
Similarly, but for obsolete BSD-derived types whose canonical
home is sys/types.h. Some of these headers define more than
one type.
* posix/Makefile (headers): Install the above new headers.
Rewrap the list.
* posix/sys/types.h: All definitions of public types now
accomplished using the above new headers. Consolidate
groups of definitions controlled by the same feature
selection macros.
* inet/arpa/inet.h, bits/socket.h
* sysdeps/mach/hurd/bits/socket.h
* sysdeps/unix/sysv/linux/bits/socket.h:
Use bits/types/socklen_t.h.
* dirent/dirent.h: Use bits/types/ino_t.h and bits/types/ino64_t.h.
* grp/grp.h: Use bits/types/gid_t.h.
* io/fcntl.h: Use bits/types/mode_t.h, bits/types/off_t.h,
bits/types/pid_t.h, and bits/types/off64_t.h.
* io/sys/stat.h: Use bits/types/dev_t.h, bits/types/gid_t.h,
bits/types/ino_t.h, bits/types/mode_t.h, bits/types/nlink_t.h,
bits/types/off_t.h, bits/types/uid_t.h, and bits/types/blkcnt_t.h.
* libio/stdio.h: Use bits/types/off_t.h, bits/types/off64_t.h,
and bits/types/ssize_t.h.
* misc/sys/mman.h: Use bits/types/off_t.h and bits/types/mode_t.h.
* misc/sys/select.h: Use bits/types/suseconds_t.h.
* posix/sched.h: Use bits/types/pid_t.h.
* posix/sys/wait.h: Use bits/types/pid_t.h and bits/types/id_t.h.
* posix/unistd.h: Use bits/types/gid_t.h, bits/types/uid_t.h,
bits/types/off_t.h, bits/types/off64_t.h, bits/types/useconds_t.h,
bits/types/intptr_t.h, and bits/types/socklen_t.h.
* pwd/pwd.h: Use bits/types/gid_t.h and bits/types/uid_t.h.
* resource/sys/resource.h: Use bits/types/id_t.h.
* signal/signal.h: Use bits/types/pid_t.h and bits/types/uid_t.h.
* stdlib/monetary.h: Use bits/types/ssize_t.h.
* sysdeps/gnu/utmpx.h: Use bits/types/pid_t.h.
* sysvipc/sys/ipc.h: Use bits/types/uid_t.h, bits/types/gid_t.h,
bits/types/mode_t.h, and bits/types/key_t.h.
* sysvipc/sys/msg.h: Use bits/types/pid_t.h and bits/types/ssize_t.h.
* sysvipc/sys/shm.h: Use bits/types/pid_t.h.
* termios/termios.h: Use bits/types/pid_t.h.
* time/sys/time.h: Use bits/types/suseconds_t.h.
* time/time.h: Use bits/types/pid_t.h.
* sunrpc/rpc/types.h: Consolidate all #includes at the top of
the file. If __BIT_TYPES_DEFINED__ is not defined after
including sys/types.h, also include bits/types/caddr_t.h,
bits/types/daddr_t.h, bits/types/fsid_t.h, and bits/types/u_int.h.
* scripts/check-obsolete-constructs.py (OBSOLETE_TYPE_HDR_RE_): New.
(ObsoleteIndirectDefinitionsAllowed): New; allows inclusion of
bits/types/ headers that define obsolete typedefs, but not
direct definitions of those types.
(ObsoleteNotAllowed, ObsoletePrivateDefinitionsAllowed)
(ObsoletePublicDefinitionsAllowed): Do not allow inclusion of
bits/types/ headers that define obsolete typedefs.
* include/bits/types/blkcnt64_t.h
* include/bits/types/blkcnt_t.h
* include/bits/types/blksize_t.h
* include/bits/types/caddr_t.h
* include/bits/types/daddr_t.h
* include/bits/types/dev_t.h
* include/bits/types/fsblkcnt64_t.h
* include/bits/types/fsblkcnt_t.h
* include/bits/types/fsfilcnt64_t.h
* include/bits/types/fsfilcnt_t.h
* include/bits/types/fsid_t.h
* include/bits/types/gid_t.h
* include/bits/types/id_t.h
* include/bits/types/ino64_t.h
* include/bits/types/ino_t.h
* include/bits/types/intptr_t.h
* include/bits/types/key_t.h
* include/bits/types/loff_t.h
* include/bits/types/mode_t.h
* include/bits/types/nlink_t.h
* include/bits/types/off64_t.h
* include/bits/types/off_t.h
* include/bits/types/pid_t.h
* include/bits/types/register_t.h
* include/bits/types/socklen_t.h
* include/bits/types/ssize_t.h
* include/bits/types/suseconds_t.h
* include/bits/types/u_char.h
* include/bits/types/u_intN_t.h
* include/bits/types/uchar.h
* include/bits/types/uid_t.h
* include/bits/types/useconds_t.h: New wrappers.
Diff:
---
bits/socket.h | 8 +-
dirent/dirent.h | 14 +--
grp/grp.h | 6 +-
include/bits/types/blkcnt64_t.h | 1 +
include/bits/types/blkcnt_t.h | 1 +
include/bits/types/blksize_t.h | 1 +
include/bits/types/caddr_t.h | 1 +
include/bits/types/daddr_t.h | 1 +
include/bits/types/dev_t.h | 1 +
include/bits/types/fsblkcnt64_t.h | 1 +
include/bits/types/fsblkcnt_t.h | 1 +
include/bits/types/fsfilcnt64_t.h | 1 +
include/bits/types/fsfilcnt_t.h | 1 +
include/bits/types/fsid_t.h | 1 +
include/bits/types/gid_t.h | 1 +
include/bits/types/id_t.h | 1 +
include/bits/types/ino64_t.h | 1 +
include/bits/types/ino_t.h | 1 +
include/bits/types/intptr_t.h | 1 +
include/bits/types/key_t.h | 1 +
include/bits/types/loff_t.h | 1 +
include/bits/types/mode_t.h | 1 +
include/bits/types/nlink_t.h | 1 +
include/bits/types/off64_t.h | 1 +
include/bits/types/off_t.h | 1 +
include/bits/types/pid_t.h | 1 +
include/bits/types/register_t.h | 1 +
include/bits/types/socklen_t.h | 1 +
include/bits/types/ssize_t.h | 1 +
include/bits/types/suseconds_t.h | 1 +
include/bits/types/u_int.h | 1 +
include/bits/types/u_intN_t.h | 1 +
include/bits/types/uid_t.h | 1 +
include/bits/types/uint.h | 1 +
include/bits/types/useconds_t.h | 1 +
inet/arpa/inet.h | 7 +-
io/fcntl.h | 27 +----
io/sys/stat.h | 66 ++---------
io/sys/statvfs.h | 21 +---
libio/stdio.h | 19 +--
misc/sys/mman.h | 16 +--
misc/sys/select.h | 7 +-
posix/Makefile | 37 ++++--
posix/bits/types/blkcnt64_t.h | 9 ++
posix/bits/types/blkcnt_t.h | 13 +++
posix/bits/types/blksize_t.h | 9 ++
posix/bits/types/caddr_t.h | 9 ++
posix/bits/types/daddr_t.h | 9 ++
posix/bits/types/dev_t.h | 9 ++
posix/bits/types/fsblkcnt64_t.h | 9 ++
posix/bits/types/fsblkcnt_t.h | 13 +++
posix/bits/types/fsfilcnt64_t.h | 9 ++
posix/bits/types/fsfilcnt_t.h | 13 +++
posix/bits/types/fsid_t.h | 9 ++
posix/bits/types/gid_t.h | 9 ++
posix/bits/types/id_t.h | 10 ++
posix/bits/types/ino64_t.h | 9 ++
posix/bits/types/ino_t.h | 13 +++
posix/bits/types/intptr_t.h | 10 ++
posix/bits/types/key_t.h | 9 ++
posix/bits/types/loff_t.h | 9 ++
posix/bits/types/mode_t.h | 9 ++
posix/bits/types/nlink_t.h | 9 ++
posix/bits/types/off64_t.h | 9 ++
posix/bits/types/off_t.h | 13 +++
posix/bits/types/pid_t.h | 9 ++
posix/bits/types/register_t.h | 9 ++
posix/bits/types/socklen_t.h | 9 ++
posix/bits/types/ssize_t.h | 9 ++
posix/bits/types/suseconds_t.h | 9 ++
posix/bits/types/u_int.h | 15 +++
posix/bits/types/u_intN_t.h | 17 +++
posix/bits/types/uid_t.h | 9 ++
posix/bits/types/uint.h | 10 ++
posix/bits/types/useconds_t.h | 9 ++
posix/sched.h | 6 +-
posix/sys/types.h | 212 +++++++---------------------------
posix/sys/wait.h | 11 +-
posix/unistd.h | 54 ++-------
pwd/pwd.h | 11 +-
resource/sys/resource.h | 6 +-
scripts/check-obsolete-constructs.py | 74 ++++++++++--
signal/signal.h | 12 +-
stdlib/monetary.h | 7 +-
stdlib/stdint.h | 5 +-
sunrpc/rpc/types.h | 44 +++----
sysdeps/gnu/utmpx.h | 5 +-
sysdeps/mach/hurd/bits/socket.h | 8 +-
sysdeps/unix/sysv/linux/bits/socket.h | 7 +-
sysvipc/sys/ipc.h | 24 +---
sysvipc/sys/msg.h | 12 +-
sysvipc/sys/shm.h | 9 +-
termios/termios.h | 8 +-
time/sys/time.h | 6 +-
time/time.h | 5 +-
95 files changed, 571 insertions(+), 540 deletions(-)
diff --git a/bits/socket.h b/bits/socket.h
index fdcf015..6687a47 100644
--- a/bits/socket.h
+++ b/bits/socket.h
@@ -28,13 +28,7 @@
#include <bits/wordsize.h>
#include <bits/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
-
+#include <bits/types/socklen_t.h>
/* Types of sockets. */
enum __socket_type
diff --git a/dirent/dirent.h b/dirent/dirent.h
index fc4d485..9639ae9 100644
--- a/dirent/dirent.h
+++ b/dirent/dirent.h
@@ -29,17 +29,9 @@ __BEGIN_DECLS
#include <bits/types.h>
#ifdef __USE_XOPEN
-# ifndef __ino_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __ino_t ino_t;
-# else
-typedef __ino64_t ino_t;
-# endif
-# define __ino_t_defined
-# endif
-# if defined __USE_LARGEFILE64 && !defined __ino64_t_defined
-typedef __ino64_t ino64_t;
-# define __ino64_t_defined
+# include <bits/types/ino_t.h>
+# ifdef __USE_LARGEFILE64
+# include <bits/types/ino64_t.h>
# endif
#endif
diff --git a/grp/grp.h b/grp/grp.h
index 0663c8f..d8f7683 100644
--- a/grp/grp.h
+++ b/grp/grp.h
@@ -31,11 +31,9 @@ __BEGIN_DECLS
#define __need_size_t
#include <stddef.h>
-
/* For the Single Unix specification we must define this type here. */
-#if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
+#if defined __USE_XOPEN || defined __USE_XOPEN2K
+# include <bits/types/gid_t.h>
#endif
/* The group structure. */
diff --git a/include/bits/types/blkcnt64_t.h b/include/bits/types/blkcnt64_t.h
new file mode 100644
index 0000000..c0c2ced
--- /dev/null
+++ b/include/bits/types/blkcnt64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/blkcnt64_t.h>
diff --git a/include/bits/types/blkcnt_t.h b/include/bits/types/blkcnt_t.h
new file mode 100644
index 0000000..ad8ed24
--- /dev/null
+++ b/include/bits/types/blkcnt_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/blkcnt_t.h>
diff --git a/include/bits/types/blksize_t.h b/include/bits/types/blksize_t.h
new file mode 100644
index 0000000..d6ed861
--- /dev/null
+++ b/include/bits/types/blksize_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/blksize_t.h>
diff --git a/include/bits/types/caddr_t.h b/include/bits/types/caddr_t.h
new file mode 100644
index 0000000..9d499e7
--- /dev/null
+++ b/include/bits/types/caddr_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/caddr_t.h>
diff --git a/include/bits/types/daddr_t.h b/include/bits/types/daddr_t.h
new file mode 100644
index 0000000..90050fa
--- /dev/null
+++ b/include/bits/types/daddr_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/daddr_t.h>
diff --git a/include/bits/types/dev_t.h b/include/bits/types/dev_t.h
new file mode 100644
index 0000000..f0451c0
--- /dev/null
+++ b/include/bits/types/dev_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/dev_t.h>
diff --git a/include/bits/types/fsblkcnt64_t.h b/include/bits/types/fsblkcnt64_t.h
new file mode 100644
index 0000000..b5951d5
--- /dev/null
+++ b/include/bits/types/fsblkcnt64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsblkcnt64_t.h>
diff --git a/include/bits/types/fsblkcnt_t.h b/include/bits/types/fsblkcnt_t.h
new file mode 100644
index 0000000..9fc9e41
--- /dev/null
+++ b/include/bits/types/fsblkcnt_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsblkcnt_t.h>
diff --git a/include/bits/types/fsfilcnt64_t.h b/include/bits/types/fsfilcnt64_t.h
new file mode 100644
index 0000000..d3152d4
--- /dev/null
+++ b/include/bits/types/fsfilcnt64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsfilcnt64_t.h>
diff --git a/include/bits/types/fsfilcnt_t.h b/include/bits/types/fsfilcnt_t.h
new file mode 100644
index 0000000..fc092c5
--- /dev/null
+++ b/include/bits/types/fsfilcnt_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsfilcnt_t.h>
diff --git a/include/bits/types/fsid_t.h b/include/bits/types/fsid_t.h
new file mode 100644
index 0000000..9d1e517
--- /dev/null
+++ b/include/bits/types/fsid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsid_t.h>
diff --git a/include/bits/types/gid_t.h b/include/bits/types/gid_t.h
new file mode 100644
index 0000000..d8cf23b
--- /dev/null
+++ b/include/bits/types/gid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/gid_t.h>
diff --git a/include/bits/types/id_t.h b/include/bits/types/id_t.h
new file mode 100644
index 0000000..5eaae0b
--- /dev/null
+++ b/include/bits/types/id_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/id_t.h>
diff --git a/include/bits/types/ino64_t.h b/include/bits/types/ino64_t.h
new file mode 100644
index 0000000..4203764
--- /dev/null
+++ b/include/bits/types/ino64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/ino64_t.h>
diff --git a/include/bits/types/ino_t.h b/include/bits/types/ino_t.h
new file mode 100644
index 0000000..2624ae5
--- /dev/null
+++ b/include/bits/types/ino_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/ino_t.h>
diff --git a/include/bits/types/intptr_t.h b/include/bits/types/intptr_t.h
new file mode 100644
index 0000000..455151b
--- /dev/null
+++ b/include/bits/types/intptr_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/intptr_t.h>
diff --git a/include/bits/types/key_t.h b/include/bits/types/key_t.h
new file mode 100644
index 0000000..c4d96aa
--- /dev/null
+++ b/include/bits/types/key_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/key_t.h>
diff --git a/include/bits/types/loff_t.h b/include/bits/types/loff_t.h
new file mode 100644
index 0000000..933175c
--- /dev/null
+++ b/include/bits/types/loff_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/loff_t.h>
diff --git a/include/bits/types/mode_t.h b/include/bits/types/mode_t.h
new file mode 100644
index 0000000..58602b5
--- /dev/null
+++ b/include/bits/types/mode_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/mode_t.h>
diff --git a/include/bits/types/nlink_t.h b/include/bits/types/nlink_t.h
new file mode 100644
index 0000000..f330ae2
--- /dev/null
+++ b/include/bits/types/nlink_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/nlink_t.h>
diff --git a/include/bits/types/off64_t.h b/include/bits/types/off64_t.h
new file mode 100644
index 0000000..002d920
--- /dev/null
+++ b/include/bits/types/off64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/off64_t.h>
diff --git a/include/bits/types/off_t.h b/include/bits/types/off_t.h
new file mode 100644
index 0000000..1f18d15
--- /dev/null
+++ b/include/bits/types/off_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/off_t.h>
diff --git a/include/bits/types/pid_t.h b/include/bits/types/pid_t.h
new file mode 100644
index 0000000..6de6aff
--- /dev/null
+++ b/include/bits/types/pid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/pid_t.h>
diff --git a/include/bits/types/register_t.h b/include/bits/types/register_t.h
new file mode 100644
index 0000000..6828620
--- /dev/null
+++ b/include/bits/types/register_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/register_t.h>
diff --git a/include/bits/types/socklen_t.h b/include/bits/types/socklen_t.h
new file mode 100644
index 0000000..229f676
--- /dev/null
+++ b/include/bits/types/socklen_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/socklen_t.h>
diff --git a/include/bits/types/ssize_t.h b/include/bits/types/ssize_t.h
new file mode 100644
index 0000000..374e438
--- /dev/null
+++ b/include/bits/types/ssize_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/ssize_t.h>
diff --git a/include/bits/types/suseconds_t.h b/include/bits/types/suseconds_t.h
new file mode 100644
index 0000000..85f0dbe
--- /dev/null
+++ b/include/bits/types/suseconds_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/suseconds_t.h>
diff --git a/include/bits/types/u_int.h b/include/bits/types/u_int.h
new file mode 100644
index 0000000..2b17d5b
--- /dev/null
+++ b/include/bits/types/u_int.h
@@ -0,0 +1 @@
+#include <posix/bits/types/u_int.h>
diff --git a/include/bits/types/u_intN_t.h b/include/bits/types/u_intN_t.h
new file mode 100644
index 0000000..ffb17bc
--- /dev/null
+++ b/include/bits/types/u_intN_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/u_intN_t.h>
diff --git a/include/bits/types/uid_t.h b/include/bits/types/uid_t.h
new file mode 100644
index 0000000..1e2b106
--- /dev/null
+++ b/include/bits/types/uid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/uid_t.h>
diff --git a/include/bits/types/uint.h b/include/bits/types/uint.h
new file mode 100644
index 0000000..a446b7f
--- /dev/null
+++ b/include/bits/types/uint.h
@@ -0,0 +1 @@
+#include <posix/bits/types/uint.h>
diff --git a/include/bits/types/useconds_t.h b/include/bits/types/useconds_t.h
new file mode 100644
index 0000000..71f720b
--- /dev/null
+++ b/include/bits/types/useconds_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/useconds_t.h>
diff --git a/inet/arpa/inet.h b/inet/arpa/inet.h
index 4db2087..facee27 100644
--- a/inet/arpa/inet.h
+++ b/inet/arpa/inet.h
@@ -20,12 +20,7 @@
#include <features.h>
#include <netinet/in.h> /* To define `struct in_addr'. */
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
+#include <bits/types/socklen_t.h>
__BEGIN_DECLS
diff --git a/io/fcntl.h b/io/fcntl.h
index 7af8dfb..2e973e6 100644
--- a/io/fcntl.h
+++ b/io/fcntl.h
@@ -46,28 +46,11 @@ __BEGIN_DECLS
/* POSIX.1-2001 specifies that these types are defined by <fcntl.h>.
Earlier POSIX standards permitted any type ending in `_t' to be defined
by any POSIX header, so we don't conditionalize the definitions here. */
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
-
-#ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-#endif
-
-#if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
-#endif
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
+#include <bits/types/mode_t.h>
+#include <bits/types/off_t.h>
+#include <bits/types/pid_t.h>
+#ifdef __USE_LARGEFILE64
+#include <bits/types/off64_t.h>
#endif
/* For XPG all symbols from <sys/stat.h> should also be available. */
diff --git a/io/sys/stat.h b/io/sys/stat.h
index 2de5eb6..e05985e 100644
--- a/io/sys/stat.h
+++ b/io/sys/stat.h
@@ -33,67 +33,19 @@
#if defined __USE_XOPEN || defined __USE_XOPEN2K
/* The Single Unix specification says that some more types are
available here. */
-
# include <bits/types/time_t.h>
-
-# ifndef __dev_t_defined
-typedef __dev_t dev_t;
-# define __dev_t_defined
-# endif
-
-# ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-# endif
-
-# ifndef __ino_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __ino_t ino_t;
-# else
-typedef __ino64_t ino_t;
-# endif
-# define __ino_t_defined
-# endif
-
-# ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-# endif
-
-# ifndef __nlink_t_defined
-typedef __nlink_t nlink_t;
-# define __nlink_t_defined
-# endif
-
-# ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-# endif
-
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
+# include <bits/types/dev_t.h>
+# include <bits/types/gid_t.h>
+# include <bits/types/ino_t.h>
+# include <bits/types/mode_t.h>
+# include <bits/types/nlink_t.h>
+# include <bits/types/off_t.h>
+# include <bits/types/uid_t.h>
#endif /* X/Open */
#ifdef __USE_UNIX98
-# ifndef __blkcnt_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __blkcnt_t blkcnt_t;
-# else
-typedef __blkcnt64_t blkcnt_t;
-# endif
-# define __blkcnt_t_defined
-# endif
-
-# ifndef __blksize_t_defined
-typedef __blksize_t blksize_t;
-# define __blksize_t_defined
-# endif
+# include <bits/types/blkcnt_t.h>
+# include <bits/types/blksize_t.h>
#endif /* Unix98 */
__BEGIN_DECLS
diff --git a/io/sys/statvfs.h b/io/sys/statvfs.h
index 89abf02..d7283dd 100644
--- a/io/sys/statvfs.h
+++ b/io/sys/statvfs.h
@@ -24,25 +24,8 @@
/* Get the system-specific definition of `struct statfs'. */
#include <bits/statvfs.h>
-#ifndef __USE_FILE_OFFSET64
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#else
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt64_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt64_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#endif
+#include <bits/types/fsblkcnt_t.h>
+#include <bits/types/fsfilcnt_t.h>
__BEGIN_DECLS
diff --git a/libio/stdio.h b/libio/stdio.h
index b63ee88..6fabdbe 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -58,25 +58,14 @@ typedef __gnuc_va_list va_list;
#endif
#if defined __USE_UNIX98 || defined __USE_XOPEN2K
-# ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-# endif
-# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
+# include <bits/types/off_t.h>
+# ifdef __USE_LARGEFILE64
+# include <bits/types/off64_t.h>
# endif
#endif
#ifdef __USE_XOPEN2K8
-# ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-# endif
+# include <bits/types/ssize_t.h>
#endif
/* The type of the second argument to `fgetpos' and `fsetpos'. */
diff --git a/misc/sys/mman.h b/misc/sys/mman.h
index b275120..43552c3 100644
--- a/misc/sys/mman.h
+++ b/misc/sys/mman.h
@@ -21,22 +21,12 @@
#include <features.h>
#include <bits/types.h>
+
#define __need_size_t
#include <stddef.h>
-#ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-#endif
-
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
+#include <bits/types/off_t.h>
+#include <bits/types/mode_t.h>
#include <bits/mman.h>
diff --git a/misc/sys/select.h b/misc/sys/select.h
index 8b10702..84e2ae3 100644
--- a/misc/sys/select.h
+++ b/misc/sys/select.h
@@ -38,12 +38,7 @@
#ifdef __USE_XOPEN2K
# include <bits/types/struct_timespec.h>
#endif
-
-#ifndef __suseconds_t_defined
-typedef __suseconds_t suseconds_t;
-# define __suseconds_t_defined
-#endif
-
+#include <bits/types/suseconds_t.h>
/* The fd_set member is required to be an array of longs. */
typedef long int __fd_mask;
diff --git a/posix/Makefile b/posix/Makefile
index 8ac6743..882f78c 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -22,17 +22,32 @@ subdir := posix
include ../Makeconfig
-headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \
- glob.h regex.h wordexp.h fnmatch.h \
- getopt.h bits/getopt_core.h bits/getopt_ext.h bits/getopt_posix.h \
- bits/types.h bits/typesizes.h bits/pthreadtypes.h \
- bits/pthreadtypes-arch.h bits/thread-shared-types.h \
- bits/posix1_lim.h bits/posix2_lim.h bits/posix_opt.h \
- bits/local_lim.h tar.h bits/utsname.h bits/confname.h \
- bits/waitflags.h bits/waitstatus.h sys/unistd.h sched.h \
- bits/sched.h bits/cpu-set.h re_comp.h wait.h bits/environments.h \
- cpio.h spawn.h bits/unistd.h bits/types/struct_sched_param.h \
- bits/unistd_ext.h
+headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \
+ glob.h regex.h wordexp.h fnmatch.h getopt.h \
+ bits/getopt_core.h bits/getopt_ext.h bits/getopt_posix.h \
+ bits/types.h bits/typesizes.h bits/pthreadtypes.h \
+ bits/pthreadtypes-arch.h bits/thread-shared-types.h \
+ bits/posix1_lim.h bits/posix2_lim.h bits/posix_opt.h \
+ bits/local_lim.h tar.h bits/utsname.h bits/confname.h \
+ bits/waitflags.h bits/waitstatus.h sys/unistd.h sched.h \
+ bits/sched.h bits/cpu-set.h re_comp.h wait.h \
+ bits/environments.h cpio.h spawn.h bits/unistd.h \
+ bits/types/struct_sched_param.h bits/unistd_ext.h \
+ bits/types/blkcnt64_t.h bits/types/blkcnt_t.h \
+ bits/types/blksize_t.h bits/types/caddr_t.h \
+ bits/types/daddr_t.h bits/types/dev_t.h \
+ bits/types/fsblkcnt64_t.h bits/types/fsblkcnt_t.h \
+ bits/types/fsfilcnt64_t.h bits/types/fsfilcnt_t.h \
+ bits/types/fsid_t.h bits/types/gid_t.h bits/types/id_t.h \
+ bits/types/ino64_t.h bits/types/ino_t.h \
+ bits/types/intptr_t.h bits/types/key_t.h \
+ bits/types/loff_t.h bits/types/mode_t.h \
+ bits/types/nlink_t.h bits/types/off64_t.h \
+ bits/types/off_t.h bits/types/pid_t.h \
+ bits/types/register_t.h bits/types/ssize_t.h \
+ bits/types/socklen_t.h bits/types/suseconds_t.h \
+ bits/types/uid_t.h bits/types/uint.h bits/types/u_int.h \
+ bits/types/u_intN_t.h bits/types/useconds_t.h
routines := \
uname \
diff --git a/posix/bits/types/blkcnt64_t.h b/posix/bits/types/blkcnt64_t.h
new file mode 100644
index 0000000..d5d81e7
--- /dev/null
+++ b/posix/bits/types/blkcnt64_t.h
@@ -0,0 +1,9 @@
+#ifndef __blkcnt64_t_defined
+#define __blkcnt64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count disk blocks (LFS). */
+typedef __blkcnt64_t blkcnt64_t;
+
+#endif
diff --git a/posix/bits/types/blkcnt_t.h b/posix/bits/types/blkcnt_t.h
new file mode 100644
index 0000000..badcd47
--- /dev/null
+++ b/posix/bits/types/blkcnt_t.h
@@ -0,0 +1,13 @@
+#ifndef __blkcnt_t_defined
+#define __blkcnt_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count number of disk blocks (POSIX). */
+#ifndef __USE_FILE_OFFSET64
+typedef __blkcnt_t blkcnt_t;
+#else
+typedef __blkcnt64_t blkcnt_t;
+#endif
+
+#endif
diff --git a/posix/bits/types/blksize_t.h b/posix/bits/types/blksize_t.h
new file mode 100644
index 0000000..9d6ada4
--- /dev/null
+++ b/posix/bits/types/blksize_t.h
@@ -0,0 +1,9 @@
+#ifndef __blksize_t_defined
+#define __blksize_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for sizes of disk blocks (POSIX). */
+typedef __blksize_t blksize_t;
+
+#endif
diff --git a/posix/bits/types/caddr_t.h b/posix/bits/types/caddr_t.h
new file mode 100644
index 0000000..fc010bd
--- /dev/null
+++ b/posix/bits/types/caddr_t.h
@@ -0,0 +1,9 @@
+#ifndef __caddr_t_defined
+#define __caddr_t_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete type for a memory address (BSD). */
+typedef __caddr_t caddr_t;
+
+#endif
diff --git a/posix/bits/types/daddr_t.h b/posix/bits/types/daddr_t.h
new file mode 100644
index 0000000..59f0b1b
--- /dev/null
+++ b/posix/bits/types/daddr_t.h
@@ -0,0 +1,9 @@
+#ifndef __daddr_t_defined
+#define __daddr_t_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete type for a disk address (BSD). */
+typedef __daddr_t daddr_t;
+
+#endif
diff --git a/posix/bits/types/dev_t.h b/posix/bits/types/dev_t.h
new file mode 100644
index 0000000..0b45f91
--- /dev/null
+++ b/posix/bits/types/dev_t.h
@@ -0,0 +1,9 @@
+#ifndef __dev_t_defined
+#define __dev_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for device IDs (POSIX). */
+typedef __dev_t dev_t;
+
+#endif
diff --git a/posix/bits/types/fsblkcnt64_t.h b/posix/bits/types/fsblkcnt64_t.h
new file mode 100644
index 0000000..690d601
--- /dev/null
+++ b/posix/bits/types/fsblkcnt64_t.h
@@ -0,0 +1,9 @@
+#ifndef __fsblkcnt64_t_defined
+#define __fsblkcnt64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system blocks (LFS). */
+typedef __fsblkcnt64_t fsblkcnt64_t;
+
+#endif
diff --git a/posix/bits/types/fsblkcnt_t.h b/posix/bits/types/fsblkcnt_t.h
new file mode 100644
index 0000000..2c7e80d
--- /dev/null
+++ b/posix/bits/types/fsblkcnt_t.h
@@ -0,0 +1,13 @@
+#ifndef __fsblkcnt_t_defined
+#define __fsblkcnt_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system blocks (POSIX). */
+#ifndef __USE_FILE_OFFSET64
+typedef __fsblkcnt_t fsblkcnt_t;
+#else
+typedef __fsblkcnt64_t fsblkcnt_t;
+#endif
+
+#endif
diff --git a/posix/bits/types/fsfilcnt64_t.h b/posix/bits/types/fsfilcnt64_t.h
new file mode 100644
index 0000000..56fcbc7
--- /dev/null
+++ b/posix/bits/types/fsfilcnt64_t.h
@@ -0,0 +1,9 @@
+#ifndef __fsfilcnt64_t_defined
+#define __fsfilcnt64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system inodes (LFS). */
+typedef __fsfilcnt64_t fsfilcnt64_t;
+
+#endif
diff --git a/posix/bits/types/fsfilcnt_t.h b/posix/bits/types/fsfilcnt_t.h
new file mode 100644
index 0000000..18d0f7e
--- /dev/null
+++ b/posix/bits/types/fsfilcnt_t.h
@@ -0,0 +1,13 @@
+#ifndef __fsfilcnt_t_defined
+#define __fsfilcnt_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system inodes (POSIX). */
+#ifndef __USE_FILE_OFFSET64
+typedef __fsfilcnt_t fsfilcnt_t;
+#else
+typedef __fsfilcnt64_t fsfilcnt_t;
+#endif
+
+#endif
diff --git a/posix/bits/types/fsid_t.h b/posix/bits/types/fsid_t.h
new file mode 100644
index 0000000..a198d30
--- /dev/null
+++ b/posix/bits/types/fsid_t.h
@@ -0,0 +1,9 @@
+#ifndef __fsid_t_defined
+#define __fsid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for a file system ID (BSD). */
+typedef __fsid_t fsid_t;
+
+#endif
diff --git a/posix/bits/types/gid_t.h b/posix/bits/types/gid_t.h
new file mode 100644
index 0000000..52974a1
--- /dev/null
+++ b/posix/bits/types/gid_t.h
@@ -0,0 +1,9 @@
+#ifndef __gid_t_defined
+#define __gid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for group IDs (POSIX). */
+typedef __gid_t gid_t;
+
+#endif
diff --git a/posix/bits/types/id_t.h b/posix/bits/types/id_t.h
new file mode 100644
index 0000000..1cb3b76
--- /dev/null
+++ b/posix/bits/types/id_t.h
@@ -0,0 +1,10 @@
+#ifndef __id_t_defined
+#define __id_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for a general identifier, can hold any pid_t, uid_t, or gid_t
+ value (POSIX). */
+typedef __id_t id_t;
+
+#endif
diff --git a/posix/bits/types/ino64_t.h b/posix/bits/types/ino64_t.h
new file mode 100644
index 0000000..e61e75a
--- /dev/null
+++ b/posix/bits/types/ino64_t.h
@@ -0,0 +1,9 @@
+#ifndef __ino64_t_defined
+#define __ino64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file serial numbers (LFS). */
+typedef __ino64_t ino64_t;
+
+#endif
diff --git a/posix/bits/types/ino_t.h b/posix/bits/types/ino_t.h
new file mode 100644
index 0000000..808821f
--- /dev/null
+++ b/posix/bits/types/ino_t.h
@@ -0,0 +1,13 @@
+#ifndef __ino_t_defined
+#define __ino_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file serial numbers (POSIX). */
+# ifndef __USE_FILE_OFFSET64
+typedef __ino_t ino_t;
+# else
+typedef __ino64_t ino_t;
+# endif
+
+#endif
diff --git a/posix/bits/types/intptr_t.h b/posix/bits/types/intptr_t.h
new file mode 100644
index 0000000..47948f9
--- /dev/null
+++ b/posix/bits/types/intptr_t.h
@@ -0,0 +1,10 @@
+#ifndef __intptr_t_defined
+#define __intptr_t_defined 1
+
+#include <bits/types.h>
+
+/* Signed integral type capable of representing a `void *' without
+ data loss (C1999). */
+typedef __intptr_t intptr_t;
+
+#endif
diff --git a/posix/bits/types/key_t.h b/posix/bits/types/key_t.h
new file mode 100644
index 0000000..424d250
--- /dev/null
+++ b/posix/bits/types/key_t.h
@@ -0,0 +1,9 @@
+#ifndef __key_t_defined
+#define __key_t_defined 1
+
+#include <bits/types.h>
+
+/* Type used by interprocess communication operations (XSI). */
+typedef __key_t key_t;
+
+#endif
diff --git a/posix/bits/types/loff_t.h b/posix/bits/types/loff_t.h
new file mode 100644
index 0000000..ecb9989
--- /dev/null
+++ b/posix/bits/types/loff_t.h
@@ -0,0 +1,9 @@
+#ifndef __loff_t_defined
+#define __loff_t_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete type for file sizes and offsets within a file (BSD). */
+typedef __loff_t loff_t;
+
+#endif
diff --git a/posix/bits/types/mode_t.h b/posix/bits/types/mode_t.h
new file mode 100644
index 0000000..3aaa70d
--- /dev/null
+++ b/posix/bits/types/mode_t.h
@@ -0,0 +1,9 @@
+#ifndef __mode_t_defined
+#define __mode_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file attribute bits (POSIX). */
+typedef __mode_t mode_t;
+
+#endif
diff --git a/posix/bits/types/nlink_t.h b/posix/bits/types/nlink_t.h
new file mode 100644
index 0000000..2f9125b
--- /dev/null
+++ b/posix/bits/types/nlink_t.h
@@ -0,0 +1,9 @@
+#ifndef __nlink_t_defined
+#define __nlink_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for link counts (POSIX). */
+typedef __nlink_t nlink_t;
+
+#endif
diff --git a/posix/bits/types/off64_t.h b/posix/bits/types/off64_t.h
new file mode 100644
index 0000000..f00bd82
--- /dev/null
+++ b/posix/bits/types/off64_t.h
@@ -0,0 +1,9 @@
+#ifndef __off64_t_defined
+#define __off64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file sizes and offsets within a file (LFS). */
+typedef __off64_t off64_t;
+
+#endif
diff --git a/posix/bits/types/off_t.h b/posix/bits/types/off_t.h
new file mode 100644
index 0000000..9ef5395
--- /dev/null
+++ b/posix/bits/types/off_t.h
@@ -0,0 +1,13 @@
+#ifndef __off_t_defined
+#define __off_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file sizes and offsets within a file (POSIX). */
+# ifndef __USE_FILE_OFFSET64
+typedef __off_t off_t;
+# else
+typedef __off64_t off_t;
+# endif
+
+#endif
diff --git a/posix/bits/types/pid_t.h b/posix/bits/types/pid_t.h
new file mode 100644
index 0000000..249e070
--- /dev/null
+++ b/posix/bits/types/pid_t.h
@@ -0,0 +1,9 @@
+#ifndef __pid_t_defined
+#define __pid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for process IDs and process group IDs (POSIX). */
+typedef __pid_t pid_t;
+
+#endif
diff --git a/posix/bits/types/register_t.h b/posix/bits/types/register_t.h
new file mode 100644
index 0000000..099b472
--- /dev/null
+++ b/posix/bits/types/register_t.h
@@ -0,0 +1,9 @@
+#ifndef __register_t_defined
+#define __register_t_defined 1
+
+#include <bits/types.h>
+
+/* Type of a general-purpose integer register (BSD). */
+typedef __register_t register_t;
+
+#endif
diff --git a/posix/bits/types/socklen_t.h b/posix/bits/types/socklen_t.h
new file mode 100644
index 0000000..8369630
--- /dev/null
+++ b/posix/bits/types/socklen_t.h
@@ -0,0 +1,9 @@
+#ifndef __socklen_t_defined
+#define __socklen_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for size of socket addresses (POSIX). */
+typedef __socklen_t socklen_t;
+
+#endif
diff --git a/posix/bits/types/ssize_t.h b/posix/bits/types/ssize_t.h
new file mode 100644
index 0000000..41e1fd7
--- /dev/null
+++ b/posix/bits/types/ssize_t.h
@@ -0,0 +1,9 @@
+#ifndef __ssize_t_defined
+#define __ssize_t_defined 1
+
+#include <bits/types.h>
+
+/* Type used for a count of bytes or an error indication (POSIX). */
+typedef __ssize_t ssize_t;
+
+#endif
diff --git a/posix/bits/types/suseconds_t.h b/posix/bits/types/suseconds_t.h
new file mode 100644
index 0000000..62ded6f
--- /dev/null
+++ b/posix/bits/types/suseconds_t.h
@@ -0,0 +1,9 @@
+#ifndef __suseconds_t_defined
+#define __suseconds_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for time in microseconds (signed) (XSI). */
+typedef __suseconds_t suseconds_t;
+
+#endif
diff --git a/posix/bits/types/u_int.h b/posix/bits/types/u_int.h
new file mode 100644
index 0000000..4c9235f
--- /dev/null
+++ b/posix/bits/types/u_int.h
@@ -0,0 +1,15 @@
+#ifndef __u_int_defined
+#define __u_int_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete shorthand names for unsigned types, used by old BSD
+ networking code and Sun RPC. */
+typedef unsigned char u_char;
+typedef unsigned short int u_short;
+typedef unsigned int u_int;
+typedef unsigned long int u_long;
+typedef __int64_t quad_t;
+typedef __uint64_t u_quad_t;
+
+#endif
diff --git a/posix/bits/types/u_intN_t.h b/posix/bits/types/u_intN_t.h
new file mode 100644
index 0000000..6257674
--- /dev/null
+++ b/posix/bits/types/u_intN_t.h
@@ -0,0 +1,17 @@
+#ifndef __u_intN_t_defined
+#define __u_intN_t_defined 1
+
+#include <bits/types.h>
+
+/* These size-specific names are used by some of the inet code.
+ They were defined by ISO C without the first `_'. */
+typedef __uint8_t u_int8_t;
+typedef __uint16_t u_int16_t;
+typedef __uint32_t u_int32_t;
+typedef __uint64_t u_int64_t;
+
+/* Some code from BIND tests this macro to see if the types above are
+ defined. */
+#define __BIT_TYPES_DEFINED__ 1
+
+#endif
diff --git a/posix/bits/types/uid_t.h b/posix/bits/types/uid_t.h
new file mode 100644
index 0000000..371cb05
--- /dev/null
+++ b/posix/bits/types/uid_t.h
@@ -0,0 +1,9 @@
+#ifndef __uid_t_defined
+#define __uid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for user IDs (POSIX). */
+typedef __uid_t uid_t;
+
+#endif
diff --git a/posix/bits/types/uint.h b/posix/bits/types/uint.h
new file mode 100644
index 0000000..69829c6
--- /dev/null
+++ b/posix/bits/types/uint.h
@@ -0,0 +1,10 @@
+#ifndef __uint_defined
+#define __uint_defined 1
+
+/* Obsolete shorthand names for unsigned types, used by old BSD
+ networking code and Sun RPC. */
+typedef unsigned short int ushort;
+typedef unsigned int uint;
+typedef unsigned long int ulong;
+
+#endif
diff --git a/posix/bits/types/useconds_t.h b/posix/bits/types/useconds_t.h
new file mode 100644
index 0000000..a363558
--- /dev/null
+++ b/posix/bits/types/useconds_t.h
@@ -0,0 +1,9 @@
+#ifndef __useconds_t_defined
+#define __useconds_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for time in microseconds (unsigned) (XSI). */
+typedef __useconds_t useconds_t;
+
+#endif
diff --git a/posix/sched.h b/posix/sched.h
index 90ef6fc..56c1470 100644
--- a/posix/sched.h
+++ b/posix/sched.h
@@ -33,11 +33,7 @@
#ifndef __USE_XOPEN2K
# include <time.h>
#endif
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
+#include <bits/types/pid_t.h>
/* Get system specific constant and data structure definitions. */
#include <bits/sched.h>
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 2d8cfd1..8f6d328 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -28,120 +28,51 @@ __BEGIN_DECLS
#include <bits/types.h>
-#ifdef __USE_MISC
-# ifndef __u_char_defined
-typedef unsigned char u_char;
-typedef unsigned short int u_short;
-typedef unsigned int u_int;
-typedef unsigned long int u_long;
-typedef __int64_t quad_t;
-typedef __uint64_t u_quad_t;
-typedef __fsid_t fsid_t;
-# define __u_char_defined
-# endif
-typedef __loff_t loff_t;
-#endif
-
-#ifndef __ino_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __ino_t ino_t;
-# else
-typedef __ino64_t ino_t;
-# endif
-# define __ino_t_defined
-#endif
-#if defined __USE_LARGEFILE64 && !defined __ino64_t_defined
-typedef __ino64_t ino64_t;
-# define __ino64_t_defined
-#endif
-
-#ifndef __dev_t_defined
-typedef __dev_t dev_t;
-# define __dev_t_defined
-#endif
-
-#ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-#endif
-
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
-
-#ifndef __nlink_t_defined
-typedef __nlink_t nlink_t;
-# define __nlink_t_defined
-#endif
-
-#ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-#endif
-
-#ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-#endif
-#if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
-#endif
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
-
-#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) \
- && !defined __id_t_defined
-typedef __id_t id_t;
-# define __id_t_defined
-#endif
+#define __need_size_t
+#include <stddef.h>
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
+#include <bits/types/blkcnt_t.h>
+#include <bits/types/clockid_t.h>
+#include <bits/types/dev_t.h>
+#include <bits/types/fsblkcnt_t.h>
+#include <bits/types/fsfilcnt_t.h>
+#include <bits/types/gid_t.h>
+#include <bits/types/ino_t.h>
+#include <bits/types/mode_t.h>
+#include <bits/types/nlink_t.h>
+#include <bits/types/off_t.h>
+#include <bits/types/pid_t.h>
+#include <bits/types/ssize_t.h>
+#include <bits/types/time_t.h>
+#include <bits/types/timer_t.h>
+#include <bits/types/uid_t.h>
-#ifdef __USE_MISC
-# ifndef __daddr_t_defined
-typedef __daddr_t daddr_t;
-typedef __caddr_t caddr_t;
-# define __daddr_t_defined
-# endif
+#ifdef __USE_LARGEFILE64
+# include <bits/types/blkcnt64_t.h>
+# include <bits/types/fsblkcnt64_t.h>
+# include <bits/types/fsfilcnt64_t.h>
+# include <bits/types/ino64_t.h>
+# include <bits/types/off64_t.h>
#endif
-#if (defined __USE_MISC || defined __USE_XOPEN) && !defined __key_t_defined
-typedef __key_t key_t;
-# define __key_t_defined
+#ifdef __USE_XOPEN
+# include <bits/types/useconds_t.h>
+# include <bits/types/suseconds_t.h>
#endif
#if defined __USE_XOPEN || defined __USE_XOPEN2K8
# include <bits/types/clock_t.h>
+# include <bits/types/id_t.h>
+# include <bits/types/key_t.h>
#endif
-#include <bits/types/clockid_t.h>
-#include <bits/types/time_t.h>
-#include <bits/types/timer_t.h>
-#ifdef __USE_XOPEN
-# ifndef __useconds_t_defined
-typedef __useconds_t useconds_t;
-# define __useconds_t_defined
-# endif
-# ifndef __suseconds_t_defined
-typedef __suseconds_t suseconds_t;
-# define __suseconds_t_defined
-# endif
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
+#include <bits/types/blksize_t.h>
#endif
-#define __need_size_t
-#include <stddef.h>
+#if defined __USE_POSIX199506 || defined __USE_UNIX98
+# include <bits/pthreadtypes.h>
+#endif
/* POSIX does not require intN_t to be defined in this header, so
technically this ought to be under __USE_MISC, but it doesn't
@@ -150,24 +81,17 @@ typedef __suseconds_t suseconds_t;
#include <bits/stdint-intn.h>
#ifdef __USE_MISC
-/* Old compatibility names for C types. */
-typedef unsigned long int ulong;
-typedef unsigned short int ushort;
-typedef unsigned int uint;
-
-/* These size-specific names are used by some of the inet code.
- They were defined by ISO C without the first `_'. */
-typedef __uint8_t u_int8_t;
-typedef __uint16_t u_int16_t;
-typedef __uint32_t u_int32_t;
-typedef __uint64_t u_int64_t;
-
-/* Type of a general-purpose integer register (BSD). */
-typedef __register_t register_t;
-
-/* Some code from BIND tests this macro to see if the types above are
- defined. */
-#define __BIT_TYPES_DEFINED__ 1
+/* Additional typedefs from BSD, mostly obsolete. */
+# include <bits/types/caddr_t.h>
+# include <bits/types/daddr_t.h>
+# include <bits/types/fsid_t.h>
+# include <bits/types/loff_t.h>
+# include <bits/types/register_t.h>
+
+/* Shorthand unsigned types, mostly superseded by stdint.h. */
+# include <bits/types/uint.h>
+# include <bits/types/u_int.h>
+# include <bits/types/u_intN_t.h>
/* In BSD <sys/types.h> is expected to define BYTE_ORDER. */
# include <endian.h>
@@ -176,54 +100,6 @@ typedef __register_t register_t;
# include <sys/select.h>
#endif /* Use misc. */
-
-#if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) \
- && !defined __blksize_t_defined
-typedef __blksize_t blksize_t;
-# define __blksize_t_defined
-#endif
-
-/* Types from the Large File Support interface. */
-#ifndef __USE_FILE_OFFSET64
-# ifndef __blkcnt_t_defined
-typedef __blkcnt_t blkcnt_t; /* Type to count number of disk blocks. */
-# define __blkcnt_t_defined
-# endif
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#else
-# ifndef __blkcnt_t_defined
-typedef __blkcnt64_t blkcnt_t; /* Type to count number of disk blocks. */
-# define __blkcnt_t_defined
-# endif
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt64_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt64_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#endif
-
-#ifdef __USE_LARGEFILE64
-typedef __blkcnt64_t blkcnt64_t; /* Type to count number of disk blocks. */
-typedef __fsblkcnt64_t fsblkcnt64_t; /* Type to count file system blocks. */
-typedef __fsfilcnt64_t fsfilcnt64_t; /* Type to count file system inodes. */
-#endif
-
-
-/* Now add the thread types. */
-#if defined __USE_POSIX199506 || defined __USE_UNIX98
-# include <bits/pthreadtypes.h>
-#endif
-
__END_DECLS
#endif /* sys/types.h */
diff --git a/posix/sys/wait.h b/posix/sys/wait.h
index 9bd4399..691be27 100644
--- a/posix/sys/wait.h
+++ b/posix/sys/wait.h
@@ -27,10 +27,7 @@
__BEGIN_DECLS
#include <bits/types.h>
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
+#include <bits/types/pid_t.h>
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
# include <signal.h>
@@ -111,11 +108,7 @@ extern __pid_t wait (int *__stat_loc);
extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-# ifndef __id_t_defined
-typedef __id_t id_t;
-# define __id_t_defined
-# endif
-
+# include <bits/types/id_t.h>
# include <bits/types/siginfo_t.h>
/* Wait for a childing matching IDTYPE and ID to change the status and
diff --git a/posix/unistd.h b/posix/unistd.h
index 55a989f..407f2fe 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -215,11 +215,7 @@ __BEGIN_DECLS
/* All functions that are not declared anywhere else. */
#include <bits/types.h>
-
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
+#include <bits/types/ssize_t.h>
#define __need_size_t
#define __need_NULL
@@ -228,52 +224,22 @@ typedef __ssize_t ssize_t;
#if defined __USE_XOPEN || defined __USE_XOPEN2K
/* The Single Unix specification says that some more types are
available here. */
-# ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-# endif
-
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
-
-# ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-# endif
-# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
-# endif
-
-# ifndef __useconds_t_defined
-typedef __useconds_t useconds_t;
-# define __useconds_t_defined
-# endif
-
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
+# include <bits/types/gid_t.h>
+# include <bits/types/uid_t.h>
+# include <bits/types/off_t.h>
+# ifdef __USE_LARGEFILE64
+# include <bits/types/off64_t.h>
# endif
+# include <bits/types/useconds_t.h>
+# include <bits/types/pid_t.h>
#endif /* X/Open */
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
-# ifndef __intptr_t_defined
-typedef __intptr_t intptr_t;
-# define __intptr_t_defined
-# endif
+# include <bits/types/intptr_t.h>
#endif
#if defined __USE_MISC || defined __USE_XOPEN
-# ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-# endif
+# include <bits/types/socklen_t.h>
#endif
/* Values for the second argument to access.
diff --git a/pwd/pwd.h b/pwd/pwd.h
index 1002ed3..ccb3bc0 100644
--- a/pwd/pwd.h
+++ b/pwd/pwd.h
@@ -34,15 +34,8 @@ __BEGIN_DECLS
#if defined __USE_XOPEN || defined __USE_XOPEN2K
/* The Single Unix specification says that some more types are
available here. */
-# ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-# endif
-
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
+# include <bits/types/gid_t.h>
+# include <bits/types/uid_t.h>
#endif
/* A record in the user database. */
diff --git a/resource/sys/resource.h b/resource/sys/resource.h
index 928646b..3ed33c4 100644
--- a/resource/sys/resource.h
+++ b/resource/sys/resource.h
@@ -22,11 +22,7 @@
/* Get the system-dependent definitions of structures and bit values. */
#include <bits/resource.h>
-
-#ifndef __id_t_defined
-typedef __id_t id_t;
-# define __id_t_defined
-#endif
+#include <bits/types/id_t.h>
__BEGIN_DECLS
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 518de75..49338c0 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -28,6 +28,7 @@
import argparse
import collections
+import os.path
import re
import sys
@@ -264,15 +265,40 @@ OBSOLETE_TYPE_RE_ = re.compile(r"""\A
| _(?: char | short | int(?:[0-9]+_t)? | long | quad_t )))
\Z""", re.VERBOSE)
+# The headers that declare them:
+OBSOLETE_TYPE_HDR_RE_ = re.compile(r"""\A
+ [<"] bits/types/
+ (?: [cd]addr_t
+ | loff_t
+ | register_t
+ | uint
+ | u_int
+ | u_intN_t ) \.h [">]
+\Z""", re.VERBOSE)
+
class ObsoleteNotAllowed(ConstructChecker):
- """Don't allow any use of the obsolete typedefs."""
+ """Don't allow any use of the obsolete typedefs,
+ or the headers that declare them."""
def examine(self, tok):
- if OBSOLETE_TYPE_RE_.match(tok.text):
+ if ((tok.kind == "IDENT"
+ and OBSOLETE_TYPE_RE_.match(tok.text))
+ or (tok.kind == "HEADER_NAME"
+ and OBSOLETE_TYPE_HDR_RE_.match(tok.text))):
+ self.reporter.error(tok, "use of {!r}")
+
+class ObsoleteIndirectDefinitionsAllowed(ConstructChecker):
+ """Don't allow any use of the obsolete typedefs,
+ but do allow inclusion of the headers that declare them."""
+ def examine(self, tok):
+ if (tok.kind == "IDENT"
+ and OBSOLETE_TYPE_RE_.match(tok.text)):
self.reporter.error(tok, "use of {!r}")
class ObsoletePrivateDefinitionsAllowed(ConstructChecker):
"""Allow definitions of the private versions of the
obsolete typedefs; that is, 'typedef [anything] __obsolete;'
+ Don't allow inclusion of headers that declare the public
+ versions.
"""
def __init__(self, reporter):
super().__init__(reporter)
@@ -300,10 +326,14 @@ class ObsoletePrivateDefinitionsAllowed(ConstructChecker):
self._check_prev()
def _check_prev(self):
- if (self.prev_token is not None
- and self.prev_token.kind == "IDENT"
- and OBSOLETE_TYPE_RE_.match(self.prev_token.text)):
- self.reporter.error(self.prev_token, "use of {!r}")
+ tok = self.prev_token
+ if tok is None:
+ return
+ if ((tok.kind == "IDENT"
+ and OBSOLETE_TYPE_RE_.match(tok.text))
+ or (tok.kind == "HEADER_NAME"
+ and OBSOLETE_TYPE_HDR_RE_.match(tok.text))):
+ self.reporter.error(tok, "use of {!r}")
class ObsoletePublicDefinitionsAllowed(ConstructChecker):
"""Allow definitions of the public versions of the obsolete
@@ -317,6 +347,9 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
typedef unsigned char u_char;
typedef __int64_t quad_t;
typedef __uint64_t u_quad_t;
+
+ Don't allow inclusion of headers that declare public
+ versions of other obsolete typedefs.
"""
def __init__(self, reporter):
super().__init__(reporter)
@@ -337,6 +370,10 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
elif tok.kind == "PUNCTUATOR" and tok.text == ";":
self._finish()
+ elif tok.kind == "HEADER_NAME":
+ if OBSOLETE_TYPE_HDR_RE_.match(tok.text):
+ self.reporter.error(tok, "use of {!r}")
+
elif self.typedef_tokens:
self.typedef_tokens.append(tok)
@@ -406,19 +443,38 @@ def ObsoleteTypedefChecker(reporter, fname):
or fname.startswith("rpcsvc/")
or "/rpc/" in fname
or "/rpcsvc/" in fname):
+ sys.stderr.write("# No typedef checks for {}\n".format(fname))
return NoCheck(reporter)
# bits/types.h is allowed to define the __-versions of the
# obsolete types.
if (fname == "bits/types.h"
or fname.endswith("/bits/types.h")):
+ sys.stderr.write("# Obsolete private defs allowed for {}\n"
+ .format(fname))
return ObsoletePrivateDefinitionsAllowed(reporter)
- # sys/types.h is allowed to use the __-versions of the
- # obsolete types, but only to define the unprefixed versions.
+ # Certain bits/types/ headers are allowed to define the
+ # unprefixed versions of the obsolete types.
+ if ((fname.startswith("bits/types/")
+ or "/bits/types/" in fname)
+ and os.path.basename(fname) in ("caddr_t.h",
+ "daddr_t.h",
+ "loff_t.h",
+ "register_t.h",
+ "uint.h",
+ "u_int.h",
+ "u_intN_t.h")):
+ sys.stderr.write("# Obsolete public defs allowed for {}\n"
+ .format(fname))
+ return ObsoletePublicDefinitionsAllowed(reporter)
+
+ # sys/types.h is allowed to include the above bits/types/ headers.
if (fname == "sys/types.h"
or fname.endswith("/sys/types.h")):
- return ObsoletePublicDefinitionsAllowed(reporter)
+ sys.stderr.write("# Obsolete indirect defs allowed for {}\n"
+ .format(fname))
+ return ObsoleteIndirectDefinitionsAllowed(reporter)
return ObsoleteNotAllowed(reporter)
diff --git a/signal/signal.h b/signal/signal.h
index 4c0de7f..ec70101 100644
--- a/signal/signal.h
+++ b/signal/signal.h
@@ -36,16 +36,8 @@ __BEGIN_DECLS
#endif
#if defined __USE_XOPEN || defined __USE_XOPEN2K
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
-#ifdef __USE_XOPEN
-# endif
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
+# include <bits/types/pid_t.h>
+# include <bits/types/uid_t.h>
#endif /* Unix98 */
#ifdef __USE_POSIX199309
diff --git a/stdlib/monetary.h b/stdlib/monetary.h
index 1cecd05..1f3347a 100644
--- a/stdlib/monetary.h
+++ b/stdlib/monetary.h
@@ -25,12 +25,7 @@
#define __need_size_t
#include <stddef.h>
#include <bits/types.h>
-
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
-
+#include <bits/types/ssize_t.h>
__BEGIN_DECLS
diff --git a/stdlib/stdint.h b/stdlib/stdint.h
index 8645d91..aca50d1 100644
--- a/stdlib/stdint.h
+++ b/stdlib/stdint.h
@@ -82,10 +82,7 @@ typedef unsigned long long int uint_fast64_t;
/* Types for `void *' pointers. */
-# ifndef __intptr_t_defined
-typedef __intptr_t intptr_t;
-# define __intptr_t_defined
-# endif
+#include <bits/types/intptr_t.h>
typedef __uintptr_t uintptr_t;
/* Largest integral types. */
diff --git a/sunrpc/rpc/types.h b/sunrpc/rpc/types.h
index 99e5f4f..13ef47f 100644
--- a/sunrpc/rpc/types.h
+++ b/sunrpc/rpc/types.h
@@ -34,6 +34,19 @@
#ifndef _RPC_TYPES_H
#define _RPC_TYPES_H 1
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/param.h>
+#include <netinet/in.h>
+
+#ifndef __BIT_TYPES_DEFINED__
+#include <bits/types/caddr_t.h>
+#include <bits/types/daddr_t.h>
+#include <bits/types/fsid_t.h>
+#include <bits/types/u_int.h>
+#endif
+
typedef int bool_t;
typedef int enum_t;
/* This needs to be changed to uint32_t in the future */
@@ -57,7 +70,6 @@ typedef unsigned long rpcport_t;
# define NULL 0
#endif
-#include <stdlib.h> /* For malloc decl. */
#define mem_alloc(bsize) malloc(bsize)
/*
* XXX: This must not use the second argument, or code in xdr_array.c needs
@@ -65,36 +77,6 @@ typedef unsigned long rpcport_t;
*/
#define mem_free(ptr, bsize) free(ptr)
-#ifndef makedev /* ie, we haven't already included it */
-#include <sys/types.h>
-#endif
-
-#if defined __APPLE_CC__ || defined __FreeBSD__
-# define __u_char_defined
-# define __daddr_t_defined
-#endif
-
-#ifndef __u_char_defined
-typedef unsigned char u_char;
-typedef unsigned short int u_short;
-typedef unsigned int u_int;
-typedef unsigned long int u_long;
-typedef __int64_t quad_t;
-typedef __uint64_t u_quad_t;
-typedef __fsid_t fsid_t;
-# define __u_char_defined
-#endif
-#ifndef __daddr_t_defined
-typedef __daddr_t daddr_t;
-typedef __caddr_t caddr_t;
-# define __daddr_t_defined
-#endif
-
-#include <sys/time.h>
-#include <sys/param.h>
-
-#include <netinet/in.h>
-
#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK (u_long)0x7F000001
#endif
diff --git a/sysdeps/gnu/utmpx.h b/sysdeps/gnu/utmpx.h
index 9274102..41c122d 100644
--- a/sysdeps/gnu/utmpx.h
+++ b/sysdeps/gnu/utmpx.h
@@ -22,10 +22,7 @@
#include <sys/time.h>
/* Required according to Unix98. */
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
+#include <bits/types/pid_t.h>
/* Get system dependent values and data structures. */
#include <bits/utmpx.h>
diff --git a/sysdeps/mach/hurd/bits/socket.h b/sysdeps/mach/hurd/bits/socket.h
index f7f3cc4..429e66c 100644
--- a/sysdeps/mach/hurd/bits/socket.h
+++ b/sysdeps/mach/hurd/bits/socket.h
@@ -29,13 +29,7 @@
#include <bits/wordsize.h>
#include <sys/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
-
+#include <bits/types/socklen_t.h>
/* Types of sockets. */
enum __socket_type
diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h
index 99af01d..cf3c03a 100644
--- a/sysdeps/unix/sysv/linux/bits/socket.h
+++ b/sysdeps/unix/sysv/linux/bits/socket.h
@@ -27,12 +27,7 @@
#include <stddef.h>
#include <sys/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
+#include <bits/types/socklen_t.h>
/* Get the architecture-dependent definition of enum __socket_type. */
#include <bits/socket_type.h>
diff --git a/sysvipc/sys/ipc.h b/sysvipc/sys/ipc.h
index 516e275..8aa7f38 100644
--- a/sysvipc/sys/ipc.h
+++ b/sysvipc/sys/ipc.h
@@ -23,26 +23,10 @@
/* Get system dependent definition of `struct ipc_perm' and more. */
#include <bits/ipctypes.h>
#include <bits/ipc.h>
-
-#ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-#endif
-
-#ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-#endif
-
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
-
-#ifndef __key_t_defined
-typedef __key_t key_t;
-# define __key_t_defined
-#endif
+#include <bits/types/uid_t.h>
+#include <bits/types/gid_t.h>
+#include <bits/types/mode_t.h>
+#include <bits/types/key_t.h>
__BEGIN_DECLS
diff --git a/sysvipc/sys/msg.h b/sysvipc/sys/msg.h
index 1ce4672..f2f18f4 100644
--- a/sysvipc/sys/msg.h
+++ b/sysvipc/sys/msg.h
@@ -31,16 +31,8 @@
/* Define types required by the standard. */
#include <bits/types/time_t.h>
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
-
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
+#include <bits/types/pid_t.h>
+#include <bits/types/ssize_t.h>
/* The following System V style IPC functions implement a message queue
system. The definition is found in XPG2. */
diff --git a/sysvipc/sys/shm.h b/sysvipc/sys/shm.h
index c15f419..bf836a7 100644
--- a/sysvipc/sys/shm.h
+++ b/sysvipc/sys/shm.h
@@ -31,14 +31,9 @@
/* Define types required by the standard. */
#include <bits/types/time_t.h>
-
#ifdef __USE_XOPEN
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-# endif
-#endif /* X/Open */
-
+# include <bits/types/pid_t.h>
+#endif
__BEGIN_DECLS
diff --git a/termios/termios.h b/termios/termios.h
index 2234208..b883dc8 100644
--- a/termios/termios.h
+++ b/termios/termios.h
@@ -23,13 +23,9 @@
#define _TERMIOS_H 1
#include <features.h>
+
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-/* We need `pid_t'. */
-# include <bits/types.h>
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-# endif
+# include <bits/types/pid_t.h>
#endif
__BEGIN_DECLS
diff --git a/time/sys/time.h b/time/sys/time.h
index 5dbc7fc..1059d30 100644
--- a/time/sys/time.h
+++ b/time/sys/time.h
@@ -23,11 +23,7 @@
#include <bits/types.h>
#include <bits/types/time_t.h>
#include <bits/types/struct_timeval.h>
-
-#ifndef __suseconds_t_defined
-typedef __suseconds_t suseconds_t;
-# define __suseconds_t_defined
-#endif
+#include <bits/types/suseconds_t.h>
#include <sys/select.h>
diff --git a/time/time.h b/time/time.h
index cba6d15..232531c 100644
--- a/time/time.h
+++ b/time/time.h
@@ -50,10 +50,7 @@ struct sigevent;
#endif
#ifdef __USE_XOPEN2K
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-# endif
+# include <bits/types/pid_t.h>
#endif
#ifdef __USE_XOPEN2K8
^ permalink raw reply [flat|nested] 4+ messages in thread
* [glibc/zack/no-nested-includes] Create bits/types headers for most remaining __T_defined macros.
@ 2019-06-18 15:33 Zack Weinberg
0 siblings, 0 replies; 4+ messages in thread
From: Zack Weinberg @ 2019-06-18 15:33 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4f874f78b23afbe4629bb19acc081bb783adbe3c
commit 4f874f78b23afbe4629bb19acc081bb783adbe3c
Author: Zack Weinberg <zackw@panix.com>
Date: Sat Mar 9 20:54:02 2019 -0500
Create bits/types headers for most remaining __T_defined macros.
This doesn't exactly fit the theme but as long as I'm tinkering with
sys/types.h it makes sense to go through and create single-declaration
bits/types/ headers for all of the remaining cases where we have
two or more headers declaring a public type.
The remaining uses of the original __T_defined idiom are:
__error_t_defined in files shared with gnulib, which probably has to
remain as is; ____gwchar_t_defined in inttypes.h, which may not be
necessary anymore and should be addressed separately, and
__ldiv_t_defined and __lldiv_t_defined in stdlib.h, ditto.
Our handling of LFS types is a little inconsistent: some headers
declare both off_t and off64_t (for instance) when
_LARGEFILE64_SOURCE, others will only declare off_t regardless of
_LARGEFILE64_SOURCE. I don't know if this was intentional or not.
I am tempted to centralize responsibility for _LARGEFILE64_SOURCE as
well as _FILE_OFFSET_BITS=64 in bits/types/off_t.h (etc) so that any
header that declares off_t will automatically also declare off64_t
when _LARGEFILE64_SOURCE.
sunrpc/rpc/types.h is special, because it is included in files
compiled by the *build* compiler (cross-rpcgen-objs), and therefore it
cannot unconditionally assume bits/types headers are available. What
I did was have it include the appropriate bits/types headers only if
including sys/types.h did not cause __BIT_TYPES_DEFINED__ to be
defined. This will do the right thing when an installed rpc/types.h
is included by application code compiled without __USE_MISC in effect.
During the build, we rely on the fact that we compile all of our own
code with __USE_MISC in effect. This is fragile, but should be
acceptable for code that's no longer built by default anyway.
scripts/check-obsolete-constructs.py ensures that only sys/types.h and
rpc/types.h include the bits/types/ headers that define obsolete types.
* posix/bits/types/blkcnt64_t.h
* posix/bits/types/blkcnt_t.h
* posix/bits/types/blksize_t.h
* posix/bits/types/dev_t.h
* posix/bits/types/fsblkcnt64_t.h
* posix/bits/types/fsblkcnt_t.h
* posix/bits/types/fsfilcnt64_t.h
* posix/bits/types/fsfilcnt_t.h
* posix/bits/types/fsid_t.h
* posix/bits/types/gid_t.h
* posix/bits/types/id_t.h
* posix/bits/types/ino64_t.h
* posix/bits/types/ino_t.h
* posix/bits/types/intptr_t.h
* posix/bits/types/key_t.h
* posix/bits/types/loff_t.h
* posix/bits/types/mode_t.h
* posix/bits/types/nlink_t.h
* posix/bits/types/off64_t.h
* posix/bits/types/off_t.h
* posix/bits/types/pid_t.h
* posix/bits/types/socklen_t.h
* posix/bits/types/ssize_t.h
* posix/bits/types/suseconds_t.h
* posix/bits/types/uid_t.h
* posix/bits/types/useconds_t.h:
New single-declaration headers for standard types canonically
defined by sys/types.h, sys/socket.h, or inttypes.h but also
exposed by other headers under some circumstances. Code moved
from posix/sys/types.h, socket/sys/socket.h, stdlib/inttypes.h
as appropriate.
* posix/bits/types/uint.h
* posix/bits/types/u_int.h
* posix/bits/types/u_intN_t.h
* posix/bits/types/caddr_t.h
* posix/bits/types/daddr_t.h
* posix/bits/types/loff_t.h
* posix/bits/types/register_t.h:
Similarly, but for obsolete BSD-derived types whose canonical
home is sys/types.h. Some of these headers define more than
one type.
* posix/Makefile (headers): Install the above new headers.
Rewrap the list.
* posix/sys/types.h: All definitions of public types now
accomplished using the above new headers. Consolidate
groups of definitions controlled by the same feature
selection macros.
* inet/arpa/inet.h, bits/socket.h
* sysdeps/mach/hurd/bits/socket.h
* sysdeps/unix/sysv/linux/bits/socket.h:
Use bits/types/socklen_t.h.
* dirent/dirent.h: Use bits/types/ino_t.h and bits/types/ino64_t.h.
* grp/grp.h: Use bits/types/gid_t.h.
* io/fcntl.h: Use bits/types/mode_t.h, bits/types/off_t.h,
bits/types/pid_t.h, and bits/types/off64_t.h.
* io/sys/stat.h: Use bits/types/dev_t.h, bits/types/gid_t.h,
bits/types/ino_t.h, bits/types/mode_t.h, bits/types/nlink_t.h,
bits/types/off_t.h, bits/types/uid_t.h, and bits/types/blkcnt_t.h.
* libio/stdio.h: Use bits/types/off_t.h, bits/types/off64_t.h,
and bits/types/ssize_t.h.
* misc/sys/mman.h: Use bits/types/off_t.h and bits/types/mode_t.h.
* misc/sys/select.h: Use bits/types/suseconds_t.h.
* posix/sched.h: Use bits/types/pid_t.h.
* posix/sys/wait.h: Use bits/types/pid_t.h and bits/types/id_t.h.
* posix/unistd.h: Use bits/types/gid_t.h, bits/types/uid_t.h,
bits/types/off_t.h, bits/types/off64_t.h, bits/types/useconds_t.h,
bits/types/intptr_t.h, and bits/types/socklen_t.h.
* pwd/pwd.h: Use bits/types/gid_t.h and bits/types/uid_t.h.
* resource/sys/resource.h: Use bits/types/id_t.h.
* signal/signal.h: Use bits/types/pid_t.h and bits/types/uid_t.h.
* stdlib/monetary.h: Use bits/types/ssize_t.h.
* sysdeps/gnu/utmpx.h: Use bits/types/pid_t.h.
* sysvipc/sys/ipc.h: Use bits/types/uid_t.h, bits/types/gid_t.h,
bits/types/mode_t.h, and bits/types/key_t.h.
* sysvipc/sys/msg.h: Use bits/types/pid_t.h and bits/types/ssize_t.h.
* sysvipc/sys/shm.h: Use bits/types/pid_t.h.
* termios/termios.h: Use bits/types/pid_t.h.
* time/sys/time.h: Use bits/types/suseconds_t.h.
* time/time.h: Use bits/types/pid_t.h.
* sunrpc/rpc/types.h: Consolidate all #includes at the top of
the file. If __BIT_TYPES_DEFINED__ is not defined after
including sys/types.h, also include bits/types/caddr_t.h,
bits/types/daddr_t.h, bits/types/fsid_t.h, and bits/types/u_int.h.
* scripts/check-obsolete-constructs.py (OBSOLETE_TYPE_HDR_RE_): New.
(ObsoleteIndirectDefinitionsAllowed): New; allows inclusion of
bits/types/ headers that define obsolete typedefs, but not
direct definitions of those types.
(ObsoleteNotAllowed, ObsoletePrivateDefinitionsAllowed)
(ObsoletePublicDefinitionsAllowed): Do not allow inclusion of
bits/types/ headers that define obsolete typedefs.
* include/bits/types/blkcnt64_t.h
* include/bits/types/blkcnt_t.h
* include/bits/types/blksize_t.h
* include/bits/types/caddr_t.h
* include/bits/types/daddr_t.h
* include/bits/types/dev_t.h
* include/bits/types/fsblkcnt64_t.h
* include/bits/types/fsblkcnt_t.h
* include/bits/types/fsfilcnt64_t.h
* include/bits/types/fsfilcnt_t.h
* include/bits/types/fsid_t.h
* include/bits/types/gid_t.h
* include/bits/types/id_t.h
* include/bits/types/ino64_t.h
* include/bits/types/ino_t.h
* include/bits/types/intptr_t.h
* include/bits/types/key_t.h
* include/bits/types/loff_t.h
* include/bits/types/mode_t.h
* include/bits/types/nlink_t.h
* include/bits/types/off64_t.h
* include/bits/types/off_t.h
* include/bits/types/pid_t.h
* include/bits/types/register_t.h
* include/bits/types/socklen_t.h
* include/bits/types/ssize_t.h
* include/bits/types/suseconds_t.h
* include/bits/types/u_char.h
* include/bits/types/u_intN_t.h
* include/bits/types/uchar.h
* include/bits/types/uid_t.h
* include/bits/types/useconds_t.h: New wrappers.
Diff:
---
bits/socket.h | 8 +-
dirent/dirent.h | 14 +--
grp/grp.h | 6 +-
include/bits/types/blkcnt64_t.h | 1 +
include/bits/types/blkcnt_t.h | 1 +
include/bits/types/blksize_t.h | 1 +
include/bits/types/caddr_t.h | 1 +
include/bits/types/daddr_t.h | 1 +
include/bits/types/dev_t.h | 1 +
include/bits/types/fsblkcnt64_t.h | 1 +
include/bits/types/fsblkcnt_t.h | 1 +
include/bits/types/fsfilcnt64_t.h | 1 +
include/bits/types/fsfilcnt_t.h | 1 +
include/bits/types/fsid_t.h | 1 +
include/bits/types/gid_t.h | 1 +
include/bits/types/id_t.h | 1 +
include/bits/types/ino64_t.h | 1 +
include/bits/types/ino_t.h | 1 +
include/bits/types/intptr_t.h | 1 +
include/bits/types/key_t.h | 1 +
include/bits/types/loff_t.h | 1 +
include/bits/types/mode_t.h | 1 +
include/bits/types/nlink_t.h | 1 +
include/bits/types/off64_t.h | 1 +
include/bits/types/off_t.h | 1 +
include/bits/types/pid_t.h | 1 +
include/bits/types/register_t.h | 1 +
include/bits/types/socklen_t.h | 1 +
include/bits/types/ssize_t.h | 1 +
include/bits/types/suseconds_t.h | 1 +
include/bits/types/u_int.h | 1 +
include/bits/types/u_intN_t.h | 1 +
include/bits/types/uid_t.h | 1 +
include/bits/types/uint.h | 1 +
include/bits/types/useconds_t.h | 1 +
inet/arpa/inet.h | 7 +-
io/fcntl.h | 27 +----
io/sys/stat.h | 66 ++---------
io/sys/statvfs.h | 21 +---
libio/stdio.h | 19 +--
misc/sys/mman.h | 16 +--
misc/sys/select.h | 7 +-
posix/Makefile | 37 ++++--
posix/bits/types/blkcnt64_t.h | 9 ++
posix/bits/types/blkcnt_t.h | 13 +++
posix/bits/types/blksize_t.h | 9 ++
posix/bits/types/caddr_t.h | 9 ++
posix/bits/types/daddr_t.h | 9 ++
posix/bits/types/dev_t.h | 9 ++
posix/bits/types/fsblkcnt64_t.h | 9 ++
posix/bits/types/fsblkcnt_t.h | 13 +++
posix/bits/types/fsfilcnt64_t.h | 9 ++
posix/bits/types/fsfilcnt_t.h | 13 +++
posix/bits/types/fsid_t.h | 9 ++
posix/bits/types/gid_t.h | 9 ++
posix/bits/types/id_t.h | 10 ++
posix/bits/types/ino64_t.h | 9 ++
posix/bits/types/ino_t.h | 13 +++
posix/bits/types/intptr_t.h | 10 ++
posix/bits/types/key_t.h | 9 ++
posix/bits/types/loff_t.h | 9 ++
posix/bits/types/mode_t.h | 9 ++
posix/bits/types/nlink_t.h | 9 ++
posix/bits/types/off64_t.h | 9 ++
posix/bits/types/off_t.h | 13 +++
posix/bits/types/pid_t.h | 9 ++
posix/bits/types/register_t.h | 9 ++
posix/bits/types/socklen_t.h | 9 ++
posix/bits/types/ssize_t.h | 9 ++
posix/bits/types/suseconds_t.h | 9 ++
posix/bits/types/u_int.h | 15 +++
posix/bits/types/u_intN_t.h | 17 +++
posix/bits/types/uid_t.h | 9 ++
posix/bits/types/uint.h | 10 ++
posix/bits/types/useconds_t.h | 9 ++
posix/sched.h | 6 +-
posix/sys/types.h | 212 +++++++---------------------------
posix/sys/wait.h | 11 +-
posix/unistd.h | 54 ++-------
pwd/pwd.h | 11 +-
resource/sys/resource.h | 6 +-
scripts/check-obsolete-constructs.py | 74 ++++++++++--
signal/signal.h | 12 +-
stdlib/monetary.h | 7 +-
stdlib/stdint.h | 5 +-
sunrpc/rpc/types.h | 44 +++----
sysdeps/gnu/utmpx.h | 5 +-
sysdeps/mach/hurd/bits/socket.h | 8 +-
sysdeps/unix/sysv/linux/bits/socket.h | 7 +-
sysvipc/sys/ipc.h | 24 +---
sysvipc/sys/msg.h | 12 +-
sysvipc/sys/shm.h | 9 +-
termios/termios.h | 8 +-
time/sys/time.h | 6 +-
time/time.h | 5 +-
95 files changed, 571 insertions(+), 540 deletions(-)
diff --git a/bits/socket.h b/bits/socket.h
index fdcf015..6687a47 100644
--- a/bits/socket.h
+++ b/bits/socket.h
@@ -28,13 +28,7 @@
#include <bits/wordsize.h>
#include <bits/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
-
+#include <bits/types/socklen_t.h>
/* Types of sockets. */
enum __socket_type
diff --git a/dirent/dirent.h b/dirent/dirent.h
index fc4d485..9639ae9 100644
--- a/dirent/dirent.h
+++ b/dirent/dirent.h
@@ -29,17 +29,9 @@ __BEGIN_DECLS
#include <bits/types.h>
#ifdef __USE_XOPEN
-# ifndef __ino_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __ino_t ino_t;
-# else
-typedef __ino64_t ino_t;
-# endif
-# define __ino_t_defined
-# endif
-# if defined __USE_LARGEFILE64 && !defined __ino64_t_defined
-typedef __ino64_t ino64_t;
-# define __ino64_t_defined
+# include <bits/types/ino_t.h>
+# ifdef __USE_LARGEFILE64
+# include <bits/types/ino64_t.h>
# endif
#endif
diff --git a/grp/grp.h b/grp/grp.h
index 0663c8f..d8f7683 100644
--- a/grp/grp.h
+++ b/grp/grp.h
@@ -31,11 +31,9 @@ __BEGIN_DECLS
#define __need_size_t
#include <stddef.h>
-
/* For the Single Unix specification we must define this type here. */
-#if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !defined __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
+#if defined __USE_XOPEN || defined __USE_XOPEN2K
+# include <bits/types/gid_t.h>
#endif
/* The group structure. */
diff --git a/include/bits/types/blkcnt64_t.h b/include/bits/types/blkcnt64_t.h
new file mode 100644
index 0000000..c0c2ced
--- /dev/null
+++ b/include/bits/types/blkcnt64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/blkcnt64_t.h>
diff --git a/include/bits/types/blkcnt_t.h b/include/bits/types/blkcnt_t.h
new file mode 100644
index 0000000..ad8ed24
--- /dev/null
+++ b/include/bits/types/blkcnt_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/blkcnt_t.h>
diff --git a/include/bits/types/blksize_t.h b/include/bits/types/blksize_t.h
new file mode 100644
index 0000000..d6ed861
--- /dev/null
+++ b/include/bits/types/blksize_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/blksize_t.h>
diff --git a/include/bits/types/caddr_t.h b/include/bits/types/caddr_t.h
new file mode 100644
index 0000000..9d499e7
--- /dev/null
+++ b/include/bits/types/caddr_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/caddr_t.h>
diff --git a/include/bits/types/daddr_t.h b/include/bits/types/daddr_t.h
new file mode 100644
index 0000000..90050fa
--- /dev/null
+++ b/include/bits/types/daddr_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/daddr_t.h>
diff --git a/include/bits/types/dev_t.h b/include/bits/types/dev_t.h
new file mode 100644
index 0000000..f0451c0
--- /dev/null
+++ b/include/bits/types/dev_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/dev_t.h>
diff --git a/include/bits/types/fsblkcnt64_t.h b/include/bits/types/fsblkcnt64_t.h
new file mode 100644
index 0000000..b5951d5
--- /dev/null
+++ b/include/bits/types/fsblkcnt64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsblkcnt64_t.h>
diff --git a/include/bits/types/fsblkcnt_t.h b/include/bits/types/fsblkcnt_t.h
new file mode 100644
index 0000000..9fc9e41
--- /dev/null
+++ b/include/bits/types/fsblkcnt_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsblkcnt_t.h>
diff --git a/include/bits/types/fsfilcnt64_t.h b/include/bits/types/fsfilcnt64_t.h
new file mode 100644
index 0000000..d3152d4
--- /dev/null
+++ b/include/bits/types/fsfilcnt64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsfilcnt64_t.h>
diff --git a/include/bits/types/fsfilcnt_t.h b/include/bits/types/fsfilcnt_t.h
new file mode 100644
index 0000000..fc092c5
--- /dev/null
+++ b/include/bits/types/fsfilcnt_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsfilcnt_t.h>
diff --git a/include/bits/types/fsid_t.h b/include/bits/types/fsid_t.h
new file mode 100644
index 0000000..9d1e517
--- /dev/null
+++ b/include/bits/types/fsid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/fsid_t.h>
diff --git a/include/bits/types/gid_t.h b/include/bits/types/gid_t.h
new file mode 100644
index 0000000..d8cf23b
--- /dev/null
+++ b/include/bits/types/gid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/gid_t.h>
diff --git a/include/bits/types/id_t.h b/include/bits/types/id_t.h
new file mode 100644
index 0000000..5eaae0b
--- /dev/null
+++ b/include/bits/types/id_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/id_t.h>
diff --git a/include/bits/types/ino64_t.h b/include/bits/types/ino64_t.h
new file mode 100644
index 0000000..4203764
--- /dev/null
+++ b/include/bits/types/ino64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/ino64_t.h>
diff --git a/include/bits/types/ino_t.h b/include/bits/types/ino_t.h
new file mode 100644
index 0000000..2624ae5
--- /dev/null
+++ b/include/bits/types/ino_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/ino_t.h>
diff --git a/include/bits/types/intptr_t.h b/include/bits/types/intptr_t.h
new file mode 100644
index 0000000..455151b
--- /dev/null
+++ b/include/bits/types/intptr_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/intptr_t.h>
diff --git a/include/bits/types/key_t.h b/include/bits/types/key_t.h
new file mode 100644
index 0000000..c4d96aa
--- /dev/null
+++ b/include/bits/types/key_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/key_t.h>
diff --git a/include/bits/types/loff_t.h b/include/bits/types/loff_t.h
new file mode 100644
index 0000000..933175c
--- /dev/null
+++ b/include/bits/types/loff_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/loff_t.h>
diff --git a/include/bits/types/mode_t.h b/include/bits/types/mode_t.h
new file mode 100644
index 0000000..58602b5
--- /dev/null
+++ b/include/bits/types/mode_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/mode_t.h>
diff --git a/include/bits/types/nlink_t.h b/include/bits/types/nlink_t.h
new file mode 100644
index 0000000..f330ae2
--- /dev/null
+++ b/include/bits/types/nlink_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/nlink_t.h>
diff --git a/include/bits/types/off64_t.h b/include/bits/types/off64_t.h
new file mode 100644
index 0000000..002d920
--- /dev/null
+++ b/include/bits/types/off64_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/off64_t.h>
diff --git a/include/bits/types/off_t.h b/include/bits/types/off_t.h
new file mode 100644
index 0000000..1f18d15
--- /dev/null
+++ b/include/bits/types/off_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/off_t.h>
diff --git a/include/bits/types/pid_t.h b/include/bits/types/pid_t.h
new file mode 100644
index 0000000..6de6aff
--- /dev/null
+++ b/include/bits/types/pid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/pid_t.h>
diff --git a/include/bits/types/register_t.h b/include/bits/types/register_t.h
new file mode 100644
index 0000000..6828620
--- /dev/null
+++ b/include/bits/types/register_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/register_t.h>
diff --git a/include/bits/types/socklen_t.h b/include/bits/types/socklen_t.h
new file mode 100644
index 0000000..229f676
--- /dev/null
+++ b/include/bits/types/socklen_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/socklen_t.h>
diff --git a/include/bits/types/ssize_t.h b/include/bits/types/ssize_t.h
new file mode 100644
index 0000000..374e438
--- /dev/null
+++ b/include/bits/types/ssize_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/ssize_t.h>
diff --git a/include/bits/types/suseconds_t.h b/include/bits/types/suseconds_t.h
new file mode 100644
index 0000000..85f0dbe
--- /dev/null
+++ b/include/bits/types/suseconds_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/suseconds_t.h>
diff --git a/include/bits/types/u_int.h b/include/bits/types/u_int.h
new file mode 100644
index 0000000..2b17d5b
--- /dev/null
+++ b/include/bits/types/u_int.h
@@ -0,0 +1 @@
+#include <posix/bits/types/u_int.h>
diff --git a/include/bits/types/u_intN_t.h b/include/bits/types/u_intN_t.h
new file mode 100644
index 0000000..ffb17bc
--- /dev/null
+++ b/include/bits/types/u_intN_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/u_intN_t.h>
diff --git a/include/bits/types/uid_t.h b/include/bits/types/uid_t.h
new file mode 100644
index 0000000..1e2b106
--- /dev/null
+++ b/include/bits/types/uid_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/uid_t.h>
diff --git a/include/bits/types/uint.h b/include/bits/types/uint.h
new file mode 100644
index 0000000..a446b7f
--- /dev/null
+++ b/include/bits/types/uint.h
@@ -0,0 +1 @@
+#include <posix/bits/types/uint.h>
diff --git a/include/bits/types/useconds_t.h b/include/bits/types/useconds_t.h
new file mode 100644
index 0000000..71f720b
--- /dev/null
+++ b/include/bits/types/useconds_t.h
@@ -0,0 +1 @@
+#include <posix/bits/types/useconds_t.h>
diff --git a/inet/arpa/inet.h b/inet/arpa/inet.h
index 4db2087..facee27 100644
--- a/inet/arpa/inet.h
+++ b/inet/arpa/inet.h
@@ -20,12 +20,7 @@
#include <features.h>
#include <netinet/in.h> /* To define `struct in_addr'. */
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
+#include <bits/types/socklen_t.h>
__BEGIN_DECLS
diff --git a/io/fcntl.h b/io/fcntl.h
index 7af8dfb..2e973e6 100644
--- a/io/fcntl.h
+++ b/io/fcntl.h
@@ -46,28 +46,11 @@ __BEGIN_DECLS
/* POSIX.1-2001 specifies that these types are defined by <fcntl.h>.
Earlier POSIX standards permitted any type ending in `_t' to be defined
by any POSIX header, so we don't conditionalize the definitions here. */
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
-
-#ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-#endif
-
-#if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
-#endif
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
+#include <bits/types/mode_t.h>
+#include <bits/types/off_t.h>
+#include <bits/types/pid_t.h>
+#ifdef __USE_LARGEFILE64
+#include <bits/types/off64_t.h>
#endif
/* For XPG all symbols from <sys/stat.h> should also be available. */
diff --git a/io/sys/stat.h b/io/sys/stat.h
index 2de5eb6..e05985e 100644
--- a/io/sys/stat.h
+++ b/io/sys/stat.h
@@ -33,67 +33,19 @@
#if defined __USE_XOPEN || defined __USE_XOPEN2K
/* The Single Unix specification says that some more types are
available here. */
-
# include <bits/types/time_t.h>
-
-# ifndef __dev_t_defined
-typedef __dev_t dev_t;
-# define __dev_t_defined
-# endif
-
-# ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-# endif
-
-# ifndef __ino_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __ino_t ino_t;
-# else
-typedef __ino64_t ino_t;
-# endif
-# define __ino_t_defined
-# endif
-
-# ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-# endif
-
-# ifndef __nlink_t_defined
-typedef __nlink_t nlink_t;
-# define __nlink_t_defined
-# endif
-
-# ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-# endif
-
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
+# include <bits/types/dev_t.h>
+# include <bits/types/gid_t.h>
+# include <bits/types/ino_t.h>
+# include <bits/types/mode_t.h>
+# include <bits/types/nlink_t.h>
+# include <bits/types/off_t.h>
+# include <bits/types/uid_t.h>
#endif /* X/Open */
#ifdef __USE_UNIX98
-# ifndef __blkcnt_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __blkcnt_t blkcnt_t;
-# else
-typedef __blkcnt64_t blkcnt_t;
-# endif
-# define __blkcnt_t_defined
-# endif
-
-# ifndef __blksize_t_defined
-typedef __blksize_t blksize_t;
-# define __blksize_t_defined
-# endif
+# include <bits/types/blkcnt_t.h>
+# include <bits/types/blksize_t.h>
#endif /* Unix98 */
__BEGIN_DECLS
diff --git a/io/sys/statvfs.h b/io/sys/statvfs.h
index 89abf02..d7283dd 100644
--- a/io/sys/statvfs.h
+++ b/io/sys/statvfs.h
@@ -24,25 +24,8 @@
/* Get the system-specific definition of `struct statfs'. */
#include <bits/statvfs.h>
-#ifndef __USE_FILE_OFFSET64
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#else
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt64_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt64_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#endif
+#include <bits/types/fsblkcnt_t.h>
+#include <bits/types/fsfilcnt_t.h>
__BEGIN_DECLS
diff --git a/libio/stdio.h b/libio/stdio.h
index b63ee88..6fabdbe 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -58,25 +58,14 @@ typedef __gnuc_va_list va_list;
#endif
#if defined __USE_UNIX98 || defined __USE_XOPEN2K
-# ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-# endif
-# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
+# include <bits/types/off_t.h>
+# ifdef __USE_LARGEFILE64
+# include <bits/types/off64_t.h>
# endif
#endif
#ifdef __USE_XOPEN2K8
-# ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-# endif
+# include <bits/types/ssize_t.h>
#endif
/* The type of the second argument to `fgetpos' and `fsetpos'. */
diff --git a/misc/sys/mman.h b/misc/sys/mman.h
index b275120..43552c3 100644
--- a/misc/sys/mman.h
+++ b/misc/sys/mman.h
@@ -21,22 +21,12 @@
#include <features.h>
#include <bits/types.h>
+
#define __need_size_t
#include <stddef.h>
-#ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-#endif
-
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
+#include <bits/types/off_t.h>
+#include <bits/types/mode_t.h>
#include <bits/mman.h>
diff --git a/misc/sys/select.h b/misc/sys/select.h
index 8b10702..84e2ae3 100644
--- a/misc/sys/select.h
+++ b/misc/sys/select.h
@@ -38,12 +38,7 @@
#ifdef __USE_XOPEN2K
# include <bits/types/struct_timespec.h>
#endif
-
-#ifndef __suseconds_t_defined
-typedef __suseconds_t suseconds_t;
-# define __suseconds_t_defined
-#endif
-
+#include <bits/types/suseconds_t.h>
/* The fd_set member is required to be an array of longs. */
typedef long int __fd_mask;
diff --git a/posix/Makefile b/posix/Makefile
index 8ac6743..882f78c 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -22,17 +22,32 @@ subdir := posix
include ../Makeconfig
-headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \
- glob.h regex.h wordexp.h fnmatch.h \
- getopt.h bits/getopt_core.h bits/getopt_ext.h bits/getopt_posix.h \
- bits/types.h bits/typesizes.h bits/pthreadtypes.h \
- bits/pthreadtypes-arch.h bits/thread-shared-types.h \
- bits/posix1_lim.h bits/posix2_lim.h bits/posix_opt.h \
- bits/local_lim.h tar.h bits/utsname.h bits/confname.h \
- bits/waitflags.h bits/waitstatus.h sys/unistd.h sched.h \
- bits/sched.h bits/cpu-set.h re_comp.h wait.h bits/environments.h \
- cpio.h spawn.h bits/unistd.h bits/types/struct_sched_param.h \
- bits/unistd_ext.h
+headers := sys/utsname.h sys/times.h sys/wait.h sys/types.h unistd.h \
+ glob.h regex.h wordexp.h fnmatch.h getopt.h \
+ bits/getopt_core.h bits/getopt_ext.h bits/getopt_posix.h \
+ bits/types.h bits/typesizes.h bits/pthreadtypes.h \
+ bits/pthreadtypes-arch.h bits/thread-shared-types.h \
+ bits/posix1_lim.h bits/posix2_lim.h bits/posix_opt.h \
+ bits/local_lim.h tar.h bits/utsname.h bits/confname.h \
+ bits/waitflags.h bits/waitstatus.h sys/unistd.h sched.h \
+ bits/sched.h bits/cpu-set.h re_comp.h wait.h \
+ bits/environments.h cpio.h spawn.h bits/unistd.h \
+ bits/types/struct_sched_param.h bits/unistd_ext.h \
+ bits/types/blkcnt64_t.h bits/types/blkcnt_t.h \
+ bits/types/blksize_t.h bits/types/caddr_t.h \
+ bits/types/daddr_t.h bits/types/dev_t.h \
+ bits/types/fsblkcnt64_t.h bits/types/fsblkcnt_t.h \
+ bits/types/fsfilcnt64_t.h bits/types/fsfilcnt_t.h \
+ bits/types/fsid_t.h bits/types/gid_t.h bits/types/id_t.h \
+ bits/types/ino64_t.h bits/types/ino_t.h \
+ bits/types/intptr_t.h bits/types/key_t.h \
+ bits/types/loff_t.h bits/types/mode_t.h \
+ bits/types/nlink_t.h bits/types/off64_t.h \
+ bits/types/off_t.h bits/types/pid_t.h \
+ bits/types/register_t.h bits/types/ssize_t.h \
+ bits/types/socklen_t.h bits/types/suseconds_t.h \
+ bits/types/uid_t.h bits/types/uint.h bits/types/u_int.h \
+ bits/types/u_intN_t.h bits/types/useconds_t.h
routines := \
uname \
diff --git a/posix/bits/types/blkcnt64_t.h b/posix/bits/types/blkcnt64_t.h
new file mode 100644
index 0000000..d5d81e7
--- /dev/null
+++ b/posix/bits/types/blkcnt64_t.h
@@ -0,0 +1,9 @@
+#ifndef __blkcnt64_t_defined
+#define __blkcnt64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count disk blocks (LFS). */
+typedef __blkcnt64_t blkcnt64_t;
+
+#endif
diff --git a/posix/bits/types/blkcnt_t.h b/posix/bits/types/blkcnt_t.h
new file mode 100644
index 0000000..badcd47
--- /dev/null
+++ b/posix/bits/types/blkcnt_t.h
@@ -0,0 +1,13 @@
+#ifndef __blkcnt_t_defined
+#define __blkcnt_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count number of disk blocks (POSIX). */
+#ifndef __USE_FILE_OFFSET64
+typedef __blkcnt_t blkcnt_t;
+#else
+typedef __blkcnt64_t blkcnt_t;
+#endif
+
+#endif
diff --git a/posix/bits/types/blksize_t.h b/posix/bits/types/blksize_t.h
new file mode 100644
index 0000000..9d6ada4
--- /dev/null
+++ b/posix/bits/types/blksize_t.h
@@ -0,0 +1,9 @@
+#ifndef __blksize_t_defined
+#define __blksize_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for sizes of disk blocks (POSIX). */
+typedef __blksize_t blksize_t;
+
+#endif
diff --git a/posix/bits/types/caddr_t.h b/posix/bits/types/caddr_t.h
new file mode 100644
index 0000000..fc010bd
--- /dev/null
+++ b/posix/bits/types/caddr_t.h
@@ -0,0 +1,9 @@
+#ifndef __caddr_t_defined
+#define __caddr_t_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete type for a memory address (BSD). */
+typedef __caddr_t caddr_t;
+
+#endif
diff --git a/posix/bits/types/daddr_t.h b/posix/bits/types/daddr_t.h
new file mode 100644
index 0000000..59f0b1b
--- /dev/null
+++ b/posix/bits/types/daddr_t.h
@@ -0,0 +1,9 @@
+#ifndef __daddr_t_defined
+#define __daddr_t_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete type for a disk address (BSD). */
+typedef __daddr_t daddr_t;
+
+#endif
diff --git a/posix/bits/types/dev_t.h b/posix/bits/types/dev_t.h
new file mode 100644
index 0000000..0b45f91
--- /dev/null
+++ b/posix/bits/types/dev_t.h
@@ -0,0 +1,9 @@
+#ifndef __dev_t_defined
+#define __dev_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for device IDs (POSIX). */
+typedef __dev_t dev_t;
+
+#endif
diff --git a/posix/bits/types/fsblkcnt64_t.h b/posix/bits/types/fsblkcnt64_t.h
new file mode 100644
index 0000000..690d601
--- /dev/null
+++ b/posix/bits/types/fsblkcnt64_t.h
@@ -0,0 +1,9 @@
+#ifndef __fsblkcnt64_t_defined
+#define __fsblkcnt64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system blocks (LFS). */
+typedef __fsblkcnt64_t fsblkcnt64_t;
+
+#endif
diff --git a/posix/bits/types/fsblkcnt_t.h b/posix/bits/types/fsblkcnt_t.h
new file mode 100644
index 0000000..2c7e80d
--- /dev/null
+++ b/posix/bits/types/fsblkcnt_t.h
@@ -0,0 +1,13 @@
+#ifndef __fsblkcnt_t_defined
+#define __fsblkcnt_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system blocks (POSIX). */
+#ifndef __USE_FILE_OFFSET64
+typedef __fsblkcnt_t fsblkcnt_t;
+#else
+typedef __fsblkcnt64_t fsblkcnt_t;
+#endif
+
+#endif
diff --git a/posix/bits/types/fsfilcnt64_t.h b/posix/bits/types/fsfilcnt64_t.h
new file mode 100644
index 0000000..56fcbc7
--- /dev/null
+++ b/posix/bits/types/fsfilcnt64_t.h
@@ -0,0 +1,9 @@
+#ifndef __fsfilcnt64_t_defined
+#define __fsfilcnt64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system inodes (LFS). */
+typedef __fsfilcnt64_t fsfilcnt64_t;
+
+#endif
diff --git a/posix/bits/types/fsfilcnt_t.h b/posix/bits/types/fsfilcnt_t.h
new file mode 100644
index 0000000..18d0f7e
--- /dev/null
+++ b/posix/bits/types/fsfilcnt_t.h
@@ -0,0 +1,13 @@
+#ifndef __fsfilcnt_t_defined
+#define __fsfilcnt_t_defined 1
+
+#include <bits/types.h>
+
+/* Type to count file system inodes (POSIX). */
+#ifndef __USE_FILE_OFFSET64
+typedef __fsfilcnt_t fsfilcnt_t;
+#else
+typedef __fsfilcnt64_t fsfilcnt_t;
+#endif
+
+#endif
diff --git a/posix/bits/types/fsid_t.h b/posix/bits/types/fsid_t.h
new file mode 100644
index 0000000..a198d30
--- /dev/null
+++ b/posix/bits/types/fsid_t.h
@@ -0,0 +1,9 @@
+#ifndef __fsid_t_defined
+#define __fsid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for a file system ID (BSD). */
+typedef __fsid_t fsid_t;
+
+#endif
diff --git a/posix/bits/types/gid_t.h b/posix/bits/types/gid_t.h
new file mode 100644
index 0000000..52974a1
--- /dev/null
+++ b/posix/bits/types/gid_t.h
@@ -0,0 +1,9 @@
+#ifndef __gid_t_defined
+#define __gid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for group IDs (POSIX). */
+typedef __gid_t gid_t;
+
+#endif
diff --git a/posix/bits/types/id_t.h b/posix/bits/types/id_t.h
new file mode 100644
index 0000000..1cb3b76
--- /dev/null
+++ b/posix/bits/types/id_t.h
@@ -0,0 +1,10 @@
+#ifndef __id_t_defined
+#define __id_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for a general identifier, can hold any pid_t, uid_t, or gid_t
+ value (POSIX). */
+typedef __id_t id_t;
+
+#endif
diff --git a/posix/bits/types/ino64_t.h b/posix/bits/types/ino64_t.h
new file mode 100644
index 0000000..e61e75a
--- /dev/null
+++ b/posix/bits/types/ino64_t.h
@@ -0,0 +1,9 @@
+#ifndef __ino64_t_defined
+#define __ino64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file serial numbers (LFS). */
+typedef __ino64_t ino64_t;
+
+#endif
diff --git a/posix/bits/types/ino_t.h b/posix/bits/types/ino_t.h
new file mode 100644
index 0000000..808821f
--- /dev/null
+++ b/posix/bits/types/ino_t.h
@@ -0,0 +1,13 @@
+#ifndef __ino_t_defined
+#define __ino_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file serial numbers (POSIX). */
+# ifndef __USE_FILE_OFFSET64
+typedef __ino_t ino_t;
+# else
+typedef __ino64_t ino_t;
+# endif
+
+#endif
diff --git a/posix/bits/types/intptr_t.h b/posix/bits/types/intptr_t.h
new file mode 100644
index 0000000..47948f9
--- /dev/null
+++ b/posix/bits/types/intptr_t.h
@@ -0,0 +1,10 @@
+#ifndef __intptr_t_defined
+#define __intptr_t_defined 1
+
+#include <bits/types.h>
+
+/* Signed integral type capable of representing a `void *' without
+ data loss (C1999). */
+typedef __intptr_t intptr_t;
+
+#endif
diff --git a/posix/bits/types/key_t.h b/posix/bits/types/key_t.h
new file mode 100644
index 0000000..424d250
--- /dev/null
+++ b/posix/bits/types/key_t.h
@@ -0,0 +1,9 @@
+#ifndef __key_t_defined
+#define __key_t_defined 1
+
+#include <bits/types.h>
+
+/* Type used by interprocess communication operations (XSI). */
+typedef __key_t key_t;
+
+#endif
diff --git a/posix/bits/types/loff_t.h b/posix/bits/types/loff_t.h
new file mode 100644
index 0000000..ecb9989
--- /dev/null
+++ b/posix/bits/types/loff_t.h
@@ -0,0 +1,9 @@
+#ifndef __loff_t_defined
+#define __loff_t_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete type for file sizes and offsets within a file (BSD). */
+typedef __loff_t loff_t;
+
+#endif
diff --git a/posix/bits/types/mode_t.h b/posix/bits/types/mode_t.h
new file mode 100644
index 0000000..3aaa70d
--- /dev/null
+++ b/posix/bits/types/mode_t.h
@@ -0,0 +1,9 @@
+#ifndef __mode_t_defined
+#define __mode_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file attribute bits (POSIX). */
+typedef __mode_t mode_t;
+
+#endif
diff --git a/posix/bits/types/nlink_t.h b/posix/bits/types/nlink_t.h
new file mode 100644
index 0000000..2f9125b
--- /dev/null
+++ b/posix/bits/types/nlink_t.h
@@ -0,0 +1,9 @@
+#ifndef __nlink_t_defined
+#define __nlink_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for link counts (POSIX). */
+typedef __nlink_t nlink_t;
+
+#endif
diff --git a/posix/bits/types/off64_t.h b/posix/bits/types/off64_t.h
new file mode 100644
index 0000000..f00bd82
--- /dev/null
+++ b/posix/bits/types/off64_t.h
@@ -0,0 +1,9 @@
+#ifndef __off64_t_defined
+#define __off64_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file sizes and offsets within a file (LFS). */
+typedef __off64_t off64_t;
+
+#endif
diff --git a/posix/bits/types/off_t.h b/posix/bits/types/off_t.h
new file mode 100644
index 0000000..9ef5395
--- /dev/null
+++ b/posix/bits/types/off_t.h
@@ -0,0 +1,13 @@
+#ifndef __off_t_defined
+#define __off_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for file sizes and offsets within a file (POSIX). */
+# ifndef __USE_FILE_OFFSET64
+typedef __off_t off_t;
+# else
+typedef __off64_t off_t;
+# endif
+
+#endif
diff --git a/posix/bits/types/pid_t.h b/posix/bits/types/pid_t.h
new file mode 100644
index 0000000..249e070
--- /dev/null
+++ b/posix/bits/types/pid_t.h
@@ -0,0 +1,9 @@
+#ifndef __pid_t_defined
+#define __pid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for process IDs and process group IDs (POSIX). */
+typedef __pid_t pid_t;
+
+#endif
diff --git a/posix/bits/types/register_t.h b/posix/bits/types/register_t.h
new file mode 100644
index 0000000..099b472
--- /dev/null
+++ b/posix/bits/types/register_t.h
@@ -0,0 +1,9 @@
+#ifndef __register_t_defined
+#define __register_t_defined 1
+
+#include <bits/types.h>
+
+/* Type of a general-purpose integer register (BSD). */
+typedef __register_t register_t;
+
+#endif
diff --git a/posix/bits/types/socklen_t.h b/posix/bits/types/socklen_t.h
new file mode 100644
index 0000000..8369630
--- /dev/null
+++ b/posix/bits/types/socklen_t.h
@@ -0,0 +1,9 @@
+#ifndef __socklen_t_defined
+#define __socklen_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for size of socket addresses (POSIX). */
+typedef __socklen_t socklen_t;
+
+#endif
diff --git a/posix/bits/types/ssize_t.h b/posix/bits/types/ssize_t.h
new file mode 100644
index 0000000..41e1fd7
--- /dev/null
+++ b/posix/bits/types/ssize_t.h
@@ -0,0 +1,9 @@
+#ifndef __ssize_t_defined
+#define __ssize_t_defined 1
+
+#include <bits/types.h>
+
+/* Type used for a count of bytes or an error indication (POSIX). */
+typedef __ssize_t ssize_t;
+
+#endif
diff --git a/posix/bits/types/suseconds_t.h b/posix/bits/types/suseconds_t.h
new file mode 100644
index 0000000..62ded6f
--- /dev/null
+++ b/posix/bits/types/suseconds_t.h
@@ -0,0 +1,9 @@
+#ifndef __suseconds_t_defined
+#define __suseconds_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for time in microseconds (signed) (XSI). */
+typedef __suseconds_t suseconds_t;
+
+#endif
diff --git a/posix/bits/types/u_int.h b/posix/bits/types/u_int.h
new file mode 100644
index 0000000..4c9235f
--- /dev/null
+++ b/posix/bits/types/u_int.h
@@ -0,0 +1,15 @@
+#ifndef __u_int_defined
+#define __u_int_defined 1
+
+#include <bits/types.h>
+
+/* Obsolete shorthand names for unsigned types, used by old BSD
+ networking code and Sun RPC. */
+typedef unsigned char u_char;
+typedef unsigned short int u_short;
+typedef unsigned int u_int;
+typedef unsigned long int u_long;
+typedef __int64_t quad_t;
+typedef __uint64_t u_quad_t;
+
+#endif
diff --git a/posix/bits/types/u_intN_t.h b/posix/bits/types/u_intN_t.h
new file mode 100644
index 0000000..6257674
--- /dev/null
+++ b/posix/bits/types/u_intN_t.h
@@ -0,0 +1,17 @@
+#ifndef __u_intN_t_defined
+#define __u_intN_t_defined 1
+
+#include <bits/types.h>
+
+/* These size-specific names are used by some of the inet code.
+ They were defined by ISO C without the first `_'. */
+typedef __uint8_t u_int8_t;
+typedef __uint16_t u_int16_t;
+typedef __uint32_t u_int32_t;
+typedef __uint64_t u_int64_t;
+
+/* Some code from BIND tests this macro to see if the types above are
+ defined. */
+#define __BIT_TYPES_DEFINED__ 1
+
+#endif
diff --git a/posix/bits/types/uid_t.h b/posix/bits/types/uid_t.h
new file mode 100644
index 0000000..371cb05
--- /dev/null
+++ b/posix/bits/types/uid_t.h
@@ -0,0 +1,9 @@
+#ifndef __uid_t_defined
+#define __uid_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for user IDs (POSIX). */
+typedef __uid_t uid_t;
+
+#endif
diff --git a/posix/bits/types/uint.h b/posix/bits/types/uint.h
new file mode 100644
index 0000000..69829c6
--- /dev/null
+++ b/posix/bits/types/uint.h
@@ -0,0 +1,10 @@
+#ifndef __uint_defined
+#define __uint_defined 1
+
+/* Obsolete shorthand names for unsigned types, used by old BSD
+ networking code and Sun RPC. */
+typedef unsigned short int ushort;
+typedef unsigned int uint;
+typedef unsigned long int ulong;
+
+#endif
diff --git a/posix/bits/types/useconds_t.h b/posix/bits/types/useconds_t.h
new file mode 100644
index 0000000..a363558
--- /dev/null
+++ b/posix/bits/types/useconds_t.h
@@ -0,0 +1,9 @@
+#ifndef __useconds_t_defined
+#define __useconds_t_defined 1
+
+#include <bits/types.h>
+
+/* Type for time in microseconds (unsigned) (XSI). */
+typedef __useconds_t useconds_t;
+
+#endif
diff --git a/posix/sched.h b/posix/sched.h
index 90ef6fc..56c1470 100644
--- a/posix/sched.h
+++ b/posix/sched.h
@@ -33,11 +33,7 @@
#ifndef __USE_XOPEN2K
# include <time.h>
#endif
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
+#include <bits/types/pid_t.h>
/* Get system specific constant and data structure definitions. */
#include <bits/sched.h>
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 2d8cfd1..8f6d328 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -28,120 +28,51 @@ __BEGIN_DECLS
#include <bits/types.h>
-#ifdef __USE_MISC
-# ifndef __u_char_defined
-typedef unsigned char u_char;
-typedef unsigned short int u_short;
-typedef unsigned int u_int;
-typedef unsigned long int u_long;
-typedef __int64_t quad_t;
-typedef __uint64_t u_quad_t;
-typedef __fsid_t fsid_t;
-# define __u_char_defined
-# endif
-typedef __loff_t loff_t;
-#endif
-
-#ifndef __ino_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __ino_t ino_t;
-# else
-typedef __ino64_t ino_t;
-# endif
-# define __ino_t_defined
-#endif
-#if defined __USE_LARGEFILE64 && !defined __ino64_t_defined
-typedef __ino64_t ino64_t;
-# define __ino64_t_defined
-#endif
-
-#ifndef __dev_t_defined
-typedef __dev_t dev_t;
-# define __dev_t_defined
-#endif
-
-#ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-#endif
-
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
-
-#ifndef __nlink_t_defined
-typedef __nlink_t nlink_t;
-# define __nlink_t_defined
-#endif
-
-#ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-#endif
-
-#ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-#endif
-#if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
-#endif
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
-
-#if (defined __USE_XOPEN || defined __USE_XOPEN2K8) \
- && !defined __id_t_defined
-typedef __id_t id_t;
-# define __id_t_defined
-#endif
+#define __need_size_t
+#include <stddef.h>
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
+#include <bits/types/blkcnt_t.h>
+#include <bits/types/clockid_t.h>
+#include <bits/types/dev_t.h>
+#include <bits/types/fsblkcnt_t.h>
+#include <bits/types/fsfilcnt_t.h>
+#include <bits/types/gid_t.h>
+#include <bits/types/ino_t.h>
+#include <bits/types/mode_t.h>
+#include <bits/types/nlink_t.h>
+#include <bits/types/off_t.h>
+#include <bits/types/pid_t.h>
+#include <bits/types/ssize_t.h>
+#include <bits/types/time_t.h>
+#include <bits/types/timer_t.h>
+#include <bits/types/uid_t.h>
-#ifdef __USE_MISC
-# ifndef __daddr_t_defined
-typedef __daddr_t daddr_t;
-typedef __caddr_t caddr_t;
-# define __daddr_t_defined
-# endif
+#ifdef __USE_LARGEFILE64
+# include <bits/types/blkcnt64_t.h>
+# include <bits/types/fsblkcnt64_t.h>
+# include <bits/types/fsfilcnt64_t.h>
+# include <bits/types/ino64_t.h>
+# include <bits/types/off64_t.h>
#endif
-#if (defined __USE_MISC || defined __USE_XOPEN) && !defined __key_t_defined
-typedef __key_t key_t;
-# define __key_t_defined
+#ifdef __USE_XOPEN
+# include <bits/types/useconds_t.h>
+# include <bits/types/suseconds_t.h>
#endif
#if defined __USE_XOPEN || defined __USE_XOPEN2K8
# include <bits/types/clock_t.h>
+# include <bits/types/id_t.h>
+# include <bits/types/key_t.h>
#endif
-#include <bits/types/clockid_t.h>
-#include <bits/types/time_t.h>
-#include <bits/types/timer_t.h>
-#ifdef __USE_XOPEN
-# ifndef __useconds_t_defined
-typedef __useconds_t useconds_t;
-# define __useconds_t_defined
-# endif
-# ifndef __suseconds_t_defined
-typedef __suseconds_t suseconds_t;
-# define __suseconds_t_defined
-# endif
+#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
+#include <bits/types/blksize_t.h>
#endif
-#define __need_size_t
-#include <stddef.h>
+#if defined __USE_POSIX199506 || defined __USE_UNIX98
+# include <bits/pthreadtypes.h>
+#endif
/* POSIX does not require intN_t to be defined in this header, so
technically this ought to be under __USE_MISC, but it doesn't
@@ -150,24 +81,17 @@ typedef __suseconds_t suseconds_t;
#include <bits/stdint-intn.h>
#ifdef __USE_MISC
-/* Old compatibility names for C types. */
-typedef unsigned long int ulong;
-typedef unsigned short int ushort;
-typedef unsigned int uint;
-
-/* These size-specific names are used by some of the inet code.
- They were defined by ISO C without the first `_'. */
-typedef __uint8_t u_int8_t;
-typedef __uint16_t u_int16_t;
-typedef __uint32_t u_int32_t;
-typedef __uint64_t u_int64_t;
-
-/* Type of a general-purpose integer register (BSD). */
-typedef __register_t register_t;
-
-/* Some code from BIND tests this macro to see if the types above are
- defined. */
-#define __BIT_TYPES_DEFINED__ 1
+/* Additional typedefs from BSD, mostly obsolete. */
+# include <bits/types/caddr_t.h>
+# include <bits/types/daddr_t.h>
+# include <bits/types/fsid_t.h>
+# include <bits/types/loff_t.h>
+# include <bits/types/register_t.h>
+
+/* Shorthand unsigned types, mostly superseded by stdint.h. */
+# include <bits/types/uint.h>
+# include <bits/types/u_int.h>
+# include <bits/types/u_intN_t.h>
/* In BSD <sys/types.h> is expected to define BYTE_ORDER. */
# include <endian.h>
@@ -176,54 +100,6 @@ typedef __register_t register_t;
# include <sys/select.h>
#endif /* Use misc. */
-
-#if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) \
- && !defined __blksize_t_defined
-typedef __blksize_t blksize_t;
-# define __blksize_t_defined
-#endif
-
-/* Types from the Large File Support interface. */
-#ifndef __USE_FILE_OFFSET64
-# ifndef __blkcnt_t_defined
-typedef __blkcnt_t blkcnt_t; /* Type to count number of disk blocks. */
-# define __blkcnt_t_defined
-# endif
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#else
-# ifndef __blkcnt_t_defined
-typedef __blkcnt64_t blkcnt_t; /* Type to count number of disk blocks. */
-# define __blkcnt_t_defined
-# endif
-# ifndef __fsblkcnt_t_defined
-typedef __fsblkcnt64_t fsblkcnt_t; /* Type to count file system blocks. */
-# define __fsblkcnt_t_defined
-# endif
-# ifndef __fsfilcnt_t_defined
-typedef __fsfilcnt64_t fsfilcnt_t; /* Type to count file system inodes. */
-# define __fsfilcnt_t_defined
-# endif
-#endif
-
-#ifdef __USE_LARGEFILE64
-typedef __blkcnt64_t blkcnt64_t; /* Type to count number of disk blocks. */
-typedef __fsblkcnt64_t fsblkcnt64_t; /* Type to count file system blocks. */
-typedef __fsfilcnt64_t fsfilcnt64_t; /* Type to count file system inodes. */
-#endif
-
-
-/* Now add the thread types. */
-#if defined __USE_POSIX199506 || defined __USE_UNIX98
-# include <bits/pthreadtypes.h>
-#endif
-
__END_DECLS
#endif /* sys/types.h */
diff --git a/posix/sys/wait.h b/posix/sys/wait.h
index 9bd4399..691be27 100644
--- a/posix/sys/wait.h
+++ b/posix/sys/wait.h
@@ -27,10 +27,7 @@
__BEGIN_DECLS
#include <bits/types.h>
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
+#include <bits/types/pid_t.h>
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
# include <signal.h>
@@ -111,11 +108,7 @@ extern __pid_t wait (int *__stat_loc);
extern __pid_t waitpid (__pid_t __pid, int *__stat_loc, int __options);
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-# ifndef __id_t_defined
-typedef __id_t id_t;
-# define __id_t_defined
-# endif
-
+# include <bits/types/id_t.h>
# include <bits/types/siginfo_t.h>
/* Wait for a childing matching IDTYPE and ID to change the status and
diff --git a/posix/unistd.h b/posix/unistd.h
index 55a989f..407f2fe 100644
--- a/posix/unistd.h
+++ b/posix/unistd.h
@@ -215,11 +215,7 @@ __BEGIN_DECLS
/* All functions that are not declared anywhere else. */
#include <bits/types.h>
-
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
+#include <bits/types/ssize_t.h>
#define __need_size_t
#define __need_NULL
@@ -228,52 +224,22 @@ typedef __ssize_t ssize_t;
#if defined __USE_XOPEN || defined __USE_XOPEN2K
/* The Single Unix specification says that some more types are
available here. */
-# ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-# endif
-
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
-
-# ifndef __off_t_defined
-# ifndef __USE_FILE_OFFSET64
-typedef __off_t off_t;
-# else
-typedef __off64_t off_t;
-# endif
-# define __off_t_defined
-# endif
-# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
-typedef __off64_t off64_t;
-# define __off64_t_defined
-# endif
-
-# ifndef __useconds_t_defined
-typedef __useconds_t useconds_t;
-# define __useconds_t_defined
-# endif
-
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
+# include <bits/types/gid_t.h>
+# include <bits/types/uid_t.h>
+# include <bits/types/off_t.h>
+# ifdef __USE_LARGEFILE64
+# include <bits/types/off64_t.h>
# endif
+# include <bits/types/useconds_t.h>
+# include <bits/types/pid_t.h>
#endif /* X/Open */
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
-# ifndef __intptr_t_defined
-typedef __intptr_t intptr_t;
-# define __intptr_t_defined
-# endif
+# include <bits/types/intptr_t.h>
#endif
#if defined __USE_MISC || defined __USE_XOPEN
-# ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-# endif
+# include <bits/types/socklen_t.h>
#endif
/* Values for the second argument to access.
diff --git a/pwd/pwd.h b/pwd/pwd.h
index 1002ed3..ccb3bc0 100644
--- a/pwd/pwd.h
+++ b/pwd/pwd.h
@@ -34,15 +34,8 @@ __BEGIN_DECLS
#if defined __USE_XOPEN || defined __USE_XOPEN2K
/* The Single Unix specification says that some more types are
available here. */
-# ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-# endif
-
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
+# include <bits/types/gid_t.h>
+# include <bits/types/uid_t.h>
#endif
/* A record in the user database. */
diff --git a/resource/sys/resource.h b/resource/sys/resource.h
index 928646b..3ed33c4 100644
--- a/resource/sys/resource.h
+++ b/resource/sys/resource.h
@@ -22,11 +22,7 @@
/* Get the system-dependent definitions of structures and bit values. */
#include <bits/resource.h>
-
-#ifndef __id_t_defined
-typedef __id_t id_t;
-# define __id_t_defined
-#endif
+#include <bits/types/id_t.h>
__BEGIN_DECLS
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 518de75..49338c0 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -28,6 +28,7 @@
import argparse
import collections
+import os.path
import re
import sys
@@ -264,15 +265,40 @@ OBSOLETE_TYPE_RE_ = re.compile(r"""\A
| _(?: char | short | int(?:[0-9]+_t)? | long | quad_t )))
\Z""", re.VERBOSE)
+# The headers that declare them:
+OBSOLETE_TYPE_HDR_RE_ = re.compile(r"""\A
+ [<"] bits/types/
+ (?: [cd]addr_t
+ | loff_t
+ | register_t
+ | uint
+ | u_int
+ | u_intN_t ) \.h [">]
+\Z""", re.VERBOSE)
+
class ObsoleteNotAllowed(ConstructChecker):
- """Don't allow any use of the obsolete typedefs."""
+ """Don't allow any use of the obsolete typedefs,
+ or the headers that declare them."""
def examine(self, tok):
- if OBSOLETE_TYPE_RE_.match(tok.text):
+ if ((tok.kind == "IDENT"
+ and OBSOLETE_TYPE_RE_.match(tok.text))
+ or (tok.kind == "HEADER_NAME"
+ and OBSOLETE_TYPE_HDR_RE_.match(tok.text))):
+ self.reporter.error(tok, "use of {!r}")
+
+class ObsoleteIndirectDefinitionsAllowed(ConstructChecker):
+ """Don't allow any use of the obsolete typedefs,
+ but do allow inclusion of the headers that declare them."""
+ def examine(self, tok):
+ if (tok.kind == "IDENT"
+ and OBSOLETE_TYPE_RE_.match(tok.text)):
self.reporter.error(tok, "use of {!r}")
class ObsoletePrivateDefinitionsAllowed(ConstructChecker):
"""Allow definitions of the private versions of the
obsolete typedefs; that is, 'typedef [anything] __obsolete;'
+ Don't allow inclusion of headers that declare the public
+ versions.
"""
def __init__(self, reporter):
super().__init__(reporter)
@@ -300,10 +326,14 @@ class ObsoletePrivateDefinitionsAllowed(ConstructChecker):
self._check_prev()
def _check_prev(self):
- if (self.prev_token is not None
- and self.prev_token.kind == "IDENT"
- and OBSOLETE_TYPE_RE_.match(self.prev_token.text)):
- self.reporter.error(self.prev_token, "use of {!r}")
+ tok = self.prev_token
+ if tok is None:
+ return
+ if ((tok.kind == "IDENT"
+ and OBSOLETE_TYPE_RE_.match(tok.text))
+ or (tok.kind == "HEADER_NAME"
+ and OBSOLETE_TYPE_HDR_RE_.match(tok.text))):
+ self.reporter.error(tok, "use of {!r}")
class ObsoletePublicDefinitionsAllowed(ConstructChecker):
"""Allow definitions of the public versions of the obsolete
@@ -317,6 +347,9 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
typedef unsigned char u_char;
typedef __int64_t quad_t;
typedef __uint64_t u_quad_t;
+
+ Don't allow inclusion of headers that declare public
+ versions of other obsolete typedefs.
"""
def __init__(self, reporter):
super().__init__(reporter)
@@ -337,6 +370,10 @@ class ObsoletePublicDefinitionsAllowed(ConstructChecker):
elif tok.kind == "PUNCTUATOR" and tok.text == ";":
self._finish()
+ elif tok.kind == "HEADER_NAME":
+ if OBSOLETE_TYPE_HDR_RE_.match(tok.text):
+ self.reporter.error(tok, "use of {!r}")
+
elif self.typedef_tokens:
self.typedef_tokens.append(tok)
@@ -406,19 +443,38 @@ def ObsoleteTypedefChecker(reporter, fname):
or fname.startswith("rpcsvc/")
or "/rpc/" in fname
or "/rpcsvc/" in fname):
+ sys.stderr.write("# No typedef checks for {}\n".format(fname))
return NoCheck(reporter)
# bits/types.h is allowed to define the __-versions of the
# obsolete types.
if (fname == "bits/types.h"
or fname.endswith("/bits/types.h")):
+ sys.stderr.write("# Obsolete private defs allowed for {}\n"
+ .format(fname))
return ObsoletePrivateDefinitionsAllowed(reporter)
- # sys/types.h is allowed to use the __-versions of the
- # obsolete types, but only to define the unprefixed versions.
+ # Certain bits/types/ headers are allowed to define the
+ # unprefixed versions of the obsolete types.
+ if ((fname.startswith("bits/types/")
+ or "/bits/types/" in fname)
+ and os.path.basename(fname) in ("caddr_t.h",
+ "daddr_t.h",
+ "loff_t.h",
+ "register_t.h",
+ "uint.h",
+ "u_int.h",
+ "u_intN_t.h")):
+ sys.stderr.write("# Obsolete public defs allowed for {}\n"
+ .format(fname))
+ return ObsoletePublicDefinitionsAllowed(reporter)
+
+ # sys/types.h is allowed to include the above bits/types/ headers.
if (fname == "sys/types.h"
or fname.endswith("/sys/types.h")):
- return ObsoletePublicDefinitionsAllowed(reporter)
+ sys.stderr.write("# Obsolete indirect defs allowed for {}\n"
+ .format(fname))
+ return ObsoleteIndirectDefinitionsAllowed(reporter)
return ObsoleteNotAllowed(reporter)
diff --git a/signal/signal.h b/signal/signal.h
index 4c0de7f..ec70101 100644
--- a/signal/signal.h
+++ b/signal/signal.h
@@ -36,16 +36,8 @@ __BEGIN_DECLS
#endif
#if defined __USE_XOPEN || defined __USE_XOPEN2K
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
-#ifdef __USE_XOPEN
-# endif
-# ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-# endif
+# include <bits/types/pid_t.h>
+# include <bits/types/uid_t.h>
#endif /* Unix98 */
#ifdef __USE_POSIX199309
diff --git a/stdlib/monetary.h b/stdlib/monetary.h
index 1cecd05..1f3347a 100644
--- a/stdlib/monetary.h
+++ b/stdlib/monetary.h
@@ -25,12 +25,7 @@
#define __need_size_t
#include <stddef.h>
#include <bits/types.h>
-
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
-
+#include <bits/types/ssize_t.h>
__BEGIN_DECLS
diff --git a/stdlib/stdint.h b/stdlib/stdint.h
index 8645d91..aca50d1 100644
--- a/stdlib/stdint.h
+++ b/stdlib/stdint.h
@@ -82,10 +82,7 @@ typedef unsigned long long int uint_fast64_t;
/* Types for `void *' pointers. */
-# ifndef __intptr_t_defined
-typedef __intptr_t intptr_t;
-# define __intptr_t_defined
-# endif
+#include <bits/types/intptr_t.h>
typedef __uintptr_t uintptr_t;
/* Largest integral types. */
diff --git a/sunrpc/rpc/types.h b/sunrpc/rpc/types.h
index 99e5f4f..13ef47f 100644
--- a/sunrpc/rpc/types.h
+++ b/sunrpc/rpc/types.h
@@ -34,6 +34,19 @@
#ifndef _RPC_TYPES_H
#define _RPC_TYPES_H 1
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/param.h>
+#include <netinet/in.h>
+
+#ifndef __BIT_TYPES_DEFINED__
+#include <bits/types/caddr_t.h>
+#include <bits/types/daddr_t.h>
+#include <bits/types/fsid_t.h>
+#include <bits/types/u_int.h>
+#endif
+
typedef int bool_t;
typedef int enum_t;
/* This needs to be changed to uint32_t in the future */
@@ -57,7 +70,6 @@ typedef unsigned long rpcport_t;
# define NULL 0
#endif
-#include <stdlib.h> /* For malloc decl. */
#define mem_alloc(bsize) malloc(bsize)
/*
* XXX: This must not use the second argument, or code in xdr_array.c needs
@@ -65,36 +77,6 @@ typedef unsigned long rpcport_t;
*/
#define mem_free(ptr, bsize) free(ptr)
-#ifndef makedev /* ie, we haven't already included it */
-#include <sys/types.h>
-#endif
-
-#if defined __APPLE_CC__ || defined __FreeBSD__
-# define __u_char_defined
-# define __daddr_t_defined
-#endif
-
-#ifndef __u_char_defined
-typedef unsigned char u_char;
-typedef unsigned short int u_short;
-typedef unsigned int u_int;
-typedef unsigned long int u_long;
-typedef __int64_t quad_t;
-typedef __uint64_t u_quad_t;
-typedef __fsid_t fsid_t;
-# define __u_char_defined
-#endif
-#ifndef __daddr_t_defined
-typedef __daddr_t daddr_t;
-typedef __caddr_t caddr_t;
-# define __daddr_t_defined
-#endif
-
-#include <sys/time.h>
-#include <sys/param.h>
-
-#include <netinet/in.h>
-
#ifndef INADDR_LOOPBACK
#define INADDR_LOOPBACK (u_long)0x7F000001
#endif
diff --git a/sysdeps/gnu/utmpx.h b/sysdeps/gnu/utmpx.h
index 9274102..41c122d 100644
--- a/sysdeps/gnu/utmpx.h
+++ b/sysdeps/gnu/utmpx.h
@@ -22,10 +22,7 @@
#include <sys/time.h>
/* Required according to Unix98. */
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
+#include <bits/types/pid_t.h>
/* Get system dependent values and data structures. */
#include <bits/utmpx.h>
diff --git a/sysdeps/mach/hurd/bits/socket.h b/sysdeps/mach/hurd/bits/socket.h
index f7f3cc4..429e66c 100644
--- a/sysdeps/mach/hurd/bits/socket.h
+++ b/sysdeps/mach/hurd/bits/socket.h
@@ -29,13 +29,7 @@
#include <bits/wordsize.h>
#include <sys/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
-
+#include <bits/types/socklen_t.h>
/* Types of sockets. */
enum __socket_type
diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h
index 99af01d..cf3c03a 100644
--- a/sysdeps/unix/sysv/linux/bits/socket.h
+++ b/sysdeps/unix/sysv/linux/bits/socket.h
@@ -27,12 +27,7 @@
#include <stddef.h>
#include <sys/types.h>
-
-/* Type for length arguments in socket calls. */
-#ifndef __socklen_t_defined
-typedef __socklen_t socklen_t;
-# define __socklen_t_defined
-#endif
+#include <bits/types/socklen_t.h>
/* Get the architecture-dependent definition of enum __socket_type. */
#include <bits/socket_type.h>
diff --git a/sysvipc/sys/ipc.h b/sysvipc/sys/ipc.h
index 516e275..8aa7f38 100644
--- a/sysvipc/sys/ipc.h
+++ b/sysvipc/sys/ipc.h
@@ -23,26 +23,10 @@
/* Get system dependent definition of `struct ipc_perm' and more. */
#include <bits/ipctypes.h>
#include <bits/ipc.h>
-
-#ifndef __uid_t_defined
-typedef __uid_t uid_t;
-# define __uid_t_defined
-#endif
-
-#ifndef __gid_t_defined
-typedef __gid_t gid_t;
-# define __gid_t_defined
-#endif
-
-#ifndef __mode_t_defined
-typedef __mode_t mode_t;
-# define __mode_t_defined
-#endif
-
-#ifndef __key_t_defined
-typedef __key_t key_t;
-# define __key_t_defined
-#endif
+#include <bits/types/uid_t.h>
+#include <bits/types/gid_t.h>
+#include <bits/types/mode_t.h>
+#include <bits/types/key_t.h>
__BEGIN_DECLS
diff --git a/sysvipc/sys/msg.h b/sysvipc/sys/msg.h
index 1ce4672..f2f18f4 100644
--- a/sysvipc/sys/msg.h
+++ b/sysvipc/sys/msg.h
@@ -31,16 +31,8 @@
/* Define types required by the standard. */
#include <bits/types/time_t.h>
-
-#ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-#endif
-
-#ifndef __ssize_t_defined
-typedef __ssize_t ssize_t;
-# define __ssize_t_defined
-#endif
+#include <bits/types/pid_t.h>
+#include <bits/types/ssize_t.h>
/* The following System V style IPC functions implement a message queue
system. The definition is found in XPG2. */
diff --git a/sysvipc/sys/shm.h b/sysvipc/sys/shm.h
index c15f419..bf836a7 100644
--- a/sysvipc/sys/shm.h
+++ b/sysvipc/sys/shm.h
@@ -31,14 +31,9 @@
/* Define types required by the standard. */
#include <bits/types/time_t.h>
-
#ifdef __USE_XOPEN
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-# endif
-#endif /* X/Open */
-
+# include <bits/types/pid_t.h>
+#endif
__BEGIN_DECLS
diff --git a/termios/termios.h b/termios/termios.h
index 2234208..b883dc8 100644
--- a/termios/termios.h
+++ b/termios/termios.h
@@ -23,13 +23,9 @@
#define _TERMIOS_H 1
#include <features.h>
+
#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
-/* We need `pid_t'. */
-# include <bits/types.h>
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-# endif
+# include <bits/types/pid_t.h>
#endif
__BEGIN_DECLS
diff --git a/time/sys/time.h b/time/sys/time.h
index 5dbc7fc..1059d30 100644
--- a/time/sys/time.h
+++ b/time/sys/time.h
@@ -23,11 +23,7 @@
#include <bits/types.h>
#include <bits/types/time_t.h>
#include <bits/types/struct_timeval.h>
-
-#ifndef __suseconds_t_defined
-typedef __suseconds_t suseconds_t;
-# define __suseconds_t_defined
-#endif
+#include <bits/types/suseconds_t.h>
#include <sys/select.h>
diff --git a/time/time.h b/time/time.h
index cba6d15..232531c 100644
--- a/time/time.h
+++ b/time/time.h
@@ -50,10 +50,7 @@ struct sigevent;
#endif
#ifdef __USE_XOPEN2K
-# ifndef __pid_t_defined
-typedef __pid_t pid_t;
-# define __pid_t_defined
-# endif
+# include <bits/types/pid_t.h>
#endif
#ifdef __USE_XOPEN2K8
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-01-08 19:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-26 16:36 [glibc/zack/no-nested-includes] Create bits/types headers for most remaining __T_defined macros Zack Weinberg
2019-06-18 15:33 Zack Weinberg
2019-06-26 15:48 Zack Weinberg
2020-01-08 19:19 Zack Weinberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).