glibc:zack/no-nested-includes

Last commit made on 2020-01-08
Get this branch:
git clone -b zack/no-nested-includes https://git.launchpad.net/glibc

Branch merges

Branch information

Name:
zack/no-nested-includes
Repository:
lp:glibc

Recent commits

536eef5... by Zack Weinberg on 2019-06-11

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.

9e32bbc... by Zack Weinberg on 2019-06-10

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.

94ab7b6... by Zack Weinberg on 2019-06-06

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.

0e8caaf... by Zack Weinberg on 2019-06-01

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.

b32c5f3... by Zack Weinberg on 2019-05-21

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.

886864a... by Zack Weinberg on 2019-05-31

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.

225a0f4... by Zack Weinberg on 2019-05-22

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.

39906a3... by Zack Weinberg on 2019-06-10

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.

ff9bae2... by Zack Weinberg on 2019-03-16

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.

7e2c24f... by Zack Weinberg on 2019-03-17

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.