Compare commits

...
Author SHA1 Message Date
Zack Weinberg 536eef52c5 Rename sys/ucontext.h to bits/ucontext.h.
sys/ucontext.h is effectively a bits header.  Its contents are
extremely system-specific, and it’s strongly associated with a
specific public header (ucontext.h) that provides a superset of its
definitions, but there are other public headers that also require some
of its definitions.  This patch therefore moves it into the bits/
namespace and adjusts all the headers that refer to it.  In case there
are external users, a stub is added that includes ucontext.h.

Most of the fallout changes are trivial, but aarch64, ia64 and riscv
need a little more work.  aarch64 sys/ucontext.h (now bits/ucontext.h)
was including sys/procfs.h for the definition of elf_greg_t etc;
the simplest fix is to have it include bits/procfs.h instead (and then
that needs to include sys/user.h for user_regs_struct).  This is not
ideal but fixing it properly would require disentangling all of the
debugger interface headers which is more than I’m up for at the moment.

ia64 bits/ptrace.h and bits/procfs.h were both including
bits/sigcontext.h, which is only licensed to be included from
signal.h.  (I’m not sure how this ever worked, or why it broke with
this patch and not some previous one.)  This is fixed by creating
another single-type header, bits/types/__ia64_fpreg.h, which provides
the only thing they need from bits/sigcontext.h.

s/u/s/l/riscv/makecontext.c was defining makecontext with a function
head that didn’t agree with its official prototype (in ucontext.h);
formerly that file did not include ucontext.h, only sys/ucontext.h,
so we were getting away with it, but it’s still wrong.  Making the
function head match the prototype actually simplifies the code.

	* sysdeps/generic/sys/ucontext.h: Move to top level bits/ucontext.h.
	Adjust multiple inclusion guard.
	* sysdeps/arm/sys/ucontext.h: Move to sysdeps/arm/bits/ucontext.h.
	Adjust multiple inclusion guard.
	* sysdeps/i386/sys/ucontext.h: Similarly.
	* sysdeps/m68k/sys/ucontext.h: Similarly.
	* sysdeps/mips/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/alpha/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/arm/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/csky/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/hppa/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/ia64/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/m68k/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/microblaze/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/mips/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/nios2/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/riscv/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/s390/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/sh/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/sparc/sys/ucontext.h: Similarly.
	* sysdeps/unix/sysv/linux/x86/sys/ucontext.h: Similarly.
	* stdlib/Makefile: Install bits/ucontext.h.

	* stdlib/sys/ucontext.h: New backward compatibility stub header,
	includes ucontext.h.
	* include/sys/ucontext.h: New wrapper.

	* sysdeps/unix/sysv/linux/aarch64/bits/procfs.h: Allow inclusion
	by bits/ucontext.h as well as sys/procfs.h.  Include sys/user.h.
	* sysdeps/unix/sysv/linux/aarch64/bits/ucontext.h: Include
	bits/procfs.h instead of sys/procfs.h.

	* sysdeps/unix/sysv/linux/ia64/bits/types/__ia64_fpreg.h:
	New file, contents factored out of ia64/bits/sigcontext.h and
	ia64/bits/ucontext.h.
	* sysdeps/unix/sysv/linux/ia64/Makefile:
	Install bits/types/__ia64_fpreg.h.  Merge subdir=misc blocks.
	* sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h
	* sysdeps/unix/sysv/linux/ia64/bits/ucontext.h:
	Include bits/types/__ia64_fpreg.h for struct ia64_fpreg.

	* sysdeps/unix/sysv/linux/ia64/bits/procfs.h:
	Include bits/types/__ia64_fpreg.h for struct ia64_fpreg.
	Don’t include bits/sigcontext.h or bits/ucontext.h.
	* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h:
	Don’t include bits/sigcontext.h.

	* sysdeps/unix/sysv/linux/riscv/makecontext.c: Include
	ucontext.h, not sys/ucontext.h. Correct function head to match
	prototype in ucontext.h.  Use va_arg to retrieve all arguments
	past argc.

	* sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c:
	Sort list of includes.

	* signal/signal.h, stdlib/ucontext.h
	* sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h
	* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h
	* sysdeps/unix/sysv/linux/riscv/bits/procfs.h
	* sysdeps/unix/sysv/linux/s390/bits/procfs.h:
	Include bits/ucontext.h, not sys/ucontext.h.

	* sysdeps/unix/sysv/linux/aarch64/sigcontextinfo.h
	* sysdeps/unix/sysv/linux/arm/sigcontextinfo.h
	* sysdeps/unix/sysv/linux/nios2/sigcontextinfo.h
	* sysdeps/unix/sysv/linux/riscv/sigcontextinfo.h:
	Include signal.h, not sys/ucontext.h.

	* sysdeps/unix/sysv/linux/arm/register-dump.h
	* sysdeps/unix/sysv/linux/csky/register-dump.h:
	Include ucontext.h, not sys/ucontext.h.

	* sysdeps/unix/sysv/linux/aarch64/ucontext_i.sym
	* sysdeps/unix/sysv/linux/alpha/ucontext-offsets.sym
	* sysdeps/unix/sysv/linux/arm/ucontext_i.sym
	* sysdeps/unix/sysv/linux/csky/abiv2/ucontext_i.sym
	* sysdeps/unix/sysv/linux/hppa/ucontext_i.sym
	* sysdeps/unix/sysv/linux/i386/ucontext_i.sym
	* sysdeps/unix/sysv/linux/ia64/sigcontext-offsets.sym
	* sysdeps/unix/sysv/linux/m68k/m680x0/ucontext_i.sym
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/ucontext_i.sym
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/ucontext_i.sym
	* sysdeps/unix/sysv/linux/mips/ucontext_i.sym
	* sysdeps/unix/sysv/linux/nios2/ucontext_i.sym
	* sysdeps/unix/sysv/linux/riscv/ucontext_i.sym
	* sysdeps/unix/sysv/linux/s390/ucontext_i.sym
	* sysdeps/unix/sysv/linux/sh/sh3/ucontext_i.sym
	* sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.sym
	* sysdeps/unix/sysv/linux/sparc/sparc32/ucontext_i.sym
	* sysdeps/unix/sysv/linux/x86_64/ucontext_i.sym:
	Include stddef.h and signal.h; don’t include any other headers.

	* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES)
	(SYSDEP_ALLOWED_INCLUDES): Update.
2020-01-08 14:17:46 -05:00
Zack Weinberg 9e32bbc2da Minimize inclusion of netinet/in.h from public headers.
As with sys/socket.h and struct sockaddr, most of the files including
netinet/in.h just want struct sockaddr_in or a related type, so
introduce bits/types headers for these.  POSIX specifically allows
arpa/inet.h to include netinet/in.h and I think it makes sense to
preserve that.  The definition of struct sockaddr_in had a dependence
on the definition of struct sockaddr; to avoid that, bits/sockaddr.h
grows a new macro, __SOCKADDR_DATA_SIZE, which is the declared size of
struct sockaddr.sa_data.

On Linux, some kernel headers (notably linux/in.h and linux/in6.h)
attempt to cooperate with a C library’s headers in defining types such
as struct sockaddr_in.  There is a set of macros whose names begin
with __UAPI_DEF_ that indicate that a type has already been defined.
This mechanism doesn’t actually work with the kernel headers as they
are in 5.0, as far as I can tell, but it could be made to work with
straightforward changes, so it makes sense for us to support it to the
extent we can.  To do this sensibly I need to introduce a new bits
header called bits/uapi-compat.h, with a trivial definition for
non-Linux.  This replaces the existing __USE_KERNEL_IPV6_DEFS macro.

	* bits/sockaddr.h (__SOCKADDR_DATA_SIZE): New macro.
	* sysdeps/unix/bsd/bits/sockaddr.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/bits/sockaddr.h: Likewise.
	* socket/bits/types/struct_sockaddr.h: Use __SOCKADDR_DATA_SIZE as
	array length of sa_data.

	* bits/in.h: Add multiple inclusion guard.
	(__USE_KERNEL_IPV6_DEFS): Don’t define.
	* sysdeps/unix/sysv/linux/bits/in.h: Similarly.
	(IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP): Define when not
	already defined, not conditional on __USE_KERNEL_IPV6_DEFS.

	* bits/uapi-compat.h: New file, trivial generic version.
	* sysdeps/unix/sysv/linux/bits/uapi-compat.h: New file,
	Linux-specific version which recognizes kernel header guard macros
	and defines __UAPI_DEF_* macros as appropriate.
	* misc/Makefile: Install bits/uapi-compat.h.

	* include/bits/types/in_addr_t.h, include/bits/types/in_port_t.h
	* include/bits/types/struct_in_addr.h
	* include/bits/types/struct_in6_addr.h
	* include/bits/types/struct_sockaddr_in.h
	* include/bits/types/struct_sockaddr_in6.h:
	New wrapper headers.

	* inet/bits/types/in_addr_t.h, inet/bits/types/in_port_t.h
	* inet/bits/types/struct_in_addr.h
	* inet/bits/types/struct_in6_addr.h
	* inet/bits/types/struct_sockaddr_in.h
	* inet/bits/types/struct_sockaddr_in6.h
	New single-type headers, factored out of inet/netinet/in.h.
	Add __UAPI_DEF_* conditionals where appropriate, and verify that
	all conditionalized definitions agree with the relevant
	OS-supplied header.  Use __SOCKADDR_DATA_SIZE to set size of sin_zero.
	* inet/Makefile: Install the new single-type headers.

	* inet/netinet/in.h: Include bits/uapi-compat.h.
	Define in_addr_t, in_port_t, struct in_addr, struct in6_addr,
	struct sockaddr_in, and struct sockaddr_in6 by including the
	above single-type headers, not directly.  Replace all
	__USE_KERNEL_IPV6_DEFS conditionals with appropriate __UAPI_DEF_*
	conditionals.  Add appropriate __UAPI_DEF_* conditionals around
	the definitions of the IPPROTO_* constants, the IN_CLASS
	macros, and struct ip_mreq.  Import IN_LOOPBACK macro from
	Linux 5.0 linux/in.h and verify all other conditionalized
	definitions agree with the relevant linux/ header.
	Define IPPORT_RESERVED only if not already defined, and make it a
	macro so we can tell.

	* inet/netinet/igmp.h, inet/netinet/ip.h, inet/netinet/ip_icmp.h:
	Include bits/types/struct_in_addr.h, not netinet/in.h.

	* inet/netinet/ip_icmp.h: Hoist all #includes to the top of the file.

	* inet/netinet/icmp6.h, inet/netinet/ip6.h
	* sysdeps/unix/sysv/linux/net/route.h:
	Include bits/types/struct_in6_addr.h, not netinet/in.h.

	* sysdeps/mach/hurd/net/route.h: Include bits/types.h and
	bits/types/struct_in6_addr.h, not netinet/in.h.  Use __uint16_t
	and __uint32_t instead of uint16_t and uint32_t.

	* resolv/bits/types/res_state.h: Include bits/types/struct_in_addr.h
	and bits/types/struct_sockaddr_in.h.  Forward declare struct
	sockaddr_in6.  Don’t include netinet/in.h.

	* resolv/netdb.h: Don’t include netinet/in.h.  Use socklen_t
	instead of __socklen_t.  Define IPPORT_RESERVED only if not
	already defined, with definition matching netinet/in.h.
	When __USE_MISC, include bits/sockaddr.h.
	* resolv/resolv.h: Don’t include netinet/in.h.

	* inet/tst-getni1.c, inet/tst-getni2.c
	* nss/tst-nss-files-hosts-erange.c, nss/tst-nss-files-hosts-getent.c
	* nss/tst-nss-files-hosts-multi.c, posix/tst-getaddrinfo2.c
	* resolv/tst-bug18665-tcp.c, resolv/tst-resolv-ai_idn-common.c
	* resolv/tst-resolv-canonname.c, resolv/tst-resolv-edns.c
	* resolv/tst-resolv-network.c, resolv/tst-resolv-nondecimal.c
	* resolv/tst-resolv-search.c, support/tst-support-namespace.c:
	Include netinet/in.h.
	* support/resolv_test.h: Include stdint.h, not sys/cdefs.h.

	* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
	Update.
2020-01-08 14:15:42 -05:00
Zack Weinberg 94ab7b6b7f Don’t include sys/socket.h from public headers.
No standard public header is required to include sys/socket.h,
although some are allowed to.  Several public headers need the
definitions of socklen_t, struct sockaddr, and/or struct
sockaddr_storage, but nothing else from sys/socket.h.  We already have
a single-type header for socklen_t, so this patch adds single-type
headers for struct sockaddr and struct sockaddr_storage.

The definition of struct sockaddr_storage is subtly different on Linux
than on the Hurd; in order to not need two copies of
bits/types/struct_sockaddr_storage.h, bits/sockaddr.h is now
responsible for defining __ss_aligntype if ‘unsigned long int’ is not
the correct definition.

I also added a single-type header for struct linger, even though only
sys/socket.h is expected to define that, just because all three copies
of bits/socket.h were defining it exactly the same way.  There would
also be a case for defining it directly in sys/socket.h but this
seemed tidier.

I did *not* create single-type headers for struct msghdr and struct
cmsghdr, because those and their helper macros are not consistent
among the three copies of bits/socket.h, and, again, only sys/socket.h
is expected to define them.

The large number of .c files that add an `#include <sys/socket.h>`
might make this look like it’s not worth doing.  However, after this
change, only half of the files in the glibc source tree that include
netinet/in.h also need to include sys/socket.h, and only a third of
the files that include netdb.h need to include sys/socket.h.  Before,
all of the files in both groups were getting sys/socket.h.  That seems
like enough justification to me.

While I was at it I noticed that sys/socketvar.h is yet another
backward compatibility header that does nothing but include some other
header (sys/socket.h, in this case) and also doesn’t need to be
system-dependent.

	* socket/bits/types/struct_linger.h
	* socket/bits/types/struct_sockaddr.h
	* socket/bits/types/struct_sockaddr_storage.h:
	New single-type headers, factored out of the various bits/socket.h
	headers.

	* include/bits/types/struct_linger.h
	* include/bits/types/struct_sockaddr.h
	* include/bits/types/struct_sockaddr_storage.h:
	New wrappers.

	* socket/Makefile (headers): Add bits/types/struct_linger.h,
	bits/types/struct_sockaddr.h, and bits/types/struct_sockaddr_storage.h.
	Alphabetize the list.

	* bits/socket.h, sysdeps/mach/hurd/bits/socket.h
	* sysdeps/unix/sysv/linux/bits/socket.h:
	Don’t define struct sockaddr, struct sockaddr_storage,
	__ss_aligntype, or struct linger here.  Minimize inclusions.
	* sysdeps/unix/bsd/bits/sockaddr.h: Define __ss_aligntype here.

	* socket/sys/socket.h: Include bits/types/struct_linger.h,
	bits/sockaddr.h, bits/types/struct_sockaddr.h, and
	bits/types/struct_sockaddr_storage.h.  Move inclusion of
	bits/socket.h below forward declaration of struct timespec,
	and update commentary.

	* inet/ifaddrs.h, socket/net/if.h
	* sysdeps/mach/hurd/net/if_arp.h
	* sysdeps/mach/hurd/net/route.h
	* sysdeps/unix/sysv/linux/errqueue.h
	* sysdeps/unix/sysv/linux/net/if_arp.h
	* sysdeps/unix/sysv/linux/net/route.h:
	Include bits/types/struct_sockaddr.h and possibly also bits/types.h,
	not sys/socket.h or sys/types.h.

	* sysdeps/unix/sysv/linux/errqueue.h:
	* sysdeps/unix/sysv/linux/net/route.h:
	Use __uint8_t and __uint32_t instead of uint8_t and uint32_t.

	* inet/arpa/inet.h: Include bits/types/size_t.h.
	* inet/netinet/in.h: Include bits/sockaddr.h,
	bits/types/struct_sockaddr.h, and
	bits/types/struct_sockaddr_storage.h,
	not sys/socket.h.  Use __socklen_t instead of socklen_t.
	* inet/netinet/tcp.h: Include bits/types.h and
	bits/types/struct_sockaddr_storage.h, not sys/socket.h or
	bits/stdint-uintn.h.  Use __uint8_t, __uint16_t, and __uint32_t
	instead of uint8_t, uint16_t and uint32_t.
	* inet/protocols/routed.h: Include features.h and
	bits/types/struct_sockaddr.h, not sys/socket.h.
	* resolv/netdb.h: Include bits/types/socklen_t.h.
	* sysdeps/unix/sysv/linux/netatalk/at.h: Don’t include sys/socket.h.

	* include/ifaddrs.h: Include stddef.h for size_t.
	* include/netdb.h: Use __socklen_t instead of socklen_t.

	* inet/check_pf.c, inet/gethstbynm.c, inet/gethstbynm_r.c
	* inet/getsourcefilter.c, inet/inet6_opt.c, inet/inet6_option.c
        * inet/inet6_rth.c, inet/setsourcefilter.c, inet/test-ifaddrs.c
	* inet/test-inet6_opt.c, inet/tst-inet6_rth.c
	* inet/tst-inet6_scopeid_pton.c, nis/nss_nis/nis-hosts.c
	* nis/nss_nisplus/nisplus-hosts.c, nscd/aicache.c, nscd/cache.c
	* nscd/hstcache.c, nscd/initgrcache.c, nscd/netgroupcache.c
	* nscd/nscd_gethst_r.c, nscd/servicescache.c, nss/digits_dots.c
	* nss/nss_files/files-hosts.c, nss/nss_files/files-network.c
	* nss/tst-nss-files-hosts-erange.c, nss/tst-nss-files-hosts-getent.c
	* nss/tst-nss-files-hosts-multi.c, posix/tst-getaddrinfo3.c
	* resolv/nss_dns/dns-network.c, resolv/resolv_conf.c
	* resolv/tst-bug18665-tcp.c, resolv/tst-bug18665.c
	* resolv/tst-inet_ntop.c, resolv/tst-inet_pton.c
	* resolv/tst-resolv-ai_idn-common.c, resolv/tst-resolv-basic.c
	* resolv/tst-resolv-edns.c, resolv/tst-resolv-network.c
	* resolv/tst-resolv-nondecimal.c, resolv/tst-resolv-search.c
	* resolv/tst-resolv-threads.c, resolv/tst-resolv-trailing.c
	* sunrpc/rpc_gethostbyname.c
	* support/support_format_address_family.c
	* support/support_format_addrinfo.c
	* support/support_format_dns_packet.c
	* support/support_format_hostent.c, support/support_format_netent.c
	* sysdeps/mach/hurd/if_index.c
	* sysdeps/unix/sysv/linux/check_native.c: Include sys/socket.h.

	* resolv/tst-resolv-binary.c: Include sys/types.h.

	* sysdeps/generic/sys/socketvar.h: Move to socket/sys/socketvar.h.
	* include/sys/socketvar.h: New wrapper.

	* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
	Update.
2020-01-08 14:15:42 -05:00
Zack Weinberg 0e8caaf081 Minimize includes of unrelated public headers by networking headers.
Stop including sys/param.h, sys/types.h, stdint.h, inttypes.h,
stdio.h, and string.h from network-related headers.  This is done
separately from earlier patches because the network headers are extra
messy, and are also more likely to contain quirks inherited verbatim
from 4.xBSD than the bulk of our public headers.

Rose and NetROM are based on AX.25 so it makes practical sense for
netrose/rose.h and netrom/netrom.h to continue including netax25/ax25.h.

The only copies of ip_icmp.h and udp.h in the source tree are moved
from sysdeps/gnu to inet (after which there are no longer any netinet/
headers in sysdeps/gnu).

Much as sys/un.h needs to duplicate the prototype for strlen,
netinet/icmp6.h needs to duplicate the prototype for memset.  I am
open to better ideas on that front.

	* resolv/resolv.h: Include bits/types.h, bits/types/FILE.h,
	and bits/types/size_t.h; don’t include sys/param.h, sys/types.h,
	or stdio.h.  Use __uint16_t and __uint32_t instead of uint16_t and
	uint32_t.
	* resolv/arpa/nameser.h: Include features.h, bits/types.h, and
	bits/types/size_t.h; don’t include sys/param.h, sys/types.h, or
	stdint.h.  Use __uint16_t and __uint32_t instead of uint16_t and
	uint32_t.
	* resolv/arpa/nameser_compat.h: Include features.h.

	* sysdeps/mach/hurd/net/ethernet.h: Include bits/types.h;
	don’t include sys/types.h or stdint.h.  Use __uint8_t and
	__uint16_t instead of uint8_t and uint16_t.
	* sysdeps/unix/sysv/linux/net/ethernet.h: Include features.h and
	bits/types.h; don’t include sys/types.h or stdint.h.
	Use __uint8_t and __uint16_t instead of uint8_t and uint16_t.
	* sysdeps/unix/sysv/linux/netinet/if_ether.h:  Include features.h
	and bits/types.h.  Use __uint8_t instead of uint8_t.

	* sysdeps/mach/hurd/net/if_arp.h: Don’t include sys/types.h or
	stdint.h. Use __uint32_t instead of uint32_t.
	* sysdeps/unix/sysv/linux/net/if_arp.h: Include features.h.
	Don’t include sys/types.h or stdint.h. Use __uint32_t instead of
	uint32_t.

	* sysdeps/mach/hurd/net/route.h: Don’t include sys/types.h.
	* sysdeps/unix/sysv/linux/net/route.h: Don’t include sys/types.h.

	* sysdeps/unix/sysv/linux/net/if_ppp.h: Include features.h and
	bits/types.h.  Don’t include sys/types.h or stdint.h.  Use
	__uint8_t and __uint32_t instead of uint8_t and uint32_t.
	* sysdeps/unix/sysv/linux/net/if_shaper.h: Include features.h and
	bits/types.h.  Don’t include sys/types.h or stdint.h.  Use
	__uint16_t and __uint32_t instead of uint16_t and uint32_t.

	* sysdeps/unix/sysv/linux/netatalk/at.h: Include features.h,
	bits/types.h, and sys/ioctl.h.  Don’t include asm/types.h or
	linux/atalk.h.  Copy over all user-appropriate definitions from
	linux/atalk.h with adjustments for glibc context.

	* grp/initgroups.c, nscd/initgrcache.c, nss/nss_db/db-XXX.c
	* resolv/ns_print.c, resolv/tst-ns_name_compress.c
	* resolv/tst-res_hnok.c, support/resolv_test.c:
	Include stdio.h.

	* nscd/initgrcache.c, nscd/netgroupcache.c
	* nss/nss_compat/compat-grp.c, nss/nss_compat/compat-pwd.c
	* nss/nss_compat/compat-spwd.c, resolv/ns_print.c:
	Include sys/param.h for MIN and/or MAX.

	* resolv/tst-resolv-res_init-skeleton.c: Include signal.h.

	* inet/protocols/rwhod.h: Include features.h and bits/types.h.
	Don’t include sys/types.h.  Use __int32_t instead of int32_t.
	* inet/protocols/talkd.h: Include features.h and bits/types.h.
	Don’t include sys/types.h, sys/socket.h, or stdint.h. Use
	__int32_t and __uint32_t instead of int32_t and uint32_t.
	* inet/protocols/timed.h: Include features.h, bits/types.h,
	and bits/types/struct_timeval.h. Don’t include sys/types.h or
	sys/time.h.
	* sysdeps/unix/sysv/linux/netipx/ipx.h: Include features.h and
	bits/types.h.  Don’t include sys/types.h or stdint.h. Use
	__uint16_t and __uint32_t instead of uint16_t and uint32_t.
	* sysdeps/unix/sysv/linux/netrose/rose.h: Include features.h.
	Don’t include sys/socket.h.

	* inet/netinet/icmp6.h: Include features.h, bits/endian.h,
	bits/types.h, and bits/types/size_t.h.  Don’t include inttypes.h,
	string.h, or sys/types.h.  Duplicate prototype of memset here.
	Use __uintN_t instead of uintN_t types.
	* inet/netinet/igmp.h: Include bits/types.h.  Don’t include sys/types.h.
	Use __uintN_t instead of uintN_t types.
	* inet/netinet/ip.h: Include bits/types.h.  Don’t include
	bits/stdint-uintn.h.  Use __uintN_t instead of uintN_t types.
	* inet/netinet/ip6.h: Include features.h, bits/endian.h, and
	bits/types.h.  Don’t include inttypes.h.  Use __uintN_t instead of
	uintN_t types.

	* inet/netinet/ip_icmp.h: Include features.h and bits/types.h.
	Don’t include sys/types.h or stdint.h.  Use __uintN_t instead of
	uintN_t types.
	* inet/netinet/udp.h: Likewise.
	* sysdeps/generic/netinet/if_ether.h: Likewise.
	* sysdeps/unix/sysv/linux/netinet/if_ether.h: Likewise.
	* sysdeps/unix/sysv/linux/netinet/if_fddi.h: Likewise.
	* sysdeps/unix/sysv/linux/netinet/if_tr.h: Likewise.

	* sysdeps/gnu/netinet/ip_icmp.h: Move to inet/netinet/ip_icmp.h.
	* sysdeps/gnu/netinet/udp.h: Move to inet/netinet/udp.h.
	* include/netinet/ip_icmp.h, include/netinet/udp.h: New wrappers.
	* sysdeps/gnu/Makefile: Remove $(subdir)==inet stanza.
	* inet/Makefile (headers): Add netinet/ip_icmp.h and
	netinet/udp.h. Don’t use $(wildcard *.h) for arpa and protocols
	headers.  Sort list.

	* scripts/check-obsolete-constructs.py
	(HEADER_ALLOWED_INCLUDES, SYSDEP_ALLOWED_INCLUDES): Update.
2020-01-08 14:15:41 -05:00
Zack Weinberg b32c5f35b8 Don’t include sys/types.h or stdint.h from most public headers.
Many public headers include sys/types.h and/or stdint.h when they only
need and/or are supposed to define a small number of types from that
header.  This patch changes as many of them as practical to include
only the single-type headers for the types they are actually specified
to define, and use the impl-namespace aliases for any types they need
but are not specified to define.  In most cases, where a header has
historically used uintN_t types, I changed it to use __uintN_t types;
in a few cases I chose to have it continue to define the complete set
of those types (using <bits/stdint-uintn.h>).

After this patch, the public headers that still include sys/types.h are:
stdlib.h and sys/param.h, where removal would risk breaking far too much;
the inclusion of sys/types.h; regex.h, which is taken verbatim from
gnulib and can't include features.h directly (I'm open to better ideas);
sys/bitypes.h, which is an alternative name for sys/types.h; and
the networking headers, which will be dealt with separately.  The headers
that still include stdint.h are: inttypes.h, as required by ISO C;
elf.h and thread_db.h, see discussion of debugger interface headers below;
and, again, the networking headers will be dealt with separately.

While I was at it, I moved headers out of sysdeps where possible: If
we have only a sysdeps/generic/something.h or sysdeps/gnu/something.h,
no other sysdeps variants, it is not really system-dependent and can
be moved to the directory that installs it.  If we have both
sysdeps/generic/ and gnu/something.h, the generic version is never
used (since we support only GNUish systems these days) and can be
deleted, and the gnu-version can be moved to the directory that
installs it.  If the only copy of a bits header is in the
top-level bits directory, it is not system-dependent.

For utmp.h and utmpx.h, I think we might be able to fold their
respective bits headers into the primary headers and make them not
system-dependent at all.  The remaining variation is between
s390*-*-linux* and everything else, and it appears to me that the s390
versions of the bits headers are actually the headers that everyone
should be using.  The only difference is that the s390 headers
unconditionally use 64-bit quantities for lastlog.ll_time,
utmp{,x}.ut_tv, and utmp{,x}.ut_session, whereas the generic headers
use either 64- or 32-bit quantities depending on
__WORDSIZE_TIME64_COMPAT32.  I could be wrong, but I don’t think it
makes sense for programs with 64-bit and 32-bit time_t to have
different ideas of the layout of a structures that are copied directly
to and from a shared file on disk.  But fixing that doesn’t belong in
this patch series.

The conform tests expect utmpx.h to define time_t and suseconds_t.
These are the public names for the types of the fields of struct
timeval, and utmpx.h is required to define struct timeval, so this is
a reasonable expectation even though POSIX doesn't _explicitly_ say
it's also required to define time_t and suseconds_t.  utmp.h is not a
standard header but it makes sense for it to be as consistent with
utmpx.h as possible, especially in our implementation where
/var/log/utmp and /var/log/utmpx have the same format.

I thought I was going to need to change all of the arch-specific
bits/epoll.h headers as well as sys/epoll.h, but it turned out not to
be necessary.  I still took the opportunity to give them all multiple
inclusion guards.

I suspect we do not need as many copies of bits/fcntl.h and bits/sem.h
as we have, but that’s complicated enough that it deserves its own patchset.

The debugger interface headers are a mess and I only have so much
patience for them.  This does the bare minimum required for
thread_db.h, sys/procfs.h, and sys/user.h, which are at least
nominally cross-platform interfaces, to avoid including sys/types.h,
sys/time.h, and/or signal.h.  Exposure of sys/ucontext.h is reduced
but not eliminated.  Cross-architecture consistency should be improved.
It would be desirable to stop including stdint.h from elf.h and
thread_db.h as well, but that would involve touching dozens more
bits headers and I ran out of patience.

Git does not understand “remove file X and then rename file Y over the
top of it” very well, so the diff looks bigger than it should.

This is another partial fix for Hurd-specific bug 23088.  The headers
that are still affected by that bug are aio.h, mqueue.h, regex.h,
signal.h, stdlib.h, and sys/types.h.

	* io/ftw.h: Don't include sys/types.h.
	* misc/sys/uio.h: Don't include sys/types.h.
	Include bits/types.h, bits/types/size_t.h, and bits/types/ssize_t.h.
	* posix/spawn.h: Don't include sys/types.h.
	Include bits/types.h, bits/types/mode_t.h, and bits/types/pid_t.h.
	* rt/aio.h: Don't include sys/types.h.
	Include bits/types.h, bits/pthreadtypes.h,
	bits/types/size_t.h, and bits/types/ssize_t.h.
	* sysdeps/pthread/semaphore.h: Don't include sys/types.h.
	* sysdeps/unix/sysv/linux/bits/uio-ext.h: Use __pid_t, not pid_t.

	* sysdeps/generic/netinet/in_systm.h: Rename to
	inet/netinet/in_systm.h.  Include bits/stdint-uintn.h,
	not sys/types.h or stdint.h.
	* sysdeps/generic/netinet/ip.h: Rename to
	inet/netinet/ip.h.  Include bits/stdint-uintn.h and
	bits/endian.h, not sys/types.h.
	* sysdeps/gnu/netinet/tcp.h: Rename to
	inet/netinet/tcp.h. Include bits/stdint-uintn.h and
	bits/endian.h, not sys/types.h or stdint.h.
	* sydeps/gnu/net/if.h: Rename to socket/net/if.h.
	Don’t include sys/types.h.

	* include/net/if.h: Include socket/net/if.h, rather than
	whatever the next net/if.h on the include path is.
	* include/netinet/in_systm.h, include/netinet/ip.h
	* include/netinet/tcp.h: New trivial wrappers.

	* sysdeps/generic/net/if.h: Delete, never used.
	* sysdeps/generic/netinet/tcp.h: Delete, never used.

	* bits/utmp.h: Delete file.
        * sysdeps/gnu/bits/utmp.h: Move to bits/utmp.h.
        Add multiple include guard.
        Don’t include paths.h, sys/time.h, or sys/types.h.
        Don’t use struct timeval.
        Use __intN_t for consistency with bits/utmpx.h.
        * sysdeps/unix/sysv/linux/s390/bits/utmp.h: Add multiple include guard.
        Don’t include paths.h, sys/time.h, sys/types.h, or bits/wordsize.h.
        Don’t use struct timeval.
        Use __intN_t for consistency with bits/utmpx.h.
        Use __time64_t unconditionally for lastlog.ll_time.
        Use __int64_t unconditionally for utmp.ut_session.
        Adjust indentation and blank lines to match bits/utmp.h.

        * sysdeps/gnu/bits/utmpx.h: Move to bits/utmpx.h.
        Add multiple include guard.
        Don’t include paths.h, sys/time.h, bits/types.h, or bits/wordsize.h.
        Don’t define _PATH_UTMPX or _PATH_WTMPX.
        Don’t use struct timeval.
        Use pid_t for consistency with bits/utmp.h.
        * sysdeps/unix/sysv/linux/s390/bits/utmpx.h: Add multiple include guard.
        Don’t define _PATH_UTMPX or _PATH_WTMPX.
        Don’t include paths.h, sys/time.h, bits/types.h, or bits/wordsize.h.
        Don’t define _PATH_UTMPX or _PATH_WTMPX.
        Don’t use struct timeval.
        Use pid_t for consistency with bits/utmp.h.
        Use __int64_t unconditionally for utmpx.ut_session.

        * login/utmp.h: Don’t include sys/types.h.
        Do include paths.h, bits/types.h, bits/types/pid_t.h,
        bits/types/suseconds_t, bits/types/time_t.h, and
        bits/types/struct_timeval.h.
        Move __BEGIN_DECLS to enclose only prototypes.

        * sysdeps/gnu/utmpx.h: Move to login/utmpx.h.
        Don’t include sys/time.h.  Do include bits/types.h,
        bits/types/suseconds_t, bits/types/time_t.h, and
        bits/types/struct_timeval.h.
        When __USE_GNU, include paths.h and define _PATH_UTMPX and _PATH_WTMPX.

        * login/Makefile (headers): Add utmpx.h and bits/utmpx.h.
        (routines): Add endutxent, getutmp, getutmpx, getutxent,
        getutxid, getutxline, pututxline, setutxent, updwtmpx, and
        utmpxname.  Reorganize.
        * sysdeps/gnu/Makefile: Do not add anything to sysdep_routines
        or sysdep_headers when subdir == login.

	* sysdeps/gnu/sys/mtio.h: Move to misc/sys/mtio.h.
	Don't include sys/types.h.
	* sysdeps/gnu/Makefile: Don't add anything to sysdep_headers
	for the misc directory.
	* misc/Makefile (headers): Add sys/mtio.h.
	* include/sys/mtio.h: New wrapper.

	* elf/link.h, inet/aliases.h, misc/sys/xattr.h:
	Don't include sys/types.h.  Include bits/types/size_t.h.

	* gmon/sys/gmon.h: Don't include sys/types.h.
	* gmon/sys/profil.h: Don't include sys/types.h.
	Include bits/types/size_t.h and bits/types/struct_timeval.h.
	* io/fts.h: Don't include sys/types.h.
	Include bits/types/dev_t.h, bits/types/ino_t.h, bits/types/ino64_t.h,
	and bits/types/nlink_t.h.
	* io/sys/sendfile.h: Don't include sys/types.h.
	Include bits/types.h, bits/types/off_t.h, bits/types/size_t.h,
	and bits/types/ssize_t.h.
	* stdlib/sys/random.h: Don't include sys/types.h.
	Include bits/types/size_t.h and bits/types/ssize_t.h.

	* gmon/tst-sprofil.h: Include sys/time.h.
	* sysdeps/mach/hurd/sendfile.c: Include sys/types.h.

	* sysdeps/unix/sysv/linux/sys/epoll.h: Don’t include stdint.h
	or sys/types.h.  Do include features.h and bits/types.h.
	(union epoll_data, struct epoll_event): Use __uint32_t and
	__uint64_t for field types.

	* sysdeps/unix/sysv/linux/alpha/bits/epoll.h
	* sysdeps/unix/sysv/linux/bits/epoll.h
	* sysdeps/unix/sysv/linux/hppa/bits/epoll.h
	* sysdeps/unix/sysv/linux/mips/bits/epoll.h
	* sysdeps/unix/sysv/linux/sparc/bits/epoll.h
	* sysdeps/unix/sysv/linux/x86/bits/epoll.h:
	Add multiple inclusion guard.

	* sysdeps/unix/sysv/linux/alpha/sys/acct.h: Style fix.
	* sysdeps/unix/sysv/linux/sys/acct.h: Include features.h
	and bits/stdint-uintn.h.  Don't include sys/types.h, stdint.h,
	or bits/types/time_t.h.

	* sysdeps/unix/sysv/linux/sys/fsuid.h
	* sysdeps/unix/sysv/linux/sys/quota.h
	Include bits/types.h, not sys/types.h.

	* sysdeps/nptl/sys/procfs.h: Include features.h and bits/types.h,
	not sys/types.h.
	* sysdeps/nptl/thread_db.h: Don’t include sys/types.h.
	* sysdeps/nptl/proc_service.h: Include bits/types/pid_t.h and
	bits/types/size_t.h.

	* sysdeps/unix/sysv/linux/sys/procfs.h: Include bits/types.h and
	bits/types/struct_timeval.h, not sys/time.h or sys/types.h.

	* sysdeps/unix/sysv/linux/aarch64/bits/procfs.h: Add multiple
	inclusion guard.  Include bits/types.h.  Correct a comment.

	* sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h:
	Add multiple inclusion guard.  Include sys/ucontext.h.

	* sysdeps/unix/sysv/linux/alpha/bits/procfs.h
	* sysdeps/unix/sysv/linux/sparc/bits/procfs.h
	Add multiple inclusion guard.  Don’t include signal.h or sys/ucontext.h.
	* sysdeps/unix/sysv/linux/ia64/bits/procfs.h:
        Add multiple inclusion guard.  Include sys/ucontext.h, not signal.h.
	* sysdeps/unix/sysv/linux/powerpc/bits/procfs.h:
        Add multiple inclusion guard.  Don’t include signal.h or
	sys/ucontext.h.  Include bits/wordsize.h and asm/elf.h.
	Adjust conditional for whether to provide various fallback
	definitions.

	* sysdeps/unix/sysv/linux/arm/bits/procfs.h
	* sysdeps/unix/sysv/linux/csky/bits/procfs.h
	* sysdeps/unix/sysv/linux/hppa/bits/procfs.h
	* sysdeps/unix/sysv/linux/m68k/bits/procfs.h
	* sysdeps/unix/sysv/linux/microblaze/bits/procfs.h
	* sysdeps/unix/sysv/linux/mips/bits/procfs.h
	* sysdeps/unix/sysv/linux/nios2/bits/procfs.h
	* sysdeps/unix/sysv/linux/riscv/bits/procfs.h
	* sysdeps/unix/sysv/linux/s390/bits/procfs.h
	* sysdeps/unix/sysv/linux/sh/bits/procfs.h
	* sysdeps/unix/sysv/linux/x86/bits/procfs.h:
        Add multiple inclusion guard.  Improve commentary.

	* sysdeps/posix/dl-fileid.h (r_file_id): Use __dev_t and __ino64_t
	for field types.

	* nss/nss.h
	* sysdeps/powerpc/sys/platform/ppc.h
	* sysdeps/unix/sysv/linux/sys/eventfd.h
	* sysdeps/unix/sysv/linux/sys/fanotify.h
	* sysdeps/unix/sysv/linux/sys/inotify.h
	* sysdeps/unix/sysv/linux/sys/raw.h
	* sysdeps/unix/sysv/linux/sys/signalfd.h:
	Include bits/types.h, not stdint.h.
	Include features.h where not already doing so.
	Use __(u)intN_t types instead of (u)intN_t types in all
	declarations.

	* sysdeps/unix/sysv/linux/powerpc/bits/powerpc.h:
	Use __uint64_t instead of uint64_t.
	* nss/tst-nss-test4.c: Include stdint.h.

	* bits/fcntl.h: Add multiple include guard.  Hoist inclusion of
	bits/types.h to top of file.
	* sysdeps/mach/hurd/bits/fcntl.h: Add multiple include guard.
	Include bits/types.h, not sys/types.h; remove redundant inclusion
	of bits/types.h in middle of file.

	* bits/sem.h: Add multiple include guard.  Include bits/types.h,
	not sys/types.h.
	* sysdeps/gnu/bits/sem.h: Likewise.
	* sysdeps/unix/sysv/linux/bits/sem.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/ipc.h: Likewise.
	* sysvipc/sys/sem.h: Include bits/types/pid_t.h and
	bits/types/time_t.h.

	* resolv/bits/types/res_state.h: Include bits/types.h, not
	sys/types.h.  Use __uint32_t and __uint16_t, not uint32_t and
	uint16_t.

	* sysdeps/mach/hurd/bits/socket.h: Include bits/types.h, not
	sys/types.h.
	* sysdeps/unix/sysv/linux/bits/socket.h: Likewise.  Use __pid_t,
	__uid_t, and __gid_t, not pid_t, uid_t, and gid_t.
	* socket/sys/socket.h: Include bits/types.h, bits/types/ssize_t.h,
	and bits/types/socklen_t.h.
	* inet/htonl.c, include/htons.c: Include endian.h.
	* include/netinet/ether.h: Include bits/types/size_t.h.

	* scripts/check-obsolete-constructs.py
	(HEADER_ALLOWED_INCLUDES, SYSDEP_ALLOWED_INCLUDES): Update.

	* sysdeps/mach/hurd/i386/Makefile: Update list of xfails for
        bug 23088.
2020-01-08 14:15:36 -05:00
Zack Weinberg 886864a8f2 Don’t include sys/time.h from sys/timex.h.
The interfaces defined in sys/timex.h only need struct timeval, not
any of the other things defined in sys/time.h.

While I was at it I moved stuff around so that sysdeps/…/linux/bits/timex.h
defines everything that uapi linux/timex.h defines (as of version 5.0;
alas, we still cannot use linux/timex.h directly) plus the
MOD_CLKA and MOD_CLKB constants.  In particular, the TIME_* constants
are relevant to users of clock_adjtime as well as adjtimex (I presume—
clock_adjtime is not very well documented) so they should be visible
from time.h as well as sys/timex.h.  Conversely, as far as I can tell,
struct ntptimeval was never a kernel interface on Linux, and MAXTC is
not part of the exposed API and also has the wrong value for current
kernels.   Also I removed a thoroughly obsolete bug workaround from
ntp_gettime.c and ntp_gettimex.c.

	* sysdeps/unix/sysv/linux/sys/timex.h: Don’t include sys/time.h.
	Update commentary.  Don’t define MAXTC.  Move definition of
	NTP_API and the TIME_* constants...
	* sysdeps/unix/sysv/linux/bits/timex.h: ...here.
	Allow inclusion only by sys/timex.h and bits/time.h.
	Update commentary.

        * sysdeps/unix/sysv/linux/ntp_gettime.c
        * sysdeps/unix/sysv/linux/ntp_gettimex.c: Remove obsolete
	check for MOD_OFFSET not being defined.

	* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
	Update.
2020-01-08 13:45:45 -05:00
Zack Weinberg 225a0f4ef9 Don’t include string.h from sys/un.h.
sys/un.h needs strlen in order to define SUN_LEN, but does not need
any of the other things declared by string.h; the path of least
resistance is to prototype strlen locally.

Also, the construct being used to get the size of everything up to the
sun_path member contains a formal dereference of a null pointer and
therefore has undefined behavior.  Replace with __SOCKADDR_COMMON_SIZE.

Some old RPC code was relying on sys/un.h to provide all of string.h.

	* sys/un.h [__USE_MISC]: Don’t include string.h.
	Include bits/types/size_t.h.  Prototype strlen locally.
	Use __SOCKADDR_COMMON_SIZE for size of leading members of
	struct sockaddr_un.

	* nis/nis_domain_of.c, nis/yp_xdr.c, sunrpc/svc.c:
	Include string.h.

	* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
	Update.
2020-01-08 13:45:45 -05:00
Zack Weinberg 39906a3e2c Don’t include signal.h from sys/wait.h or sys/param.h.
Besides the snarl of debugger/ucontext interfaces, these are the only
public headers that include signal.h.

sys/wait.h includes signal.h only for the definition of siginfo_t.
We already have a single-type header for that, so use it.  siginfo_t
contains a field whose type is uid_t, but sys/wait.h is not specified
to define uid_t, so, as is already done for pid_t, the conformance
test is modified to expect that field to have type __uid_t instead.

It is not clear what subset of the definitions from signal.h are
actually expected by historical users of sys/param.h; I’ve chosen to
take the comment at face value and cut it down to bits/signum.h, which
supplies _NSIG and all of the SIG* constants.  This requires adjusting
every copy of bits/signum.h to permit inclusion by sys/param.h as well
as signal.h.

While I was at it I moved the comment about sys/param.h being obsolete
from sysdeps/mach/hurd/bits/param.h, where it’s not likely to be seen,
to the top-level sys/param.h, and edited it to give more useful advice.

This patch partially fixes Hurd-specific bug 23088; sys/wait.h is now
conformant.

	* posix/sys/wait.h: Include bits/types/siginfo_t.h, not signal.h.
	* conform/data/sys/wait.h-data: Do not expect a definition of uid_t.

	* malloc/tst-mallocfork.c, nptl/tst-fork4.c, nptl/tst-getpid3.c
	* nptl/tst-mutex9.c, nptl/tst-rwlock12.c
	* resolv/tst-resolv-res_init-skeleton.c
	* sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c:
        Include signal.h.

	* nptl/tst-cancel4.c, rt/tst-mqueue1.c
	* support/tst-support_capture_subprocess.c
	* sysdeps/unix/sysv/linux/tst-align-clone.c:
	Include signal.h.  Sort includes.

	* misc/sys/param.h: Include bits/signum.h, not signal.h.
	Add comment explaining that this header is obsolete, based on
	a similar comment in Hurd bits/param.h.

	* bits/param.h: Add multiple inclusion guard and defensive #error.
	* sysdeps/mach/hurd/bits/param.h: Add multiple inclusion guard.
	Remove comment explaining that this header is obsolete (see above).
	* sysdeps/mach/i386/bits/mach/param.h: Add multiple inclusion guard.
	* sysdeps/unix/sysv/linux/bits/param.h: Add multiple inclusion guard.

	* bits/signum-generic.h, bits/signum.h
	* sysdeps/unix/bsd/bits/signum.h
	* sysdeps/unix/sysv/linux/alpha/bits/signum.h
	* sysdeps/unix/sysv/linux/bits/signum.h
	* sysdeps/unix/sysv/linux/hppa/bits/signum.h
	* sysdeps/unix/sysv/linux/mips/bits/signum.h:
	Allow inclusion by sys/param.h as well as signal.h.

	* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
	Update.

        * sysdeps/mach/hurd/i386/Makefile: Remove XFAILs for sys/wait.h.
2020-01-08 13:45:44 -05:00
Zack Weinberg ff9bae2f92 Don’t include sys/select.h from sys/types.h.
This is supposedly present for BSD compatibility, but the current
generation of BSDs is not consistent about it: FreeBSD does, OpenBSD
doesn’t, NetBSD exposes only fd_set and the FD_* macros.  Programs
that need to wait for any of multiple I/O events have several
alternatives to select nowadays, so I think it makes sense to expose
select only to programs that specifically want it.

Only a few places within our own code are affected.  A few test
programs need to include sys/select.h explicitly, as does rpc/svc.h.
sysdeps/nptl/thread_db.h needs to declare sigset_t, and
sysdeps/unix/sysv/linux/pselect.c was including sys/poll.h instead of
sys/select.h, which is probably a copy-and-paste error.  sys/socket.h
needs to forward-declare struct timespec under __USE_GNU, because
recvmmsg has a struct timespec * argument; I’m open to the possibility
of having it fully declare struct timespec.

I considered taking sys/select.h out of sys/time.h as well, but POSIX
not only explicitly allows this inclusion, it requires sys/time.h to
declare almost everything that sys/select.h declares.  It doesn’t seem
worth creating another bits header just to prevent sys/time.h from
declaring pselect, sigset_t, and struct timespec.

Not including sys/select.h from sys/types.h means that sys/types.h
also no longer defines anything from sys/time.h, and a couple of files
were relying on that.  (pthread_join_common.c should be using
clock_gettime instead of gettimeofday, but that's out of scope for
this patch series.)

	* posix/sys/types.h: Don’t include sys/select.h.
	* scripts/check-obsolete-constructs.py: Remove whitelist entry
	for sys/types.h -> sys/select.h.  Adjust commentary re
	sys/time.h -> sys/select.h.

	* socket/sys/socket.h: When __USE_GNU, forward-declare struct timespec.
	* misc/tst-fdset.c, nptl/tst-cancel4.c, scripts/check-c++-types.sh
	* sunrpc/rpc/svc.h: Include sys/select.h.
	* sysdeps/nptl/thread_db.h: Include bits/types/sigset_t.h.
	* sysdeps/unix/sysv/linux/pselect.c: Include sys/select.h,
	not sys/poll.h.
	* nptl/pthread_join_common.c, sysdeps/unix/sysv/linux/dl-vdso.h:
	Include sys/time.h.
2020-01-08 13:45:44 -05:00
Zack Weinberg 7e2c24ffcb Limit the set of strings.h functions also exposed in string.h.
As someone who can remember when you might not be able to include both
string.h and strings.h at the same time, it annoys me that strings.h
still exists and is the only standard source for str(n)casecmp(_l) and
ffs.  I think it’s right that we expose those functions from string.h.
However, there’s no reason we need to keep exposing the other obsolete
functions that strings.h declares from string.h.

This patch creates <bits/strings_x2k8.h>, which declares the
non-obsolete functions whose official home is strings.h.  strings.h
includes it unconditionally, and string.h includes it under
__USE_MISC, instead of strings.h.

Two tests of the obsolete strings.h functions had to be adjusted.

	* string/strings.h (strcasecmp, strncasecmp, strcasecmp_l)
	(strncasecmp_l, ffs, ffsl, ffsll): Move declarations to...
	* string/bits/strings_x2k8.h: ... this new file.
	* string/Makefile: Install bits/strings_x2k8.h.
	* include/bits/strings_x2k8h: New wrapper.
	* string/string.h: Include bits/strings_x2k8.h instead of
	strings.h.

	* debug/tst-chk1.c, string/test-string.h: Include strings.h.
	* scripts/check-obsolete-constructs.py: string.h is no longer
	expected to include strings.h.

	* sysdeps/i386/i686/multiarch/bcopy.c
	* sysdeps/i386/i686/multiarch/bzero.c
	* sysdeps/i386/i686/multiarch/ifunc-impl-list.c
	* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c
	* sysdeps/powerpc/powerpc64/multiarch/bcopy-ppc64.c
	* sysdeps/powerpc/powerpc64/multiarch/bcopy.c
	* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
	* sysdeps/s390/bzero.c
	* sysdeps/s390/multiarch/ifunc-impl-list.c
	* sysdeps/sparc/sparc64/multiarch/bzero.c
	* sysdeps/sparc/sparc64/multiarch/ifunc-impl-list.c:
        Include strings.h.
2020-01-08 13:42:38 -05:00
Zack Weinberg ee57733099 Don’t rely on stddef.h or stdarg.h for individual type definitions.
In the course of developing earlier patches in this series I
discovered that clang’s stddef.h does not implement the __need_*
convention correctly: in C++, under some circumstances __need_NULL
will also cause a definition of nullptr_t, and when the “modules”
feature is enabled, all of the __need macros are ignored and all of
stddef.h is exposed.  (I’m not sure how to actually make either of
these things happen, I discovered the problem by reading the file.)

Worse, clang’s stdarg.h does not implement __need___va_list *at all*;
including its stdarg.h will always expose all of its definitions.

These are bugs in clang but it seems prudent to work around them, and
the simplest way to do so is to have the bits/types/ headers
introduced in the previous patch make definitions themselves, when
possible.  For size_t, ptrdiff_t, and wchar_t, we can use the
predefined macros __SIZE_TYPE__, __PTRDIFF_TYPE__, and __WCHAR_TYPE__,
when available, falling back to the old approach.  For __gnuc_va_list,
we have a whitelist of compilers known to provide __builtin_va_list,
falling back to the old approach.  NULL and va_list are defined
ab initio.

An additional complication is that we must be able to tell stddef.h
and stdarg.h _not_ to define again things we have already defined.  It
appears to me, based on inspection of clang, GCC, and icc stddef.h and
stdarg.h, that we can use the macros _SIZE_T, _PTRDIFF_T, _WCHAR_T,
_VA_LIST, and __GNUC_VA_LIST to accomplish this.

Since we are no longer relying on stdarg.h to define an
implementation-namespace alias for us, I thought it would make sense
also to stop calling it __gnuc_va_list.  The bulk of this patch is
a mechanical substitution of __va_list for __gnuc_va_list throughout
our headers.

Copyright boilerplate is added to stdlib/bits/NULL.h and stdlib/bits/types/*.h
because they now contain enough commentary and code that they could
plausibly be copyrightable.

	* stdlib/bits/NULL.h: Do not use stddef.h to define NULL.
	Define NULL ab initio if not already defined, as `((void *)0)` for C,
	and either `__null` or 0 for C++, depending on compiler support.

	* stdlib/bits/types/__va_list.h: If __builtin_va_list is known to
	be available, use it to define __va_list without including
	stdarg.h.  Otherwise use __need___va_list to request a definition
	of __gnuc_va_list and nothing else from stdarg.h, then use that to
	define __va_list.
	* stdlib/bits/types/va_list.h: Use __va_list, not __gnuc_va_list,
	to define va_list.  Improve commentary.

	* stdlib/bits/types/ptrdiff_t.h: If __PTRDIFF_TYPE__ is defined,
	use it to define ptrdiff_t without including stddef.h.  Otherwise
	use __need_ptrdiff_t to request a definition of ptrdiff_t and
	nothing else from stddef.h.  Use _PTRDIFF_T as guard macro to
	match behavior of common stddef.h implementations.
	* stdlib/bits/types/size_t.h: Similarly for size_t, with
	__SIZE_TYPE__, __need_size_t, and _SIZE_T.
	* stdlib/bits/types/wchar_t.h: Similarly for wchar_t, with
	__WCHAR_TYPE__, __need_wchar_t, and _WCHAR_T.  If __cplusplus
	is defined, do nothing; wchar_t is built-in in C++.

	* conform/data/stdio.h-data, conform/data/wchar.h-data
	* include/err.h, include/stdio.h, include/syslog.h, include/wchar.h
	* libio/bits/stdio.h, libio/bits/stdio2.h, libio/iolibio.h
	* libio/libio.h, libio/stdio.h, libio/vwprintf.c, misc/bits/syslog.h
	* misc/err.c, misc/err.h, misc/syslog.h, stdio-common/printf.h
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.c
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.h
	* wcsmbs/bits/wchar2.h, wcsmbs/wchar.h:
	Replace all uses of __gnuc_va_list with __va_list.

        * scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
        bits/NULL.h is no longer allowed to include stddef.h.
2020-01-08 13:42:38 -05:00
Zack Weinberg cb54252075 Add bits/types/ wrappers for stddef.h and stdarg.h types.
We rely on the compiler's stddef.h and stdarg.h to define size_t,
ptrdiff_t, wchar_t, NULL, and __gnuc_va_list, and to implement a
convention that allows us to request the definition of a specific one:
for instance

    #define __need_size_t
    #include <stddef.h>

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	* scripts/check-obsolete-constructs.py
	(UNIVERSAL_ALLOWED_INCLUDES): Remove stddef.h and stdarg.h.
	(HEADER_ALLOWED_INCLUDES): Update.
2020-01-08 13:41:32 -05:00
Zack Weinberg 7e51209849 Split up endian.h to minimize exposure of BYTE_ORDER.
With only two exceptions (sys/types.h and sys/param.h, both of which
historically might have defined BYTE_ORDER) the public headers that
include <endian.h> only want to be able to test __BYTE_ORDER against
__*_ENDIAN.

This patch creates a new bits/endian.h that can be included by any
header that wants to be able to test __BYTE_ORDER and/or
__FLOAT_WORD_ORDER against the __*_ENDIAN constants, or needs
__LONG_LONG_PAIR.  It only defines macros in the implementation
namespace.

The existing bits/endian.h (which could not be included independently
of endian.h, and only defines __BYTE_ORDER and maybe __FLOAT_WORD_ORDER)
is renamed to bits/endianness.h.  I also took the opportunity to
canonicalize the form of this header, which we are stuck with having
one copy of per architecture.  Since they are so short, this means git
doesn’t understand that they were renamed from existing headers, sigh.

endian.h itself is a nonstandard header and its only remaining use
from a standard header is guarded by __USE_MISC, so I dropped the
__USE_MISC conditionals from around all of the public-namespace things
it defines.  (This means, an application that requests strict library
conformance but includes endian.h will still see the definition of
BYTE_ORDER.)

A few changes to specific bits/endian(ness).h variants deserve
mention:

 - sysdeps/unix/sysv/linux/ia64/bits/endian.h is moved to
   sysdeps/ia64/bits/endianness.h.  If I remember correctly, ia64 did
   have selectable endianness, but we have assembly code in
   sysdeps/ia64 that assumes it’s little-endian, so there is no reason
   to treat the ia64 endianness.h as linux-specific.

 - The C-SKY port does not fully support big-endian mode, but I do
   not think this is sufficient reason to make csky/bits/endian(ness).h
   error out if __CSKYBE__ is defined, so it now defines __BYTE_ORDER
   appropriately for whichever mode the compiler is in.

 - The PowerPC port had extra logic in its bits/endian.h to detect a
   broken compiler, which strikes me as unnecessary, so I removed it.

 - The only files that defined __FLOAT_WORD_ORDER always defined it to
   the same value as __BYTE_ORDER, so I removed those definitions.
   The SH bits/endian(ness).h had comments inconsistent with the
   actual setting of __FLOAT_WORD_ORDER, which I also removed.

 - I *removed* copyright boilerplate from the few bits/endian(ness).h
   headers that had it; these files record a single fact in a fashion
   dictated by an external spec, so I do not think they are copyrightable.

As long as I was changing every copy of ieee754.h in the tree, I
noticed that only the MIPS variant includes float.h, because it uses
LDBL_MANT_DIG to decide among three different versions of
ieee854_long_double.  This patch makes it not include float.h when
GCC’s intrinsic __LDBL_MANT_DIG__ is available.

	* string/endian.h: Unconditionally define LITTLE_ENDIAN,
	BIG_ENDIAN, PDP_ENDIAN, and BYTE_ORDER.	 Condition byteswapping
	macros only on !__ASSEMBLER__.	Move the definitions of
	__BIG_ENDIAN, __LITTLE_ENDIAN, __PDP_ENDIAN, __FLOAT_WORD_ORDER,
	and __LONG_LONG_PAIR to...
	* string/bits/endian.h: ...this new file, which includes
	the renamed header bits/endianness.h for the definition of
	__BYTE_ORDER and possibly __FLOAT_WORD_ORDER.

	* string/Makefile: Install bits/endianness.h.
	* include/bits/endian.h: New wrapper.

	* bits/endian.h: Rename to bits/endianness.h.
	Add multiple-include guard.  Rewrite the comment explaining what
	the machine-specific variants of this file should do.

	* sysdeps/unix/sysv/linux/ia64/bits/endian.h:
	Move to sysdeps/ia64.

	* sysdeps/aarch64/bits/endian.h
	* sysdeps/alpha/bits/endian.h
	* sysdeps/arm/bits/endian.h
	* sysdeps/csky/bits/endian.h
	* sysdeps/hppa/bits/endian.h
	* sysdeps/ia64/bits/endian.h
	* sysdeps/m68k/bits/endian.h
	* sysdeps/microblaze/bits/endian.h
	* sysdeps/mips/bits/endian.h
	* sysdeps/nios2/bits/endian.h
	* sysdeps/powerpc/bits/endian.h
	* sysdeps/riscv/bits/endian.h
	* sysdeps/s390/bits/endian.h
	* sysdeps/sh/bits/endian.h
	* sysdeps/sparc/bits/endian.h
	* sysdeps/x86/bits/endian.h:
	Rename to endianness.h; canonicalize form of file; remove
	redundant definitions of __FLOAT_WORD_ORDER.

	* sysdeps/csky/bits/endianness.h: Do not error out if __CSKYEB__
	is defined.
	* sysdeps/powerpc/bits/endianness.h: Remove logic to check for
	broken compilers.

	* ctype/ctype.h
	* inet/netinet/in.h
	* resolv/arpa/nameser_compat.h
	* sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h
	* sysdeps/arm/nptl/bits/pthreadtypes-arch.h
	* sysdeps/csky/nptl/bits/pthreadtypes-arch.h
	* sysdeps/ia64/ieee754.h
	* sysdeps/ieee754/ieee754.h
	* sysdeps/ieee754/ldbl-128/ieee754.h
	* sysdeps/ieee754/ldbl-128ibm/ieee754.h
	* sysdeps/m68k/nptl/bits/pthreadtypes-arch.h
	* sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h
	* sysdeps/mips/ieee754/ieee754.h
	* sysdeps/mips/nptl/bits/pthreadtypes-arch.h
	* sysdeps/nios2/nptl/bits/pthreadtypes-arch.h
	* sysdeps/nptl/pthread.h
	* sysdeps/riscv/nptl/bits/pthreadtypes-arch.h
	* sysdeps/sh/nptl/bits/pthreadtypes-arch.h
	* sysdeps/sparc/sparc32/ieee754.h
	* sysdeps/unix/sysv/linux/generic/bits/stat.h
	* sysdeps/unix/sysv/linux/generic/bits/statfs.h
	* sysdeps/unix/sysv/linux/sys/acct.h
	* wctype/bits/wctype-wchar.h:
	Include bits/endian.h, not endian.h.

	* sysdeps/unix/sysv/linux/hppa/pthread.h: Don’t include endian.h.

	* sysdeps/mips/ieee754/ieee754.h: Use __LDBL_MANT_DIG__
	in ifdefs, instead of LDBL_MANT_DIG.  Only include float.h
	when __LDBL_MANT_DIG__ is not predefined, in which case
	define __LDBL_MANT_DIG__ to equal LDBL_MANT_DIG.

	* scripts/check-obsolete-constructs.h: Remove most of the
	whitelist entries for endian.h and float.h.
2020-01-08 13:41:26 -05:00
Zack Weinberg afaa4fe717 Don’t include sys/cdefs.h directly from public headers.
The convention throughout glibc is that every public header includes
features.h directly, as its first action, and relies on features.h to
include sys/cdefs.h.  In a few places, though, it’s been done the
other way around, usually in headers that were copied from a BSD
source (where the convention is exactly the opposite).  This patch
makes all installed headers match the glibc convention.

This patch also corrects a bug in glob.h: it may declare size_t
without notifying stddef.h that it has done this, so e.g.

    #define _XOPEN_SOURCE 700
    #include <glob.h>
    #include <stddef.h>
    int dummy;

declares size_t twice, which is invalid prior to C2011.  I wasn’t able
to persuade gcc 8 to issue an error, even with -std=c89 -Wsystem-headers,
but clang is not so lenient.

	* posix/glob.h: Include features.h, not sys/cdefs.h.
	When __USE_XOPEN || USE_XOPEN2K8, include stddef.h for size_t;
	otherwise, issue an immediate #error if __SIZE_TYPE__ is not
	available. Use __gsize_t, not __size_t, as an impl-namespace
	alternative name for size_t.
	* conform/data/glob.h-data: Adjust to match.

	* inet/netinet/igmp.h, mach/lock-intern.h, misc/ar.h
	* misc/sys/auxv.h, resolv/resolv.h, socket/sys/un.h
	* sunrpc/rpc/auth_des.h, sunrpc/rpc/rpc_msg.h
	* sysdeps/generic/memcopy.h, sysdeps/generic/netinet/tcp.h
	* sysdeps/htl/pthread.h, sysdeps/mach/hurd/net/ethernet.h
	* sysdeps/mach/hurd/net/if_arp.h: Include features.h, not sys/cdefs.h.

	* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
        Update.
2020-01-08 13:04:44 -05:00
Zack Weinberg 89cbc039a9 Swap sys/poll.h with poll.h.
Similarly to (sys/)syslog.h, poll.h is the header standardized by
POSIX, but we had all of its contents in sys/, for historical reasons.
This patch exchanges the contents of the two headers, and adds
multiple-include guards to all of poll.h’s bits headers.

	* io/poll.h: Exchange contents with...
	* io/sys/poll.h: ...this file.  Adjust guard macros.

	* include/poll.h: Exchange contents with...
	* include/sys/poll.h: ...this file.  Adjust guard macros.

	* bits/poll.h, io/bits/poll2.h
	* sysdeps/unix/sysv/linux/bits/poll.h
	* sysdeps/unix/sysv/linux/m68k/bits/poll.h
	* sysdeps/unix/sysv/linux/mips/bits/poll.h
	* sysdeps/unix/sysv/linux/sparc/bits/poll.h:
        Allow inclusion by poll.h, not sys/poll.h.  Add multiple-
        include guards where not already present.

	* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
        Update.
2020-01-08 13:04:43 -05:00
Zack Weinberg 5ad1fcd032 Swap sys/syslog.h with syslog.h.
Our installed syslog.h is a trivial wrapper around sys/syslog.h, which
is where all the actual declarations are.  This is backward from
POSIX, which specifies syslog.h and its contents, and does not specify
sys/syslog.h.  This arrangement appears to have been inherited from
some BSD-phylum C library, and probably pre-dates any standardization
of syslog.

This patch swaps the contents of syslog.h and sys/syslog.h, so that
the actual declarations appear under the standardized name.  Since it
is necessary to adjust all of syslog.h’s bits headers, I also added
multiple-include guards to those files that didn’t already have
them.  (All installed headers should have multiple-include guards,
even if they are internal and only used in one public header.  The
“never include this file directly” #error convention doesn’t protect
against including the internal header a second time after its parent
header has already been included.)

	* misc/sys/syslog.h: Exchange contents with...
	* misc/syslog.h: ...this file.  Adjust multiple-include guards.

	* include/sys/syslog.h: Exchange contents with...
	* include/syslog.h: ...this file.  Adjust multiple-include guards.

	* bits/syslog-path.h, misc/bits/syslog-ldbl.h
	* misc/bits/syslog.h: Allow inclusion by syslog.h, not sys/syslog.h.
	Add multiple-include guard where not already present.

	* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
        Update.
2020-01-08 12:56:34 -05:00
Zack Weinberg 86130d1b37 Add check-obsolete-constructs checker for nested includes.
As a first step toward minimizing the number of public headers that
include other public headers, add a checker to check-obsolete-constructs
that will error out on any such inclusion that’s not on a whitelist.
The whitelist is initialized to all of the nested inclusions that
already exist; subsequent patches will remove nested inclusions and
shrink the whitelist, hopefully to the point where we only have
nested inclusions as mandated by the relevant standards.

Hurd headers and Sun RPC headers and interface definitions are exempt
from these checks.  The former is because minimizing their
cross-inclusions would require making Hurd-specific design decisions,
which I feel is best left to the Hurd maintainers.  The latter is
because they are obsolete in glibc; cleanups should be done under the
auspices of TIRPC.

	* scripts/check-obsolete-constructs.py
	(UNIVERSAL_ALLOWED_INCLUDES, HEADER_ALLOWED_INCLUDES)
	(SYSDEP_ALLOWED_INCLUDES, NESTED_INCLUDES_EXEMPT_RE)
	(get_allowed_nested, NestedIncludeCheckerWhitelistOnly)
	(NestedIncludeChecker): New.
	(HeaderChecker): Instantiate and run a NestedIncludeChecker
	for each header.
2020-01-08 12:56:33 -05:00
Zack Weinberg 795eb42e06 Don’t conditionalize declarations of ldiv_t, lldiv_t, __gwchar_t.
The declarations of ldiv_t, lldiv_t, and __gwchar_t are all wrapped in
__foo_t_defined conditionals, despite there being only one header in
glibc that declares them.  I checked codesearch.debian.net and only
found one other program that refers to the __foo_t_defined
conditionals: u-boot provides its own definition of ldiv_t if
__ldiv_t_defined is not defined by stdlib.h.  I conclude that the
conditionals are not necessary, but the definitions of
__ldiv_t_defined and __lldiv_t_defined should be preserved.

	* stdlib/inttypes.h: Unconditionally define __gwchar_t.
        Don’t define ____gwchar_t_defined.
        * stdlib/stdlib.h: Unconditionally define ldiv_t.
        Condition lldiv_t only on __USE_ISOC99.
2020-01-08 12:56:33 -05:00
Zack Weinberg d5ebebf969 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.
2020-01-08 12:56:32 -05:00
Zack Weinberg 23432307d4 Clean up bits/types.h.
This makes four linked changes to bits/types.h.  First, we use
__(u)?int(16|32|64)_t to define __[SU](16|32|64)_TYPE.  In addition
to reducing the amount of ifdeffage, this means __STD_TYPE is no longer
necessary, since gcc -std=c89 will complain about ‘typedef long long foo_t’
but not ‘typedef __int64_t foo_t’, even if the underlying type
of __int64_t is long long.

Second, we eliminate __UQUAD_TYPE and __SQUAD_TYPE from the set of
macros bits/typesizes.h should use to define __FOO_T_TYPE macros,
since they are always the same as __U64_TYPE and __S64_TYPE
respectively.

Third, we remove __u_char, __u_short, __u_int, __u_long, __u_quad_t,
and __quad_t, we add __uintptr_t, and we define __intmax_t and
__uintmax_t as __int64_t and __uint64_t.

Fourth, we reorganize the list of typedefs into groups by the
standard (if any) that defines them, and sort them alphabetically within
each group.

	* posix/bits/types.h: Move #error for __WORDSIZE neither 32 nor 64
	to first group of conditionals on __WORDSIZE, and make it more
	explicit.  Update commentary.  Define all __foo_t types with
	regular ‘typedef’.  Reorganize all __foo_t types into the same
	groups that sys/types.h uses.
	(__u_char, __u_short, __u_int, __u_long, __quad_t, __u_quad_t)
	(__UQUAD_TYPE, __SQUAD_TYPE, __STD_TYPE): Don’t define.
	(__S16_TYPE): Define unconditionally as __int16_t.
	(__U16_TYPE): Define unconditionally as __uint16_t.
	(__S32_TYPE): Define unconditionally as __int32_t.
	(__U32_TYPE): Define unconditionally as __uint32_t.
	(__S64_TYPE): Define unconditionally as __int64_t.
	(__U64_TYPE): Define unconditionally as __uint64_t.
	(__intmax_t): Define unconditionally as __int64_t.
	(__uintmax_t): Define unconditionally as __uint64_t.
        (__uintptr_t): New typedef.

	* bits/time64.h
	* bits/typesizes.h
	* sysdeps/mach/hurd/bits/typesizes.h
	* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
	* sysdeps/unix/sysv/linux/generic/bits/typesizes.h
	* sysdeps/unix/sysv/linux/mips/bits/typesizes.h
	* sysdeps/unix/sysv/linux/s390/bits/typesizes.h
	* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
	* sysdeps/unix/sysv/linux/x86/bits/typesizes.h:
	Replace all uses of __UQUAD_TYPE with __U64_TYPE, and all
	uses of __SQUAD_TYPE with __S64_TYPE.

        * posix/sys/types.h, rpc/sys/types.h
        (u_char): Define as unsigned char.
        (u_short): Define as unsigned short.
        (u_int): Define as unsigned int.
        (u_long): Define as unsigned long.
        (quad_t): Define as __int64_t.
        (u_quad_t): Define as __uint64_t.

        * stdlib/stdint.h (intptr_t): Define as __intptr_t.
        (uintptr_t): Define as __uintptr_t.

        * scripts/check-obsolete-constructs.py: Update allowed
        definitions for the obsolete types.  No longer allow
        __STD_TYPE as an alias for typedef.
2020-01-08 12:56:32 -05:00
Zack Weinberg 9bdd08229b Simplify definition of __time64_t.
bits/time64.h always sets __TIME64_T_TYPE to be __time_t when
__TIMESIZE == 64, so we can unconditionally use __TIME64_T_TYPE to
define __time64_t; we don’t need another conditional in bits/types.h.

Also move the definition of __time64_t next to the definition of
__time_t.

	* posix/bits/types.h (__time64_t): Unconditionally define
        as __TIME64_T_TYPE.  Move definition next to __time_t.
2020-01-08 12:56:31 -05:00
Zack Weinberg 454939fdd0 Add caddr_t, daddr_t, and loff_t to the set of obsolete typedefs.
caddr_t is a BSD-derived alias for ‘char *’, obsoleted by the
introduction of ‘void *’ in C89 (!)  daddr_t is a “disk address,”
but it’s always defined as ‘int’, making it too small for modern
disks and tapes.  loff_t is another name for off64_t, from early
drafts of LFS.  All three are already only exposed by sys/types.h
under __USE_MISC.

This patch adds them to the set of types that shall not be used in
installed headers (enforced by check-obsolete-constructs.py) and
expunges all remaining uses, internally as well as in installed
headers.  Since __DADDR_T_TYPE is always defined as __S32_TYPE, and
daddr_t is obsolete so there’s no need to worry about future
variation, the patch also removes __DADDR_T_TYPE from the set of
macros that bits/typesizes.h is required to define.  Instead
bits/types.h always defines __daddr_t as __S32_TYPE, and the
definition is moved to a more logical location within the file, next
to __caddr_t.

It’s always safe to change (__)loff_t to the matching (__)off64_t;
in a few internal files, I removed an unnecessary __ prefix.

daddr_t is only used for struct ustat, which is obsoleted by struct
statvfs and we already don’t declare it in public headers, and for an
ioctl parameter block in sys/mtio.h (which may or may not be obsolete,
I can’t tell).  In sys/mtio.h I replaced both uses with ‘int’ to match
the use of bare ‘long int’ for most of the other fields of that
structure.  In misc/ustat.c, the definition of struct ustat is not
actually necessary so I removed it entirely.  In
sysdeps/unix/sysv/linux/ustat.c a definition is necessary but only
because INLINE_SYSCALL_CALL doesn’t work (on at least x86) when an
argument is a pointer to an incomplete type, so I substituted a dummy
definition.

Most of the internal uses of caddr_t are in the sunrpc and nis
directories, and since most of that code is obsolete, I mechanically
replaced them with char * rather than consider whether void * might
make more sense.  Because “const caddr_t foo” is semantically
different from “const char *foo” (in the first case ‘foo’ itself is
const but the memory pointed to isn’t, in the second case the memory
pointed to is const but ‘foo’ isn’t) this change exposed some
const-correctness errors in sunrpc, which I fixed minimally.  Outside
of sunrpc and nis, I put a little more thought into whether uses of
caddr_t should be void * instead.

	* scripts/check-obsolete-constructs.py: Add caddr_t, daddr_t,
        and loff_t to the set of obsolete types forbidden in public
        headers.

	* posix/bits/types.h: Unconditionally define __daddr_t as
        __S32_TYPE.  Move definition of __daddr_t next to definition
        of __caddr_t.
	* bits/typesizes.h
	* sysdeps/mach/hurd/bits/typesizes.h
	* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
	* sysdeps/unix/sysv/linux/generic/bits/typesizes.h
	* sysdeps/unix/sysv/linux/mips/bits/typesizes.h
	* sysdeps/unix/sysv/linux/s390/bits/typesizes.h
	* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
	* sysdeps/unix/sysv/linux/x86/bits/typesizes.h:
        Don’t define __DADDR_T_TYPE.

        * sysdeps/gnu/sys/mtio.h (struct mtget): Change all uses of
	__daddr_t to int.
	* misc/ustat.c: Remove definition of struct ustat; only
        forward-declare it.
	* sysdeps/unix/sysv/linux/ustat.c: Replace fields of
        struct ustat with a size-preserving dummy field.

	* hurd/Makefile (migheaderpipe): Rewrite loff_t as __off64_t.
        * hurd/fd-read.c (_hurd_fd_read): Use off64_t instead of loff_t.
        * hurd/fd-write.c (hurd_fd_write): Use off64_t instead of loff_t.
        * hurd/hurd/fd.h (_hurd_fd_read, _hurd_fd_write): Declare
        using __off64_t instead of __loff_t.
        * support/xunistd.h (xcopy_file_range): Declare using off64_t
        instead of loff_t.
	* sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h
	* sysdeps/unix/sysv/linux/lseek.c
	* sysdeps/unix/sysv/linux/lseek64.c
	* sysdeps/unix/sysv/linux/splice.c
        Throughout, use off64_t instead of loff_t.

	* sysdeps/unix/sysv/linux/sys/quota.h
        (dqoff): Use __off64_t instead of __loff_t.
        (quotactl): Declare using char * instead of caddr_t.
	* sysdeps/unix/sysv/linux/test-errno-linux.c
        (do_test): Cast to char * instead of caddr_t when calling quotactl.

	* elf/dl-map-segments.h (_dl_map_segments): Cast to void *
        instead of caddr_t when calling __mprotect and __mmap.
        * elf/dl-minimal.c (malloc): Declare page as char *, not caddr_t.
        * elf/dl-reloc.c (_dl_relocate_object): Declare textrels.start
        as char *, not caddr_t.  Cast to char *, not caddr_t, in
        pointer arithmetic.

	* intl/loadmsgcat.c: Remove two unnecessary casts to caddr_t
        when calling munmap. Change a third cast to target void *
        instead and add a comment explaining why this one is necessary.

	* locale/loadlocale.c (_nl_load_locale): Use NULL instead of
        `(caddr_t)0`, and remove an unnecessary cast to caddr_t when
        calling munmap.
        (_nl_unload_locale): Change casts when calling free and munmap
        to target char *, and add a comment explaining why they are
        necessary.

	* sysdeps/gnu/net/if.h
        (struct ifreq): Declare ifru_data as char *, not __caddr_t.
        (struct ifconf): Declare ifcu_buf as char *, not __caddr_t.

	* nis/nis_add.c
	* nis/nis_call.c
	* nis/nis_callback.c
	* nis/nis_checkpoint.c
	* nis/nis_findserv.c
	* nis/nis_intern.h
	* nis/nis_lookup.c
	* nis/nis_mkdir.c
	* nis/nis_modify.c
	* nis/nis_ping.c
	* nis/nis_remove.c
	* nis/nis_rmdir.c
	* nis/nis_server.c
	* nis/nis_table.c
	* nis/nis_util.c
	* nis/nss_nisplus/nisplus-grp.c
	* nis/nss_nisplus/nisplus-pwd.c
	* nis/rpcsvc/nis_callback.h
	* nis/rpcsvc/yp.h
	* nis/ypclnt.c
	* sunrpc/auth_des.c
	* sunrpc/auth_unix.c
	* sunrpc/authdes_prot.c
	* sunrpc/authuxprot.c
	* sunrpc/clnt_raw.c
	* sunrpc/clnt_tcp.c
	* sunrpc/clnt_udp.c
	* sunrpc/clnt_unix.c
	* sunrpc/key_call.c
	* sunrpc/pm_getmaps.c
	* sunrpc/pm_getport.c
	* sunrpc/pmap_clnt.c
	* sunrpc/pmap_prot2.c
	* sunrpc/pmap_rmt.c
	* sunrpc/proto.h
	* sunrpc/rpc/auth.h
	* sunrpc/rpc/clnt.h
	* sunrpc/rpc/pmap_clnt.h
	* sunrpc/rpc/pmap_rmt.h
	* sunrpc/rpc/rpc_msg.h
	* sunrpc/rpc/svc.h
	* sunrpc/rpc/xdr.h
	* sunrpc/rpc_clntout.c
	* sunrpc/rpc_cmsg.c
	* sunrpc/rpc_hout.c
	* sunrpc/rpc_prot.c
	* sunrpc/rpc_sample.c
	* sunrpc/rpc_svcout.c
	* sunrpc/svc.c
	* sunrpc/svc_authux.c
	* sunrpc/svc_raw.c
	* sunrpc/svc_tcp.c
	* sunrpc/svc_udp.c
	* sunrpc/svc_unix.c
	* sunrpc/xdr.c
	* sunrpc/xdr_array.c
	* sunrpc/xdr_mem.c
	* sunrpc/xdr_rec.c
	* sunrpc/xdr_ref.c
	* sunrpc/xdr_sizeof.c
	* sunrpc/xdr_stdio.c:
        Mechanically replace all uses of caddr_t with char *.

        * sunrpc/xdr_mem.c (xdrmem_create): Cast away const when
        setting xdrs->x_private and xdrs->x_base.
        * sunrpc/xdr_stdio.c (xdrstdio_getbytes): Correct argument
        types in definition to match prototype.
2020-01-08 12:56:31 -05:00
Zack Weinberg 40782c2685 sys/types.h: Don’t define u_intN_t or register_t unless __USE_MISC.
sys/types.h unconditionally defines u_int8_t, u_int16_t, u_int32_t,
u_int64_t, and register_t.  These are not part of any standard.  The
u_intXX_t types are superseded by C99’s uintXX_t types (defined in
stdint.h).  I’m not aware of a standardized exact equivalent of
register_t, but also I’ve never seen anyone use it for anything.
I could be persuaded to leave that one alone.

sys/types.h also unconditionally defines int8_t, int16_t, int32_t, and
int64_t, which are the same as the C99 exact-width signed types in
stdint.h.  POSIX doesn’t require these to appear in sys/types.h, so in
principle they ought to be brought under __USE_MISC also.  But, when I
tried that it broke about two dozen files just in our own source tree,
and POSIX doesn’t *forbid* sys/types.h to define these types, so I
think we should leave them alone.

	* posix/sys/types.h (u_int8_t, u_int16_t, u_int32_t, u_int64_t)
        (register_t): Move under #ifdef __USE_MISC.
        Consolidate adjacent #ifdef __USE_MISC blocks.
        * scripts/check_obsolete_constructs.py: Add register_t to the
        set of obsolete typedefs that our headers should not use
        (but sys/types.h may still define).
2020-01-08 12:52:50 -05:00
Zack Weinberg 9d8ecbbf11 Define register_t using bits/typesizes.h macros.
Currently register_t is, unlike all other types in sys/types.h,
defined using a GCC extension (__attribute__((mode(word)))), falling
back to ‘int’ if the extension is unavailable.  This is a potential
ABI compatibility hazard for people using non-GNU compilers with
glibc.  It’s also unnecessary; the bits/typesizes.h mechanism can
handle all of the existing variation in the definition.  In most
cases, defining __REGISTER_T_TYPE as __SWORD_TYPE is sufficient.
Special handling is necessary for MIPS n32 and x86-64 x32, where
__SWORD_TYPE is ‘int’ and the appropriate type for register_t is
‘long long’.  Unfortunately, this means we need to create a new
bits/typesizes.h variant for linux/mips.  This variant is based
on the top-level bits/typesizes.h, not linux/generic/bits/typesizes.h,
to match the existing MIPS ABIs.

Tested using build-many-glibcs.  The c++-types test confirms that the
physical type of register_t does not change on any supported platform.

	* posix/sys/types.h: Typedef register_t as __register_t.
        * posix/bits/types.h: Typedef __register_t using __REGISTER_T_TYPE.

	* bits/typesizes.h
        * sysdeps/mach/hurd/bits/typesizes.h
        * sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
        * sysdeps/unix/sysv/linux/generic/bits/typesizes.h
        * sysdeps/unix/sysv/linux/s390/bits/typesizes.h
        * sysdeps/unix/sysv/linux/sparc/bits/typesizes.h:
        Define __REGISTER_T_TYPE as __SWORD_TYPE.

        * sysdeps/unix/sysv/linux/mips/bits/typesizes.h:
        New file (copied from bits/typesizes.h).
        Define __REGISTER_T_TYPE as __SWORD_TYPE for o32 and n64 ABIs.
        Define __REGISTER_T_TYPE as __SQUAD_TYPE for n32.
        * sysdeps/unix/sysv/linux/x86/bits/typesizes.h:
        Define __REGISTER_T_TYPE as __SWORD_TYPE for o32 and 64-bit ABIs.
        Define __REGISTER_T_TYPE as __SQUAD_TYPE for x32.
2020-01-08 12:52:49 -05:00
Zack Weinberg 6de42c5330 Move most headers installed by top-level Makefile to misc/.
The Makefile glue to run tests on installed headers is currently
duplicated between the top-level Makefile and Rules, because the
top-level Makefile doesn't read Rules but does install some headers.

This patch moves most of the headers installed by the top-level Makefile
to misc/ (chosen arbitrarily; I'm open to putting them somewhere else
if reviewers feel it would be better) and removes the duplicated logic
from the top-level Makefile.  I believe this also means that none of
the headers in include/ are installed headers anymore.

gnu/lib-names*.h are still generated by code in Makerules and installed
by the top-level Makefile.  I tried to move them to misc/ as well, but
that broke the generation process in a manner that didn't make any sense
so I gave up.  The tests performed on installed headers are not
especially useful for gnu/lib-names*.h so I think we can live with this
for now.

	* include/bits/xopen_lim.h
	* include/features.h
	* include/gnu-versions.h
	* include/gnu/libc-version.h
	* include/limits.h
	* include/stdc-predef.h
	* include/values.h:
	Move to misc/ and replace with a trivial wrapper.
	* Makefile (headers): Remove all headers moved to misc/.
	Don't set a vpath for %.h.
	(check-installed-headers-c.out, check-installed-headers-cxx.out)
	(check-wrapper-headers.out): Remove rules.
	* misc/Makefile (headers): Add all of the above headers and
	sort the list.
	* sysdeps/mach/hurd/bits/errno.h: Regenerate.
2020-01-08 12:52:44 -05:00
648 changed files with 5355 additions and 4328 deletions
+2 -36
View File
@@ -68,17 +68,11 @@ endif # $(AUTOCONF) = no
subdir_objs subdir_stubs subdir_testclean \
$(addprefix install-, no-libc.a bin lib data headers others)
headers := limits.h values.h features.h gnu-versions.h \
bits/xopen_lim.h gnu/libc-version.h stdc-predef.h \
bits/libc-header-start.h
headers :=
echo-headers: subdir_echo-headers
# The headers are in the include directory.
subdir-dirs = include
vpath %.h $(subdir-dirs)
# What to install.
# This header is created during the install process. See below.
install-others = $(inst_includedir)/gnu/stubs.h
install-bin-script =
@@ -522,34 +516,6 @@ $(objpfx)check-local-headers.out: scripts/check-local-headers.sh
"$(includedir)" "$(objpfx)" < /dev/null > $@; \
$(evaluate-test)
ifneq "$(headers)" ""
# Special test of all the installed headers in this directory.
tests-special += $(objpfx)check-installed-headers-c.out
libof-check-installed-headers-c := testsuite
$(objpfx)check-installed-headers-c.out: \
scripts/check-installed-headers.sh $(headers)
$(SHELL) $(..)scripts/check-installed-headers.sh c \
"$(CC) $(filter-out -std=%,$(CFLAGS)) -D_ISOMAC $(+includes)" \
$(headers) > $@; \
$(evaluate-test)
ifneq "$(CXX)" ""
tests-special += $(objpfx)check-installed-headers-cxx.out
libof-check-installed-headers-cxx := testsuite
$(objpfx)check-installed-headers-cxx.out: \
scripts/check-installed-headers.sh $(headers)
$(SHELL) $(..)scripts/check-installed-headers.sh c++ \
"$(CXX) $(filter-out -std=%,$(CXXFLAGS)) -D_ISOMAC $(+includes)" \
$(headers) > $@; \
$(evaluate-test)
endif # $(CXX)
tests-special += $(objpfx)check-wrapper-headers.out
$(objpfx)check-wrapper-headers.out: scripts/check-wrapper-headers.py $(headers)
$(PYTHON) $< --root=. --subdir=. $(headers) \
--generated $(common-generated) > $@; $(evaluate-test)
endif # $(headers)
define summarize-tests
@egrep -v '^(PASS|XFAIL):' $(objpfx)$1 || true
@echo "Summary of test results$2:"
+11
View File
@@ -187,6 +187,17 @@ Deprecated and removed features, and other changes affecting compatibility:
* The obsolete and never-implemented XSI STREAMS header files <stropts.h>
and <sys/stropts.h> have been removed.
* The obsolete functions bcmp, bcopy, bzero, index, and rindex are no
longer declared in <string.h>, only <strings.h>.
* The typedefs u_int8_t, u_int16_t, u_int32_t, u_int64_t, and register_t
are no longer defined by <sys/types.h> in strict conformance modes.
These types were historically provided by <sys/types.h> on BSD systems,
but are not part of the POSIX specification for that header. Applications
requiring fixed-width unsigned integer types should use the similarly
named uint8_t, uint16_t, etc. from <stdint.h>. There is no standardized
replacement for register_t.
* Support for the "inet6" option in /etc/resolv.conf and the RES_USE_INET6
resolver flag (deprecated in glibc 2.25) have been removed.
-13
View File
@@ -1,13 +0,0 @@
/* This file should define __BYTE_ORDER as appropriate for the machine
in question. See string/endian.h for how to define it.
If only the stub bits/endian.h applies to a particular configuration,
bytesex.h is generated by running a program on the host machine.
So if cross-compiling to a machine with a different byte order,
the bits/endian.h file for that machine must exist. */
#ifndef _ENDIAN_H
# error "Never use <bits/endian.h> directly; include <endian.h> instead."
#endif
#error Machine byte order unknown.
+17
View File
@@ -0,0 +1,17 @@
/* This file must be overridden for each supported CPU architecture.
It should define __BYTE_ORDER to one of the constants defined in
string/bits/endian.h, as appropriate for the machine in
question. If floating-point quantities are not stored in the
same byte order as integer quantities, it should also define
__FLOAT_WORD_ORDER as appropriate. */
#ifndef _BITS_ENDIANNESS_H
#define _BITS_ENDIANNESS_H 1
#ifndef _BITS_ENDIAN_H
# error "Never use <bits/endianness.h> directly; include <endian.h> instead."
#endif
#error "Machine byte order unknown."
#endif /* bits/endianness.h */
+6 -3
View File
@@ -16,10 +16,14 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _BITS_FCNTL_H
#define _BITS_FCNTL_H 1
#ifndef _FCNTL_H
#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
#endif
#include <bits/types.h>
/* File access modes for `open' and `fcntl'. */
#define O_RDONLY 0 /* Open read-only. */
@@ -104,9 +108,6 @@
/* File descriptor flags used with F_GETFD and F_SETFD. */
#define FD_CLOEXEC 1 /* Close on exec. */
#include <bits/types.h>
/* The structure describing an advisory lock. This is the type of the third
argument to `fcntl' for the F_GETLK, F_SETLK, and F_SETLKW requests. */
struct flock
@@ -144,3 +145,5 @@ struct flock64
# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
#endif
#endif
+5 -3
View File
@@ -15,15 +15,15 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _BITS_IN_H
#define _BITS_IN_H 1
/* Generic version. */
#ifndef _NETINET_IN_H
# error "Never use <bits/in.h> directly; include <netinet/in.h> instead."
#endif
/* This is the generic version, do not assume a linux-based kernel. */
#define __USE_KERNEL_IPV6_DEFS 0
/* To select the IP level. */
#define SOL_IP 0
@@ -115,3 +115,5 @@ struct ip_opts
#define IPV6_RTHDR_STRICT 1 /* Hop must be a neighbour. */
#define IPV6_RTHDR_TYPE_0 0 /* IPv6 Routing header type 0. */
#endif /* bits/in.h. */
+7
View File
@@ -16,6 +16,9 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _BITS_PARAM_H
#define _BITS_PARAM_H 1
#ifndef _SYS_PARAM_H
# error "Never use <bits/param.h> directly; include <sys/param.h> instead."
#endif
@@ -31,3 +34,7 @@
EXEC_PAGESIZE
*/
#error "Generic bits/param.h should not have been used."
#endif
+7 -2
View File
@@ -15,8 +15,11 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _SYS_POLL_H
# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
#ifndef _BITS_POLL_H
#define _BITS_POLL_H 1
#ifndef _POLL_H
# error "Never use <bits/poll.h> directly; include <poll.h> instead."
#endif
/* Event types that can be polled for. These bits may be set in `events'
@@ -40,3 +43,5 @@
#define POLLERR 010 /* Error condition. */
#define POLLHUP 020 /* Hung up. */
#define POLLNVAL 040 /* Invalid polling request. */
#endif /* bits/poll.h */
+6 -1
View File
@@ -15,11 +15,14 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _BITS_SEM_H
#define _BITS_SEM_H 1
#ifndef _SYS_SEM_H
# error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
#endif
#include <sys/types.h>
#include <bits/types.h>
/* Flags for `semop'. */
#define SEM_UNDO 0x1000 /* undo the operation on exit */
@@ -58,3 +61,5 @@ struct semid_ds
incorrect. One can test the macro _SEM_SEMUN_UNDEFINED to see whether
one must define the union or not. */
#define _SEM_SEMUN_UNDEFINED 1
#endif /* bits/sem.h */
+1 -1
View File
@@ -19,7 +19,7 @@
#ifndef _BITS_SIGNUM_GENERIC_H
#define _BITS_SIGNUM_GENERIC_H 1
#ifndef _SIGNAL_H
#if !defined _SIGNAL_H && !defined _SYS_PARAM_H
#error "Never include <bits/signum-generic.h> directly; use <signal.h> instead."
#endif
+1 -1
View File
@@ -19,7 +19,7 @@
#ifndef _BITS_SIGNUM_H
#define _BITS_SIGNUM_H 1
#ifndef _SIGNAL_H
#if !defined _SIGNAL_H && !defined _SYS_PARAM_H
#error "Never include <bits/signum.h> directly; use <signal.h> instead."
#endif
+3
View File
@@ -39,4 +39,7 @@ typedef unsigned short int sa_family_t;
/* Size of struct sockaddr_storage. */
#define _SS_SIZE 128
/* Size of struct sockaddr.sa_data. */
#define __SOCKADDR_DATA_SIZE 14
#endif /* bits/sockaddr.h */
-47
View File
@@ -23,18 +23,6 @@
# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
#endif
#define __need_size_t
#include <stddef.h>
#include <bits/wordsize.h>
#include <bits/types.h>
/* Type for length arguments in socket calls. */
#ifndef __socklen_t_defined
typedef __socklen_t socklen_t;
# define __socklen_t_defined
#endif
/* Types of sockets. */
enum __socket_type
@@ -145,34 +133,6 @@ enum __socket_type
/* Maximum queue length specifiable by listen. */
#define SOMAXCONN 128 /* 5 on the origional 4.4 BSD. */
/* Get the definition of the macro to define the common sockaddr members. */
#include <bits/sockaddr.h>
/* Structure describing a generic socket address. */
struct sockaddr
{
__SOCKADDR_COMMON (sa_); /* Common data: address family and length. */
char sa_data[14]; /* Address data. */
};
/* Structure large enough to hold any socket address (with the historical
exception of AF_UNIX). */
#if __WORDSIZE == 64
# define __ss_aligntype __uint64_t
#else
# define __ss_aligntype __uint32_t
#endif
#define _SS_PADSIZE \
(_SS_SIZE - __SOCKADDR_COMMON_SIZE - sizeof (__ss_aligntype))
struct sockaddr_storage
{
__SOCKADDR_COMMON (ss_); /* Address family, etc. */
char __ss_padding[_SS_PADSIZE];
__ss_aligntype __ss_align; /* Force desired alignment. */
};
/* Bits in the FLAGS argument to `send', `recv', et al. */
enum
@@ -355,11 +315,4 @@ enum
#define SO_TYPE SO_TYPE
};
/* Structure used to manipulate the SO_LINGER option. */
struct linger
{
int l_onoff; /* Nonzero to linger on close. */
int l_linger; /* Time to linger. */
};
#endif /* bits/socket.h */
+4 -4
View File
@@ -16,13 +16,13 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _SYS_SYSLOG_H
# error "Never include this file directly. Use <sys/syslog.h> instead"
#endif
#ifndef _BITS_SYSLOG_PATH_H
#define _BITS_SYSLOG_PATH_H 1
#ifndef _SYSLOG_H
# error "Never include <bits/syslog-path.h> directly. Use <syslog.h> instead"
#endif
#define _PATH_LOG "/dev/log"
#endif /* bits/syslog-path.h */
+1 -1
View File
@@ -30,7 +30,7 @@
# define __TIME64_T_TYPE __TIME_T_TYPE
#else
/* Define a 64-bit time type alongsize the 32-bit one. */
# define __TIME64_T_TYPE __SQUAD_TYPE
# define __TIME64_T_TYPE __S64_TYPE
#endif
#endif /* bits/time64.h */
+1 -2
View File
@@ -19,8 +19,7 @@
#ifndef __stack_t_defined
#define __stack_t_defined 1
#define __need_size_t
#include <stddef.h>
#include <bits/types/size_t.h>
/* Structure describing a signal stack. */
typedef struct
+8 -8
View File
@@ -26,31 +26,30 @@
/* See <bits/types.h> for the meaning of these macros. This file exists so
that <bits/types.h> need not vary across different GNU platforms. */
#define __DEV_T_TYPE __UQUAD_TYPE
#define __DEV_T_TYPE __U64_TYPE
#define __UID_T_TYPE __U32_TYPE
#define __GID_T_TYPE __U32_TYPE
#define __INO_T_TYPE __ULONGWORD_TYPE
#define __INO64_T_TYPE __UQUAD_TYPE
#define __INO64_T_TYPE __U64_TYPE
#define __MODE_T_TYPE __U32_TYPE
#define __NLINK_T_TYPE __UWORD_TYPE
#define __OFF_T_TYPE __SLONGWORD_TYPE
#define __OFF64_T_TYPE __SQUAD_TYPE
#define __OFF64_T_TYPE __S64_TYPE
#define __PID_T_TYPE __S32_TYPE
#define __RLIM_T_TYPE __ULONGWORD_TYPE
#define __RLIM64_T_TYPE __UQUAD_TYPE
#define __RLIM64_T_TYPE __U64_TYPE
#define __BLKCNT_T_TYPE __SLONGWORD_TYPE
#define __BLKCNT64_T_TYPE __SQUAD_TYPE
#define __BLKCNT64_T_TYPE __S64_TYPE
#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
#define __FSBLKCNT64_T_TYPE __U64_TYPE
#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
#define __FSFILCNT64_T_TYPE __U64_TYPE
#define __FSWORD_T_TYPE __SWORD_TYPE
#define __ID_T_TYPE __U32_TYPE
#define __CLOCK_T_TYPE __SLONGWORD_TYPE
#define __TIME_T_TYPE __SLONGWORD_TYPE
#define __USECONDS_T_TYPE __U32_TYPE
#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
#define __DADDR_T_TYPE __S32_TYPE
#define __KEY_T_TYPE __S32_TYPE
#define __CLOCKID_T_TYPE __S32_TYPE
#define __TIMER_T_TYPE void *
@@ -60,6 +59,7 @@
#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
#define __CPU_MASK_TYPE __ULONGWORD_TYPE
#define __REGISTER_T_TYPE __SWORD_TYPE
#ifdef __LP64__
/* Tell the libc code that off_t and off64_t are actually the same type
+34
View File
@@ -0,0 +1,34 @@
/* Copyright (C) 2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
/* This header is internal to glibc and should not be included outside
of glibc headers. It is included by each header that needs to make
global declarations that may or may not already have been made by a
header provided by the underlying operating system kernel. All such
declarations are associated with macros named __UAPI_DEF_something,
which have three possible values:
If __UAPI_DEF_FOO is not defined, nobody has yet declared `foo'.
If __UAPI_DEF_FOO is defined to 0, glibc's headers have declared `foo'.
If __UAPI_DEF_FOO is defined to 1, the kernel's headers have declared `foo`.
This header cannot have a multiple-inclusion guard, because it needs
to recheck for additional declarations by kernel headers each time
a glibc header that uses it is included.
This generic version of uapi-compat.h is used on operating systems
where none of the above coordination is necessary. */
@@ -21,8 +21,8 @@
use of struct sigcontext does not conform to POSIX namespace
requirements. */
#ifndef _SYS_UCONTEXT_H
#define _SYS_UCONTEXT_H 1
#ifndef _BITS_UCONTEXT_H
#define _BITS_UCONTEXT_H 1
#include <features.h>
@@ -51,4 +51,4 @@ typedef struct ucontext_t
#undef __ctx
#endif /* sys/ucontext.h */
#endif /* bits/ucontext.h */
+20 -12
View File
@@ -16,13 +16,13 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _BITS_UTMP_H
#define _BITS_UTMP_H 1
#ifndef _UTMP_H
# error "Never include <bits/utmp.h> directly; use <utmp.h> instead."
#endif
#include <paths.h>
#include <sys/time.h>
#include <sys/types.h>
#include <bits/wordsize.h>
@@ -36,7 +36,7 @@
struct lastlog
{
#if __WORDSIZE_TIME64_COMPAT32
int32_t ll_time;
__int32_t ll_time;
#else
__time_t ll_time;
#endif
@@ -69,23 +69,29 @@ struct utmp
__attribute_nonstring__; /* Hostname for remote login. */
struct exit_status ut_exit; /* Exit status of a process marked
as DEAD_PROCESS. */
/* The ut_session and ut_tv fields must be the same size when compiled
32- and 64-bit. This allows data files and shared memory to be
shared between 32- and 64-bit applications. */
shared between 32- and 64-bit applications. Even on 64-bit systems,
struct timeval is not guaranteed to have both fields be 64 bits. */
#if __WORDSIZE_TIME64_COMPAT32
int32_t ut_session; /* Session ID, used for windowing. */
__int32_t ut_session; /* Session ID, used for windowing. */
struct
{
int32_t tv_sec; /* Seconds. */
int32_t tv_usec; /* Microseconds. */
__int32_t tv_sec; /* Seconds. */
__int32_t tv_usec; /* Microseconds. */
} ut_tv; /* Time entry was made. */
#else
long int ut_session; /* Session ID, used for windowing. */
struct timeval ut_tv; /* Time entry was made. */
__int64_t ut_session; /* Session ID, used for windowing. */
struct
{
__int64_t tv_sec; /* Seconds. */
__int64_t tv_usec; /* Microseconds. */
} ut_tv; /* Time entry was made. */
#endif
int32_t ut_addr_v6[4]; /* Internet address of remote host. */
char __glibc_reserved[20]; /* Reserved for future use. */
__int32_t ut_addr_v6[4]; /* Internet address of remote host. */
char __glibc_reserved[20]; /* Reserved for future use. */
};
/* Backwards compatibility hacks. */
@@ -125,3 +131,5 @@ struct utmp
#define _HAVE_UT_ID 1
#define _HAVE_UT_TV 1
#define _HAVE_UT_HOST 1
#endif /* bits/utmp.h */
+16 -17
View File
@@ -16,22 +16,13 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#ifndef _BITS_UTMPX_H
#define _BITS_UTMPX_H 1
#ifndef _UTMPX_H
# error "Never include <bits/utmpx.h> directly; use <utmpx.h> instead."
#endif
#include <bits/types.h>
#include <sys/time.h>
#include <bits/wordsize.h>
#ifdef __USE_GNU
# include <paths.h>
# define _PATH_UTMPX _PATH_UTMP
# define _PATH_WTMPX _PATH_WTMP
#endif
#define __UT_LINESIZE 32
#define __UT_NAMESIZE 32
#define __UT_HOSTSIZE 256
@@ -67,9 +58,10 @@ struct utmpx
struct __exit_status ut_exit; /* Exit status of a process marked
as DEAD_PROCESS. */
/* The fields ut_session and ut_tv must be the same size when compiled
32- and 64-bit. This allows files and shared memory to be shared
between 32- and 64-bit applications. */
/* The ut_session and ut_tv fields must be the same size when compiled
32- and 64-bit. This allows data files and shared memory to be
shared between 32- and 64-bit applications. Even on 64-bit systems,
struct timeval is not guaranteed to have both fields be 64 bits. */
#if __WORDSIZE_TIME64_COMPAT32
__int32_t ut_session; /* Session ID, used for windowing. */
struct
@@ -78,9 +70,14 @@ struct utmpx
__int32_t tv_usec; /* Microseconds. */
} ut_tv; /* Time entry was made. */
#else
long int ut_session; /* Session ID, used for windowing. */
struct timeval ut_tv; /* Time entry was made. */
__int64_t ut_session; /* Session ID, used for windowing. */
struct
{
__int64_t tv_sec; /* Seconds. */
__int64_t tv_usec; /* Microseconds. */
} ut_tv; /* Time entry was made. */
#endif
__int32_t ut_addr_v6[4]; /* Internet address of remote host. */
char __glibc_reserved[20]; /* Reserved for future use. */
};
@@ -104,3 +101,5 @@ struct utmpx
#ifdef __USE_GNU
# define ACCOUNTING 9 /* System accounting. */
#endif
#endif /* bits/utmpx.h */
+1 -1
View File
@@ -1,6 +1,6 @@
#if !defined ISO && !defined ISO99 && !defined ISO11
#ifdef POSIX
# define size_t __size_t
# define size_t __gsize_t
#endif
type glob_t
+1 -1
View File
@@ -41,7 +41,7 @@ type fpos_t
#if !defined ISO && !defined ISO99 && !defined ISO11 && !defined POSIX
type va_list
#else
#define va_list __gnuc_va_list
#define va_list __va_list
#endif
type size_t
#if defined XOPEN2K8 || defined POSIX2008
+1
View File
@@ -2,6 +2,7 @@
#ifdef POSIX
# define pid_t __pid_t
#endif
#define uid_t __uid_t
constant WNOHANG
constant WUNTRACED
+6 -6
View File
@@ -59,17 +59,17 @@ function wint_t towlower (wint_t)
function wint_t towupper (wint_t)
# endif
function wint_t ungetwc (wint_t, FILE*)
function int vfwprintf (FILE*, const wchar_t*, __gnuc_va_list)
function int vfwprintf (FILE*, const wchar_t*, __va_list)
# ifndef UNIX98
function int vfwscanf (FILE*, const wchar_t*, __gnuc_va_list)
function int vfwscanf (FILE*, const wchar_t*, __va_list)
# endif
function int vwprintf (const wchar_t*, __gnuc_va_list)
function int vwprintf (const wchar_t*, __va_list)
# ifndef UNIX98
function int vwscanf (const wchar_t*, __gnuc_va_list)
function int vwscanf (const wchar_t*, __va_list)
# endif
function int vswprintf (wchar_t*, size_t, const wchar_t*, __gnuc_va_list)
function int vswprintf (wchar_t*, size_t, const wchar_t*, __va_list)
# ifndef UNIX98
function int vswscanf (const wchar_t*, const wchar_t*, __gnuc_va_list)
function int vswscanf (const wchar_t*, const wchar_t*, __va_list)
# endif
# if defined XOPEN2K8 || defined POSIX2008
function {wchar_t*} wcpcpy (wchar_t*, const wchar_t*)
+1
View File
@@ -30,6 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include <wchar.h>
#include <sys/poll.h>
-2
View File
@@ -17,8 +17,6 @@
<https://www.gnu.org/licenses/>. */
#include <wchar.h>
#define __need_ptrdiff_t
#include <stddef.h>
+4 -13
View File
@@ -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
@@ -241,8 +233,7 @@ extern int dirfd (DIR *__dirp) __THROW __nonnull ((1));
# endif
# endif
# define __need_size_t
# include <stddef.h>
# include <bits/types/size_t.h>
/* Scan the directory DIR, calling SELECTOR on each directory entry.
Entries for which SELECT returns nonzero are individually malloc'd,
+2 -2
View File
@@ -20,8 +20,8 @@
#define _DLFCN_H 1
#include <features.h>
#define __need_size_t
#include <stddef.h>
#include <bits/types/size_t.h>
/* Collect various system dependent definitions and declarations. */
#include <bits/dlfcn.h>
+7 -8
View File
@@ -71,7 +71,7 @@ _dl_map_segments (struct link_map *l, int fd,
handle the portion of the segment past the end of the file
mapping. */
if (__glibc_unlikely
(__mprotect ((caddr_t) (l->l_addr + c->mapend),
(__mprotect ((void *) (l->l_addr + c->mapend),
loadcmds[nloadcmds - 1].mapstart - c->mapend,
PROT_NONE) < 0))
return DL_MAP_SEGMENTS_ERROR_MPROTECT;
@@ -123,22 +123,21 @@ _dl_map_segments (struct link_map *l, int fd,
if (__glibc_unlikely ((c->prot & PROT_WRITE) == 0))
{
/* Dag nab it. */
if (__mprotect ((caddr_t) (zero
& ~(GLRO(dl_pagesize) - 1)),
GLRO(dl_pagesize), c->prot|PROT_WRITE) < 0)
return DL_MAP_SEGMENTS_ERROR_MPROTECT;
if (__mprotect ((void *) (zero & ~(GLRO(dl_pagesize) - 1)),
GLRO(dl_pagesize), c->prot|PROT_WRITE) < 0)
return DL_MAP_SEGMENTS_ERROR_MPROTECT;
}
memset ((void *) zero, '\0', zeropage - zero);
if (__glibc_unlikely ((c->prot & PROT_WRITE) == 0))
__mprotect ((caddr_t) (zero & ~(GLRO(dl_pagesize) - 1)),
__mprotect ((void *) (zero & ~(GLRO(dl_pagesize) - 1)),
GLRO(dl_pagesize), c->prot);
}
if (zeroend > zeropage)
{
/* Map the remaining zero pages in from the zero fill FD. */
caddr_t mapat;
mapat = __mmap ((caddr_t) zeropage, zeroend - zeropage,
char *mapat;
mapat = __mmap ((void *) zeropage, zeroend - zeropage,
c->prot, MAP_ANON|MAP_PRIVATE|MAP_FIXED,
-1, 0);
if (__glibc_unlikely (mapat == MAP_FAILED))
+1 -1
View File
@@ -65,7 +65,7 @@ malloc (size_t n)
{
/* Insufficient space left; allocate another page plus one extra
page to reduce number of mmap calls. */
caddr_t page;
char *page;
size_t nup = (n + GLRO(dl_pagesize) - 1) & ~(GLRO(dl_pagesize) - 1);
if (__glibc_unlikely (nup == 0 && n != 0))
return NULL;
+2 -2
View File
@@ -148,7 +148,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
{
struct textrels
{
caddr_t start;
char *start;
size_t len;
int prot;
struct textrels *next;
@@ -198,7 +198,7 @@ _dl_relocate_object (struct link_map *l, struct r_scope_elem *scope[],
newp->len = ALIGN_UP (ph->p_vaddr + ph->p_memsz, GLRO(dl_pagesize))
- ALIGN_DOWN (ph->p_vaddr, GLRO(dl_pagesize));
newp->start = PTR_ALIGN_DOWN (ph->p_vaddr, GLRO(dl_pagesize))
+ (caddr_t) l->l_addr;
+ (char *) l->l_addr;
newp->prot = 0;
if (ph->p_flags & PF_R)
+1 -1
View File
@@ -23,7 +23,6 @@
#include <features.h>
#include <elf.h>
#include <dlfcn.h>
#include <sys/types.h>
/* We use this macro to refer to ELF types independent of the native wordsize.
`ElfW(TYPE)' is used in place of `Elf32_TYPE' or `Elf64_TYPE'. */
@@ -31,6 +30,7 @@
#define _ElfW(e,w,t) _ElfW_1 (e, w, _##t)
#define _ElfW_1(e,w,t) e##w##t
#include <bits/types/size_t.h>
#include <bits/elfclass.h> /* Defines __ELF_NATIVE_CLASS. */
#include <bits/link.h>
-2
View File
@@ -34,8 +34,6 @@
#include <features.h>
#include <sys/types.h>
/*
* See gmon_out.h for gmon.out format.
*/
+2 -2
View File
@@ -20,8 +20,8 @@
#include <features.h>
#include <sys/time.h>
#include <sys/types.h>
#include <bits/types/size_t.h>
#include <bits/types/struct_timeval.h>
/* This interface is intended to follow the sprofil() system calls as
described by the sprofil(2) man page of Irix v6.5, except that:
+1
View File
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/profil.h>
#include <sys/time.h>
#include <bits/wordsize.h>
+3 -10
View File
@@ -27,15 +27,11 @@
__BEGIN_DECLS
#include <bits/types.h>
#define __need_size_t
#include <stddef.h>
#include <bits/types/size_t.h>
/* For the Single Unix specification we must define this type here. */
#if (defined __USE_XOPEN || defined __USE_XOPEN2K) && !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. */
@@ -169,9 +165,6 @@ extern int fgetgrent_r (FILE *__restrict __stream,
#ifdef __USE_MISC
# define __need_size_t
# include <stddef.h>
/* Set the group set for the current user to GROUPS (N of them). */
extern int setgroups (size_t __n, const __gid_t *__groups) __THROW;
+1
View File
@@ -19,6 +19,7 @@
#include <errno.h>
#include <grp.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+1 -3
View File
@@ -23,9 +23,7 @@
#include <features.h>
#include <paths.h>
#include <bits/types/FILE.h>
#define __need_size_t
#include <stddef.h>
#include <bits/types/size_t.h>
/* Path to the user database files. */
#define GSHADOW _PATH_GSHADOW
+1 -1
View File
@@ -90,7 +90,7 @@ CFLAGS-hurdstartup.o = $(no-stack-protector)
CFLAGS-RPC_exec_startup_get_info.o = $(no-stack-protector)
# Make generated headers compatible with all support standards
migheaderpipe := | sed -e 's/\<ino64_t\>/__ino64_t/' -e 's/\<loff_t\>/__loff_t/'
migheaderpipe := | sed -e 's/\<ino64_t\>/__ino64_t/' -e 's/\<loff_t\>/__off64_t/'
include ../mach/Machrules
include ../Rules
+1 -1
View File
@@ -22,7 +22,7 @@
#include <string.h>
error_t
_hurd_fd_read (struct hurd_fd *fd, void *buf, size_t *nbytes, loff_t offset)
_hurd_fd_read (struct hurd_fd *fd, void *buf, size_t *nbytes, off64_t offset)
{
error_t err;
char *data;
+1 -1
View File
@@ -23,7 +23,7 @@
error_t
_hurd_fd_write (struct hurd_fd *fd,
const void *buf, size_t *nbytes, loff_t offset)
const void *buf, size_t *nbytes, off64_t offset)
{
error_t err;
mach_msg_type_number_t wrote;
+4 -2
View File
@@ -255,9 +255,11 @@ extern error_t _hurd_fd_close (struct hurd_fd *fd);
If successful, stores the amount actually read or written in *NBYTES. */
extern error_t _hurd_fd_read (struct hurd_fd *fd,
void *buf, size_t *nbytes, __loff_t offset);
void *buf, size_t *nbytes,
__off64_t offset);
extern error_t _hurd_fd_write (struct hurd_fd *fd,
const void *buf, size_t *nbytes, __loff_t offset);
const void *buf, size_t *nbytes,
__off64_t offset);
/* Call *RPC on PORT and/or CTTY; if a call on CTTY returns EBACKGROUND,
-2
View File
@@ -19,8 +19,6 @@
#ifndef _HURD_IOCTL_H
#define _HURD_IOCTL_H 1
#define __need___va_list
#include <stdarg.h>
#include <bits/ioctls.h>
#include <mach/port.h>
+6 -9
View File
@@ -21,10 +21,6 @@
#define _HURD_SIGNAL_H 1
#include <features.h>
#define __need_size_t
#define __need_NULL
#include <stddef.h>
#include <mach/mach_types.h>
#include <mach/port.h>
#include <mach/message.h>
@@ -34,6 +30,7 @@
#include <bits/types/error_t.h>
#include <bits/types/stack_t.h>
#include <bits/types/sigset_t.h>
#include <bits/types/size_t.h>
#include <bits/sigaction.h>
#include <hurd/msg.h>
@@ -164,7 +161,7 @@ extern void _hurd_sigstate_delete (thread_t thread);
_HURD_SIGNAL_H_EXTERN_INLINE struct hurd_sigstate *
_hurd_self_sigstate (void)
{
if (THREAD_SELF->_hurd_sigstate == NULL)
if (! THREAD_SELF->_hurd_sigstate)
THREAD_SELF->_hurd_sigstate = _hurd_thread_sigstate (__mach_thread_self ());
return THREAD_SELF->_hurd_sigstate;
}
@@ -207,11 +204,11 @@ _hurd_critical_section_lock (void)
#ifdef __LIBC_NO_TLS
if (__LIBC_NO_TLS ())
/* TLS is currently initializing, no need to enter critical section. */
return NULL;
return 0;
#endif
ss = THREAD_SELF->_hurd_sigstate;
if (ss == NULL)
if (! ss)
{
/* The thread variable is unset; this must be the first time we've
asked for it. In this case, the critical section flag cannot
@@ -222,7 +219,7 @@ _hurd_critical_section_lock (void)
if (! __spin_try_lock (&ss->critical_section_lock))
/* We are already in a critical section, so do nothing. */
return NULL;
return 0;
/* With the critical section lock held no signal handler will run.
Return our sigstate pointer; this will be passed to
@@ -239,7 +236,7 @@ extern void _hurd_critical_section_unlock (void *our_lock);
_HURD_SIGNAL_H_EXTERN_INLINE void
_hurd_critical_section_unlock (void *our_lock)
{
if (our_lock == NULL)
if (! our_lock)
/* The critical section lock was held when we began. Do nothing. */
return;
else
+1 -2
View File
@@ -19,8 +19,7 @@
#ifndef _HURD_SIGPREEMPT_H
#define _HURD_SIGPREEMPT_H 1
#define __need_size_t
#include <stddef.h>
#include <bits/types/size_t.h>
#include <errno.h>
#include <bits/types/error_t.h>
#include <signal.h> /* For sighandler_t, SIG_ERR. */
+7 -11
View File
@@ -17,20 +17,16 @@
<https://www.gnu.org/licenses/>. */
#ifndef _HURD_USERLINK_H
#define _HURD_USERLINK_H 1
#include <features.h>
#define __need_NULL
#include <stddef.h>
#include <features.h>
#include <setjmp.h>
#if defined __USE_EXTERN_INLINES && defined _LIBC
# if IS_IN (libc)
# include <hurd/signal.h>
# endif
#endif
#include <setjmp.h>
/* This structure records a link in two doubly-linked lists.
We call these the per-resource user list and the per-thread
@@ -156,11 +152,11 @@ _hurd_userlink_move (struct hurd_userlink *new_link,
{
*new_link = *link;
if (new_link->resource.next != NULL)
if (new_link->resource.next)
new_link->resource.next->resource.prevp = &new_link->resource.next;
*new_link->resource.prevp = new_link;
if (new_link->thread.next != NULL)
if (new_link->thread.next)
new_link->thread.next->thread.prevp = &new_link->thread.next;
*new_link->thread.prevp = new_link;
}
@@ -180,13 +176,13 @@ extern int _hurd_userlink_clear (struct hurd_userlink **chainp);
_HURD_USERLINK_H_EXTERN_INLINE int
_hurd_userlink_clear (struct hurd_userlink **chainp)
{
if (*chainp == NULL)
if (! *chainp)
return 1;
/* Detach the chain of current users from the cell. The last user to
remove his link from that chain will deallocate the old resource. */
(*chainp)->resource.prevp = NULL;
*chainp = NULL;
(*chainp)->resource.prevp = 0;
*chainp = 0;
return 0;
}
# endif
+2 -4
View File
@@ -24,12 +24,10 @@
#include <features.h>
#include <bits/types/__mbstate_t.h>
#include <bits/types/size_t.h>
#include <bits/types/wchar_t.h>
#include <bits/types/wint_t.h>
#define __need_size_t
#define __need_wchar_t
#include <stddef.h>
/* ISO 10646 value used to signal invalid value. */
#define __UNKNOWN_10646_CHAR ((wchar_t) 0xfffd)
+1 -2
View File
@@ -19,8 +19,7 @@
#define _ICONV_H 1
#include <features.h>
#define __need_size_t
#include <stddef.h>
#include <bits/types/size_t.h>
__BEGIN_DECLS
-1
View File
@@ -54,7 +54,6 @@
#include <string.h>
#include <wchar.h>
#include <sys/param.h> /* For MIN. */
#define __need_size_t
#include <stddef.h>
#include <libc-diag.h>
-2
View File
@@ -140,8 +140,6 @@
#include <assert.h>
#include <iconv/gconv_int.h>
#include <string.h>
#define __need_size_t
#define __need_NULL
#include <stddef.h>
#ifndef STATIC_GCONV
+1
View File
@@ -0,0 +1 @@
#include <stdlib/bits/NULL.h>
+1
View File
@@ -0,0 +1 @@
#include <string/bits/strings_x2k8.h>
+1
View File
@@ -0,0 +1 @@
#include <stdlib/bits/types/__va_list.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/blkcnt64_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/blkcnt_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/blksize_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/caddr_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/daddr_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/dev_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/fsblkcnt64_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/fsblkcnt_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/fsfilcnt64_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/fsfilcnt_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/fsid_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/gid_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/id_t.h>
+1
View File
@@ -0,0 +1 @@
#include <inet/bits/types/in_addr_t.h>
+1
View File
@@ -0,0 +1 @@
#include <inet/bits/types/in_port_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/ino64_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/ino_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/intptr_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/key_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/loff_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/mode_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/nlink_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/off64_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/off_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/pid_t.h>
+1
View File
@@ -0,0 +1 @@
#include <stdlib/bits/types/ptrdiff_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/register_t.h>
+1
View File
@@ -0,0 +1 @@
#include <stdlib/bits/types/size_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/socklen_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/ssize_t.h>
+1
View File
@@ -0,0 +1 @@
#include <inet/bits/types/struct_in6_addr.h>
+1
View File
@@ -0,0 +1 @@
#include <inet/bits/types/struct_in_addr.h>
+1
View File
@@ -0,0 +1 @@
#include <socket/bits/types/struct_linger.h>
+1
View File
@@ -0,0 +1 @@
#include <socket/bits/types/struct_sockaddr.h>
+1
View File
@@ -0,0 +1 @@
#include <inet/bits/types/struct_sockaddr_in.h>
+1
View File
@@ -0,0 +1 @@
#include <inet/bits/types/struct_sockaddr_in6.h>
@@ -0,0 +1 @@
#include <socket/bits/types/struct_sockaddr_storage.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/suseconds_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/u_int.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/u_intN_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/uid_t.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/uint.h>
+1
View File
@@ -0,0 +1 @@
#include <posix/bits/types/useconds_t.h>
+1
View File
@@ -0,0 +1 @@
#include <stdlib/bits/types/va_list.h>
+1
View File
@@ -0,0 +1 @@
#include <stdlib/bits/types/wchar_t.h>
+1 -148
View File
@@ -1,148 +1 @@
/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
/*
* Never include this file directly; use <limits.h> instead.
*/
/* Additional definitions from X/Open Portability Guide, Issue 4, Version 2
System Interfaces and Headers, 4.16 <limits.h>
Please note only the values which are not greater than the minimum
stated in the standard document are listed. The `sysconf' functions
should be used to obtain the actual value. */
#ifndef _XOPEN_LIM_H
#define _XOPEN_LIM_H 1
/* We do not provide fixed values for
ARG_MAX Maximum length of argument to the `exec' function
including environment data.
ATEXIT_MAX Maximum number of functions that may be registered
with `atexit'.
CHILD_MAX Maximum number of simultaneous processes per real
user ID.
OPEN_MAX Maximum number of files that one process can have open
at anyone time.
PAGESIZE
PAGE_SIZE Size of bytes of a page.
PASS_MAX Maximum number of significant bytes in a password.
We only provide a fixed limit for
IOV_MAX Maximum number of `iovec' structures that one process has
available for use with `readv' or writev'.
if this is indeed fixed by the underlying system.
*/
/* Maximum number of `iovec' structures that may be used in a single call
to `readv', `writev', etc. */
#define _XOPEN_IOV_MAX _POSIX_UIO_MAXIOV
#include <bits/uio_lim.h>
#ifdef __IOV_MAX
# define IOV_MAX __IOV_MAX
#else
# undef IOV_MAX
#endif
/* Maximum value of `digit' in calls to the `printf' and `scanf'
functions. We have no limit, so return a reasonable value. */
#define NL_ARGMAX _POSIX_ARG_MAX
/* Maximum number of bytes in a `LANG' name. We have no limit. */
#define NL_LANGMAX _POSIX2_LINE_MAX
/* Maximum message number. We have no limit. */
#define NL_MSGMAX INT_MAX
/* Maximum number of bytes in N-to-1 collation mapping. We have no
limit. */
#if defined __USE_GNU || !defined __USE_XOPEN2K8
# define NL_NMAX INT_MAX
#endif
/* Maximum set number. We have no limit. */
#define NL_SETMAX INT_MAX
/* Maximum number of bytes in a message. We have no limit. */
#define NL_TEXTMAX INT_MAX
/* Default process priority. */
#define NZERO 20
/* Number of bits in a word of type `int'. */
#ifdef INT_MAX
# if INT_MAX == 32767
# define WORD_BIT 16
# else
# if INT_MAX == 2147483647
# define WORD_BIT 32
# else
/* Safe assumption. */
# define WORD_BIT 64
# endif
# endif
#elif defined __INT_MAX__
# if __INT_MAX__ == 32767
# define WORD_BIT 16
# else
# if __INT_MAX__ == 2147483647
# define WORD_BIT 32
# else
/* Safe assumption. */
# define WORD_BIT 64
# endif
# endif
#else
# define WORD_BIT 32
#endif
/* Number of bits in a word of type `long int'. */
#ifdef LONG_MAX
# if LONG_MAX == 2147483647
# define LONG_BIT 32
# else
/* Safe assumption. */
# define LONG_BIT 64
# endif
#elif defined __LONG_MAX__
# if __LONG_MAX__ == 2147483647
# define LONG_BIT 32
# else
/* Safe assumption. */
# define LONG_BIT 64
# endif
#else
# include <bits/wordsize.h>
# if __WORDSIZE == 64
# define LONG_BIT 64
# else
# define LONG_BIT 32
# endif
#endif
#endif /* bits/xopen_lim.h */
#include <misc/bits/xopen_lim.h>

Some files were not shown because too many files have changed in this diff Show More