<feed xmlns='http://www.w3.org/2005/Atom'>
<title>glibc.git/socket, branch zack/no-nested-includes</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/'/>
<entry>
<title>Minimize inclusion of netinet/in.h from public headers.</title>
<updated>2020-01-08T19:15:42+00:00</updated>
<author>
<name>Zack Weinberg</name>
<email>zackw@panix.com</email>
</author>
<published>2019-06-10T13:07:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=9e32bbc2da1644f4ec9c1428faf98ed6ad508e4a'/>
<id>9e32bbc2da1644f4ec9c1428faf98ed6ad508e4a</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>Don’t include sys/socket.h from public headers.</title>
<updated>2020-01-08T19:15:42+00:00</updated>
<author>
<name>Zack Weinberg</name>
<email>zackw@panix.com</email>
</author>
<published>2019-06-06T13:49:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=94ab7b6b7f5b7f424554e325c20f60f706efc207'/>
<id>94ab7b6b7f5b7f424554e325c20f60f706efc207</id>
<content type='text'>
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 &lt;sys/socket.h&gt;`
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt;sys/socket.h&gt;`
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>Don’t include sys/types.h or stdint.h from most public headers.</title>
<updated>2020-01-08T19:15:36+00:00</updated>
<author>
<name>Zack Weinberg</name>
<email>zackw@panix.com</email>
</author>
<published>2019-05-21T23:05:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=b32c5f35b8fb037bd54cde10bb14e6510171534a'/>
<id>b32c5f35b8fb037bd54cde10bb14e6510171534a</id>
<content type='text'>
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 &lt;bits/stdint-uintn.h&gt;).

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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt;bits/stdint-uintn.h&gt;).

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.
</pre>
</div>
</content>
</entry>
<entry>
<title>Don’t include string.h from sys/un.h.</title>
<updated>2020-01-08T18:45:45+00:00</updated>
<author>
<name>Zack Weinberg</name>
<email>zackw@panix.com</email>
</author>
<published>2019-05-22T16:03:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=225a0f4ef94a6505f2bb28d44d85bb3a9a45e5ef'/>
<id>225a0f4ef94a6505f2bb28d44d85bb3a9a45e5ef</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>Don’t include sys/select.h from sys/types.h.</title>
<updated>2020-01-08T18:45:44+00:00</updated>
<author>
<name>Zack Weinberg</name>
<email>zackw@panix.com</email>
</author>
<published>2019-03-16T16:35:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=ff9bae2f92e83e9655abd8b32021b0d6407ef560'/>
<id>ff9bae2f92e83e9655abd8b32021b0d6407ef560</id>
<content type='text'>
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 -&gt; sys/select.h.  Adjust commentary re
	sys/time.h -&gt; 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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 -&gt; sys/select.h.  Adjust commentary re
	sys/time.h -&gt; 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.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add bits/types/ wrappers for stddef.h and stdarg.h types.</title>
<updated>2020-01-08T18:41:32+00:00</updated>
<author>
<name>Zack Weinberg</name>
<email>zackw@panix.com</email>
</author>
<published>2019-05-28T17:59:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=cb54252075282ed6ed171a5b0d8eb372c2b06522'/>
<id>cb54252075282ed6ed171a5b0d8eb372c2b06522</id>
<content type='text'>
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 &lt;stddef.h&gt;

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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt;stddef.h&gt;

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.
</pre>
</div>
</content>
</entry>
<entry>
<title>Don’t include sys/cdefs.h directly from public headers.</title>
<updated>2020-01-08T18:04:44+00:00</updated>
<author>
<name>Zack Weinberg</name>
<email>zackw@panix.com</email>
</author>
<published>2019-06-18T15:47:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=afaa4fe717db9f4106570665f5db0cd45684b96a'/>
<id>afaa4fe717db9f4106570665f5db0cd45684b96a</id>
<content type='text'>
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 &lt;glob.h&gt;
    #include &lt;stddef.h&gt;
    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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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 &lt;glob.h&gt;
    #include &lt;stddef.h&gt;
    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.
</pre>
</div>
</content>
</entry>
<entry>
<title>Update copyright dates with scripts/update-copyrights.</title>
<updated>2020-01-01T00:14:33+00:00</updated>
<author>
<name>Joseph Myers</name>
<email>joseph@codesourcery.com</email>
</author>
<published>2020-01-01T00:14:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=d614a7539657941a9201c236b2f15afac18e1213'/>
<id>d614a7539657941a9201c236b2f15afac18e1213</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Prefer https to http for gnu.org and fsf.org URLs</title>
<updated>2019-09-07T09:43:31+00:00</updated>
<author>
<name>Paul Eggert</name>
<email>eggert@cs.ucla.edu</email>
</author>
<published>2019-09-07T05:40:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=5a82c74822d3272df2f5929133680478c0cfb4bd'/>
<id>5a82c74822d3272df2f5929133680478c0cfb4bd</id>
<content type='text'>
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:

sed -ri '
  s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
  s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
  $(find $(git ls-files) -prune -type f \
      ! -name '*.po' \
      ! -name 'ChangeLog*' \
      ! -path COPYING ! -path COPYING.LIB \
      ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
      ! -path manual/texinfo.tex ! -path scripts/config.guess \
      ! -path scripts/config.sub ! -path scripts/install-sh \
      ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
      ! -path INSTALL ! -path  locale/programs/charmap-kw.h \
      ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
      ! '(' -name configure \
            -execdir test -f configure.ac -o -f configure.in ';' ')' \
      ! '(' -name preconfigure \
            -execdir test -f preconfigure.ac ';' ')' \
      -print)

and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:

  chmod a+x sysdeps/unix/sysv/linux/riscv/configure
  # Omit irrelevant whitespace and comment-only changes,
  # perhaps from a slightly-different Autoconf version.
  git checkout -f \
    sysdeps/csky/configure \
    sysdeps/hppa/configure \
    sysdeps/riscv/configure \
    sysdeps/unix/sysv/linux/csky/configure
  # Omit changes that caused a pre-commit check to fail like this:
  # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
  git checkout -f \
    sysdeps/powerpc/powerpc64/ppc-mcount.S \
    sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
  # Omit change that caused a pre-commit check to fail like this:
  # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
  git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:

sed -ri '
  s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
  s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
  $(find $(git ls-files) -prune -type f \
      ! -name '*.po' \
      ! -name 'ChangeLog*' \
      ! -path COPYING ! -path COPYING.LIB \
      ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
      ! -path manual/texinfo.tex ! -path scripts/config.guess \
      ! -path scripts/config.sub ! -path scripts/install-sh \
      ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
      ! -path INSTALL ! -path  locale/programs/charmap-kw.h \
      ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
      ! '(' -name configure \
            -execdir test -f configure.ac -o -f configure.in ';' ')' \
      ! '(' -name preconfigure \
            -execdir test -f preconfigure.ac ';' ')' \
      -print)

and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:

  chmod a+x sysdeps/unix/sysv/linux/riscv/configure
  # Omit irrelevant whitespace and comment-only changes,
  # perhaps from a slightly-different Autoconf version.
  git checkout -f \
    sysdeps/csky/configure \
    sysdeps/hppa/configure \
    sysdeps/riscv/configure \
    sysdeps/unix/sysv/linux/csky/configure
  # Omit changes that caused a pre-commit check to fail like this:
  # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
  git checkout -f \
    sysdeps/powerpc/powerpc64/ppc-mcount.S \
    sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
  # Omit change that caused a pre-commit check to fail like this:
  # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
  git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix a few typos in comments</title>
<updated>2019-01-12T13:44:51+00:00</updated>
<author>
<name>Dmitry V. Levin</name>
<email>ldv@altlinux.org</email>
</author>
<published>2019-01-12T13:44:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=a1b02ae763bff6457cddf08d1e453d103b5d6259'/>
<id>a1b02ae763bff6457cddf08d1e453d103b5d6259</id>
<content type='text'>
Apply the following spelling fixes:
$ git grep -F -l 'relevent' |
  xargs sed -i 's/relevent/relevant/g'
$ git grep -F -l 'checked fot' |
  xargs sed -i 's/checked fot/checked for/g'
$ git grep -F -l "could't" |
  xargs sed -i "s/could't/couldn't/g"
$ git grep -F -l 'wheter' | grep -Fv ChangeLog.old |
  xargs sed -i 's/wheter/whether/g'
$ git grep -F -l 'neccessary' | grep -Fv ChangeLog.old |
  xargs sed -i 's/neccessary/necessary/g'
$ git grep -F -l 'ouput' |
  xargs sed -i 's/ouput/output/g'
$ git grep -F -w -l 'iput' |
  xargs sed -i 's/iput/input/g'

This is inspired by a gnulib bug report at
https://lists.gnu.org/archive/html/bug-gnulib/2019-01/msg00081.html

* argp/argp-help.c: Fix typo in comment.
* misc/sys/cdefs.h: Likewise.
* posix/regexec.c (sift_states_iter_mb): Likewise.
* socket/sockatmark.c: Likewise.
* socket/sys/socket.h: Likewise.
* sysdeps/ia64/fpu/libm_sincos_large.S: Likewise.
* sysdeps/ia64/fpu/libm_sincosl.S: Likewise.
* sysdeps/ia64/fpu/s_cosl.S: Likewise.
* sysdeps/ieee754/dbl-64/k_rem_pio2.c: Likewise.
* sysdeps/unix/sockatmark.c: Likewise.
* time/strptime_l.c: Likewise.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Apply the following spelling fixes:
$ git grep -F -l 'relevent' |
  xargs sed -i 's/relevent/relevant/g'
$ git grep -F -l 'checked fot' |
  xargs sed -i 's/checked fot/checked for/g'
$ git grep -F -l "could't" |
  xargs sed -i "s/could't/couldn't/g"
$ git grep -F -l 'wheter' | grep -Fv ChangeLog.old |
  xargs sed -i 's/wheter/whether/g'
$ git grep -F -l 'neccessary' | grep -Fv ChangeLog.old |
  xargs sed -i 's/neccessary/necessary/g'
$ git grep -F -l 'ouput' |
  xargs sed -i 's/ouput/output/g'
$ git grep -F -w -l 'iput' |
  xargs sed -i 's/iput/input/g'

This is inspired by a gnulib bug report at
https://lists.gnu.org/archive/html/bug-gnulib/2019-01/msg00081.html

* argp/argp-help.c: Fix typo in comment.
* misc/sys/cdefs.h: Likewise.
* posix/regexec.c (sift_states_iter_mb): Likewise.
* socket/sockatmark.c: Likewise.
* socket/sys/socket.h: Likewise.
* sysdeps/ia64/fpu/libm_sincos_large.S: Likewise.
* sysdeps/ia64/fpu/libm_sincosl.S: Likewise.
* sysdeps/ia64/fpu/s_cosl.S: Likewise.
* sysdeps/ieee754/dbl-64/k_rem_pio2.c: Likewise.
* sysdeps/unix/sockatmark.c: Likewise.
* time/strptime_l.c: Likewise.
</pre>
</div>
</content>
</entry>
</feed>
