diff options
author | Zack Weinberg <zackw@panix.com> | 2019-03-09 20:54:02 -0500 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2020-01-08 12:56:32 -0500 |
commit | d5ebebf969165c51e6a9fcff3a21b6591269eaea (patch) | |
tree | 2655d6b5d54a8315a1ca50819d4a86e05ceeaa36 | |
parent | 23432307d4e17872f5573df4413f5b1efa0cab6d (diff) | |
download | glibc-d5ebebf969165c51e6a9fcff3a21b6591269eaea.tar.gz |
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.
95 files changed, 571 insertions, 540 deletions
diff --git a/bits/socket.h b/bits/socket.h index bebb2e7a57..e72dcfda40 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 92d0925047..0886b6d30d 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 @@ -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 0000000000..c0c2ceded0 --- /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 0000000000..ad8ed2455b --- /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 0000000000..d6ed861acb --- /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 0000000000..9d499e7fff --- /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 0000000000..90050fae5e --- /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 0000000000..f0451c00ad --- /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 0000000000..b5951d5121 --- /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 0000000000..9fc9e4104b --- /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 0000000000..d3152d44a8 --- /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 0000000000..fc092c5673 --- /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 0000000000..9d1e517229 --- /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 0000000000..d8cf23be0e --- /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 0000000000..5eaae0bf76 --- /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 0000000000..42037642c9 --- /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 0000000000..2624ae5034 --- /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 0000000000..455151b5b6 --- /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 0000000000..c4d96aa4e0 --- /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 0000000000..933175cbcb --- /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 0000000000..58602b5d76 --- /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 0000000000..f330ae2d9e --- /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 0000000000..002d92055b --- /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 0000000000..1f18d157b7 --- /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 0000000000..6de6affc13 --- /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 0000000000..68286206d1 --- /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 0000000000..229f676c50 --- /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 0000000000..374e4386c7 --- /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 0000000000..85f0dbe6f0 --- /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 0000000000..2b17d5b831 --- /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 0000000000..ffb17bceb1 --- /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 0000000000..1e2b106f52 --- /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 0000000000..a446b7fb06 --- /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 0000000000..71f720bd7c --- /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 651fc69f1e..08837249fa 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 21b60c264d..0ca71e3310 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 ce014d03a5..cbadf67d70 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 568e2649bc..41cb379229 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 5a10a4d3ee..cf99970f90 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 02abf589a0..01cc640704 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 29d011c2d5..c7d1a95e51 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 4507d84bf1..64fad14abd 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 0000000000..d5d81e75be --- /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 0000000000..badcd47ccc --- /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 0000000000..9d6ada4e4d --- /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 0000000000..fc010bd8a6 --- /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 0000000000..59f0b1b85b --- /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 0000000000..0b45f915eb --- /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 0000000000..690d6016aa --- /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 0000000000..2c7e80d41a --- /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 0000000000..56fcbc7930 --- /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 0000000000..18d0f7ebdb --- /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 0000000000..a198d30a07 --- /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 0000000000..52974a1fa3 --- /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 0000000000..1cb3b76ef8 --- /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 0000000000..e61e75a3ef --- /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 0000000000..808821f2c8 --- /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 0000000000..47948f9161 --- /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 0000000000..424d250268 --- /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 0000000000..ecb9989681 --- /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 0000000000..3aaa70dc70 --- /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 0000000000..2f9125b488 --- /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 0000000000..f00bd82f48 --- /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 0000000000..9ef5395e99 --- /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 0000000000..249e070953 --- /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 0000000000..099b472f9e --- /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 0000000000..836963058e --- /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 0000000000..41e1fd7ea7 --- /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 0000000000..62ded6fd84 --- /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 0000000000..4c9235f3fc --- /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 0000000000..625767412f --- /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 0000000000..371cb055c8 --- /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 0000000000..69829c6f16 --- /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 0000000000..a363558b2d --- /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 60c9c3c710..bb7e727da0 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 f7452aeef4..ba8e72a215 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 a42e16c1b0..d4646ac89f 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 0dd4200ad6..e5958e3d36 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. @@ -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 4edafb50d5..5355da84bf 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 ae740993ef..e458e2b8b3 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 40825e95ec..f7f50c82d4 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 dfb6ed5c0c..8f268a0060 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 391e3d2500..94d6e71a82 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 99e5f4f151..13ef47f3c9 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 f50a0dbeb9..b1a82a46cf 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 ff898aa188..06a731184b 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 50f89db2ac..f275b33499 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 0c7f3567db..ca2b989074 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 c70cfa582c..b110e16eff 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 6c58742c4f..c1cc2951c4 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 41cd79bfd7..0af77e397c 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 21fa9ed451..3769f85605 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 015bc1c7f3..c12d5e2fb3 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 |