<feed xmlns='http://www.w3.org/2005/Atom'>
<title>glibc.git/inet, 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>Minimize includes of unrelated public headers by networking headers.</title>
<updated>2020-01-08T19:15:41+00:00</updated>
<author>
<name>Zack Weinberg</name>
<email>zackw@panix.com</email>
</author>
<published>2019-06-01T23:32:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=0e8caaf081a844893aa5bbf67010c3e34ca47f34'/>
<id>0e8caaf081a844893aa5bbf67010c3e34ca47f34</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</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>Split up endian.h to minimize exposure of BYTE_ORDER.</title>
<updated>2020-01-08T18:41:26+00:00</updated>
<author>
<name>Zack Weinberg</name>
<email>zackw@panix.com</email>
</author>
<published>2019-03-15T13:02:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=7e51209849daa7183794e8b0870a97de4c38e3ac'/>
<id>7e51209849daa7183794e8b0870a97de4c38e3ac</id>
<content type='text'>
With only two exceptions (sys/types.h and sys/param.h, both of which
historically might have defined BYTE_ORDER) the public headers that
include &lt;endian.h&gt; only want to be able to test __BYTE_ORDER against
__*_ENDIAN.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	* scripts/check-obsolete-constructs.h: Remove most of the
	whitelist entries for endian.h and float.h.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
With only two exceptions (sys/types.h and sys/param.h, both of which
historically might have defined BYTE_ORDER) the public headers that
include &lt;endian.h&gt; only want to be able to test __BYTE_ORDER against
__*_ENDIAN.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	* scripts/check-obsolete-constructs.h: Remove most of the
	whitelist entries for endian.h and float.h.
</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>Create bits/types headers for most remaining __T_defined macros.</title>
<updated>2020-01-08T17:56:32+00:00</updated>
<author>
<name>Zack Weinberg</name>
<email>zackw@panix.com</email>
</author>
<published>2019-03-10T01:54:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=d5ebebf969165c51e6a9fcff3a21b6591269eaea'/>
<id>d5ebebf969165c51e6a9fcff3a21b6591269eaea</id>
<content type='text'>
This doesn't exactly fit the theme but as long as I'm tinkering with
sys/types.h it makes sense to go through and create single-declaration
bits/types/ headers for all of the remaining cases where we have
two or more headers declaring a public type.

The remaining uses of the original __T_defined idiom are:
__error_t_defined in files shared with gnulib, which probably has to
remain as is; ____gwchar_t_defined in inttypes.h, which may not be
necessary anymore and should be addressed separately, and
__ldiv_t_defined and __lldiv_t_defined in stdlib.h, ditto.

Our handling of LFS types is a little inconsistent: some headers
declare both off_t and off64_t (for instance) when
_LARGEFILE64_SOURCE, others will only declare off_t regardless of
_LARGEFILE64_SOURCE.  I don't know if this was intentional or not.
I am tempted to centralize responsibility for _LARGEFILE64_SOURCE as
well as _FILE_OFFSET_BITS=64 in bits/types/off_t.h (etc) so that any
header that declares off_t will automatically also declare off64_t
when _LARGEFILE64_SOURCE.

sunrpc/rpc/types.h is special, because it is included in files
compiled by the *build* compiler (cross-rpcgen-objs), and therefore it
cannot unconditionally assume bits/types headers are available.  What
I did was have it include the appropriate bits/types headers only if
including sys/types.h did not cause __BIT_TYPES_DEFINED__ to be
defined.  This will do the right thing when an installed rpc/types.h
is included by application code compiled without __USE_MISC in effect.
During the build, we rely on the fact that we compile all of our own
code with __USE_MISC in effect.  This is fragile, but should be
acceptable for code that's no longer built by default anyway.

scripts/check-obsolete-constructs.py ensures that only sys/types.h and
rpc/types.h include the bits/types/ headers that define obsolete types.

	* posix/bits/types/blkcnt64_t.h
	* posix/bits/types/blkcnt_t.h
	* posix/bits/types/blksize_t.h
	* posix/bits/types/dev_t.h
	* posix/bits/types/fsblkcnt64_t.h
	* posix/bits/types/fsblkcnt_t.h
	* posix/bits/types/fsfilcnt64_t.h
	* posix/bits/types/fsfilcnt_t.h
	* posix/bits/types/fsid_t.h
	* posix/bits/types/gid_t.h
	* posix/bits/types/id_t.h
	* posix/bits/types/ino64_t.h
	* posix/bits/types/ino_t.h
	* posix/bits/types/intptr_t.h
	* posix/bits/types/key_t.h
	* posix/bits/types/loff_t.h
	* posix/bits/types/mode_t.h
	* posix/bits/types/nlink_t.h
	* posix/bits/types/off64_t.h
	* posix/bits/types/off_t.h
	* posix/bits/types/pid_t.h
	* posix/bits/types/socklen_t.h
	* posix/bits/types/ssize_t.h
	* posix/bits/types/suseconds_t.h
	* posix/bits/types/uid_t.h
	* posix/bits/types/useconds_t.h:
        New single-declaration headers for standard types canonically
	defined by sys/types.h, sys/socket.h, or inttypes.h but also
	exposed by other headers under some circumstances.  Code moved
        from posix/sys/types.h, socket/sys/socket.h, stdlib/inttypes.h
        as appropriate.

	* posix/bits/types/uint.h
	* posix/bits/types/u_int.h
	* posix/bits/types/u_intN_t.h
	* posix/bits/types/caddr_t.h
	* posix/bits/types/daddr_t.h
	* posix/bits/types/loff_t.h
	* posix/bits/types/register_t.h:
        Similarly, but for obsolete BSD-derived types whose canonical
	home is sys/types.h.  Some of these headers define more than
	one type.

        * posix/Makefile (headers): Install the above new headers.
        Rewrap the list.
        * posix/sys/types.h: All definitions of public types now
        accomplished using the above new headers.  Consolidate
        groups of definitions controlled by the same feature
        selection macros.

        * inet/arpa/inet.h, bits/socket.h
        * sysdeps/mach/hurd/bits/socket.h
        * sysdeps/unix/sysv/linux/bits/socket.h:
        Use bits/types/socklen_t.h.

        * dirent/dirent.h: Use bits/types/ino_t.h and bits/types/ino64_t.h.
        * grp/grp.h: Use bits/types/gid_t.h.
        * io/fcntl.h: Use bits/types/mode_t.h, bits/types/off_t.h,
        bits/types/pid_t.h, and bits/types/off64_t.h.
        * io/sys/stat.h: Use bits/types/dev_t.h, bits/types/gid_t.h,
        bits/types/ino_t.h, bits/types/mode_t.h, bits/types/nlink_t.h,
        bits/types/off_t.h, bits/types/uid_t.h, and bits/types/blkcnt_t.h.
        * libio/stdio.h: Use bits/types/off_t.h, bits/types/off64_t.h,
        and bits/types/ssize_t.h.
        * misc/sys/mman.h: Use bits/types/off_t.h and bits/types/mode_t.h.
        * misc/sys/select.h: Use bits/types/suseconds_t.h.
        * posix/sched.h: Use bits/types/pid_t.h.
        * posix/sys/wait.h: Use bits/types/pid_t.h and bits/types/id_t.h.
        * posix/unistd.h: Use bits/types/gid_t.h, bits/types/uid_t.h,
        bits/types/off_t.h, bits/types/off64_t.h, bits/types/useconds_t.h,
        bits/types/intptr_t.h, and bits/types/socklen_t.h.
        * pwd/pwd.h: Use bits/types/gid_t.h and bits/types/uid_t.h.
        * resource/sys/resource.h: Use bits/types/id_t.h.
        * signal/signal.h: Use bits/types/pid_t.h and bits/types/uid_t.h.
        * stdlib/monetary.h: Use bits/types/ssize_t.h.
        * sysdeps/gnu/utmpx.h: Use bits/types/pid_t.h.
        * sysvipc/sys/ipc.h: Use bits/types/uid_t.h, bits/types/gid_t.h,
        bits/types/mode_t.h, and bits/types/key_t.h.
        * sysvipc/sys/msg.h: Use bits/types/pid_t.h and bits/types/ssize_t.h.
        * sysvipc/sys/shm.h: Use bits/types/pid_t.h.
        * termios/termios.h: Use bits/types/pid_t.h.
        * time/sys/time.h: Use bits/types/suseconds_t.h.
        * time/time.h: Use bits/types/pid_t.h.

        * sunrpc/rpc/types.h: Consolidate all #includes at the top of
        the file.  If __BIT_TYPES_DEFINED__ is not defined after
        including sys/types.h, also include bits/types/caddr_t.h,
        bits/types/daddr_t.h, bits/types/fsid_t.h, and bits/types/u_int.h.

        * scripts/check-obsolete-constructs.py (OBSOLETE_TYPE_HDR_RE_): New.
        (ObsoleteIndirectDefinitionsAllowed): New; allows inclusion of
        bits/types/ headers that define obsolete typedefs, but not
        direct definitions of those types.
        (ObsoleteNotAllowed, ObsoletePrivateDefinitionsAllowed)
        (ObsoletePublicDefinitionsAllowed): Do not allow inclusion of
        bits/types/ headers that define obsolete typedefs.

	* include/bits/types/blkcnt64_t.h
	* include/bits/types/blkcnt_t.h
	* include/bits/types/blksize_t.h
	* include/bits/types/caddr_t.h
	* include/bits/types/daddr_t.h
	* include/bits/types/dev_t.h
	* include/bits/types/fsblkcnt64_t.h
	* include/bits/types/fsblkcnt_t.h
	* include/bits/types/fsfilcnt64_t.h
	* include/bits/types/fsfilcnt_t.h
	* include/bits/types/fsid_t.h
	* include/bits/types/gid_t.h
	* include/bits/types/id_t.h
	* include/bits/types/ino64_t.h
	* include/bits/types/ino_t.h
	* include/bits/types/intptr_t.h
	* include/bits/types/key_t.h
	* include/bits/types/loff_t.h
	* include/bits/types/mode_t.h
	* include/bits/types/nlink_t.h
	* include/bits/types/off64_t.h
	* include/bits/types/off_t.h
	* include/bits/types/pid_t.h
	* include/bits/types/register_t.h
	* include/bits/types/socklen_t.h
	* include/bits/types/ssize_t.h
	* include/bits/types/suseconds_t.h
	* include/bits/types/u_char.h
	* include/bits/types/u_intN_t.h
	* include/bits/types/uchar.h
	* include/bits/types/uid_t.h
	* include/bits/types/useconds_t.h: New wrappers.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This doesn't exactly fit the theme but as long as I'm tinkering with
sys/types.h it makes sense to go through and create single-declaration
bits/types/ headers for all of the remaining cases where we have
two or more headers declaring a public type.

The remaining uses of the original __T_defined idiom are:
__error_t_defined in files shared with gnulib, which probably has to
remain as is; ____gwchar_t_defined in inttypes.h, which may not be
necessary anymore and should be addressed separately, and
__ldiv_t_defined and __lldiv_t_defined in stdlib.h, ditto.

Our handling of LFS types is a little inconsistent: some headers
declare both off_t and off64_t (for instance) when
_LARGEFILE64_SOURCE, others will only declare off_t regardless of
_LARGEFILE64_SOURCE.  I don't know if this was intentional or not.
I am tempted to centralize responsibility for _LARGEFILE64_SOURCE as
well as _FILE_OFFSET_BITS=64 in bits/types/off_t.h (etc) so that any
header that declares off_t will automatically also declare off64_t
when _LARGEFILE64_SOURCE.

sunrpc/rpc/types.h is special, because it is included in files
compiled by the *build* compiler (cross-rpcgen-objs), and therefore it
cannot unconditionally assume bits/types headers are available.  What
I did was have it include the appropriate bits/types headers only if
including sys/types.h did not cause __BIT_TYPES_DEFINED__ to be
defined.  This will do the right thing when an installed rpc/types.h
is included by application code compiled without __USE_MISC in effect.
During the build, we rely on the fact that we compile all of our own
code with __USE_MISC in effect.  This is fragile, but should be
acceptable for code that's no longer built by default anyway.

scripts/check-obsolete-constructs.py ensures that only sys/types.h and
rpc/types.h include the bits/types/ headers that define obsolete types.

	* posix/bits/types/blkcnt64_t.h
	* posix/bits/types/blkcnt_t.h
	* posix/bits/types/blksize_t.h
	* posix/bits/types/dev_t.h
	* posix/bits/types/fsblkcnt64_t.h
	* posix/bits/types/fsblkcnt_t.h
	* posix/bits/types/fsfilcnt64_t.h
	* posix/bits/types/fsfilcnt_t.h
	* posix/bits/types/fsid_t.h
	* posix/bits/types/gid_t.h
	* posix/bits/types/id_t.h
	* posix/bits/types/ino64_t.h
	* posix/bits/types/ino_t.h
	* posix/bits/types/intptr_t.h
	* posix/bits/types/key_t.h
	* posix/bits/types/loff_t.h
	* posix/bits/types/mode_t.h
	* posix/bits/types/nlink_t.h
	* posix/bits/types/off64_t.h
	* posix/bits/types/off_t.h
	* posix/bits/types/pid_t.h
	* posix/bits/types/socklen_t.h
	* posix/bits/types/ssize_t.h
	* posix/bits/types/suseconds_t.h
	* posix/bits/types/uid_t.h
	* posix/bits/types/useconds_t.h:
        New single-declaration headers for standard types canonically
	defined by sys/types.h, sys/socket.h, or inttypes.h but also
	exposed by other headers under some circumstances.  Code moved
        from posix/sys/types.h, socket/sys/socket.h, stdlib/inttypes.h
        as appropriate.

	* posix/bits/types/uint.h
	* posix/bits/types/u_int.h
	* posix/bits/types/u_intN_t.h
	* posix/bits/types/caddr_t.h
	* posix/bits/types/daddr_t.h
	* posix/bits/types/loff_t.h
	* posix/bits/types/register_t.h:
        Similarly, but for obsolete BSD-derived types whose canonical
	home is sys/types.h.  Some of these headers define more than
	one type.

        * posix/Makefile (headers): Install the above new headers.
        Rewrap the list.
        * posix/sys/types.h: All definitions of public types now
        accomplished using the above new headers.  Consolidate
        groups of definitions controlled by the same feature
        selection macros.

        * inet/arpa/inet.h, bits/socket.h
        * sysdeps/mach/hurd/bits/socket.h
        * sysdeps/unix/sysv/linux/bits/socket.h:
        Use bits/types/socklen_t.h.

        * dirent/dirent.h: Use bits/types/ino_t.h and bits/types/ino64_t.h.
        * grp/grp.h: Use bits/types/gid_t.h.
        * io/fcntl.h: Use bits/types/mode_t.h, bits/types/off_t.h,
        bits/types/pid_t.h, and bits/types/off64_t.h.
        * io/sys/stat.h: Use bits/types/dev_t.h, bits/types/gid_t.h,
        bits/types/ino_t.h, bits/types/mode_t.h, bits/types/nlink_t.h,
        bits/types/off_t.h, bits/types/uid_t.h, and bits/types/blkcnt_t.h.
        * libio/stdio.h: Use bits/types/off_t.h, bits/types/off64_t.h,
        and bits/types/ssize_t.h.
        * misc/sys/mman.h: Use bits/types/off_t.h and bits/types/mode_t.h.
        * misc/sys/select.h: Use bits/types/suseconds_t.h.
        * posix/sched.h: Use bits/types/pid_t.h.
        * posix/sys/wait.h: Use bits/types/pid_t.h and bits/types/id_t.h.
        * posix/unistd.h: Use bits/types/gid_t.h, bits/types/uid_t.h,
        bits/types/off_t.h, bits/types/off64_t.h, bits/types/useconds_t.h,
        bits/types/intptr_t.h, and bits/types/socklen_t.h.
        * pwd/pwd.h: Use bits/types/gid_t.h and bits/types/uid_t.h.
        * resource/sys/resource.h: Use bits/types/id_t.h.
        * signal/signal.h: Use bits/types/pid_t.h and bits/types/uid_t.h.
        * stdlib/monetary.h: Use bits/types/ssize_t.h.
        * sysdeps/gnu/utmpx.h: Use bits/types/pid_t.h.
        * sysvipc/sys/ipc.h: Use bits/types/uid_t.h, bits/types/gid_t.h,
        bits/types/mode_t.h, and bits/types/key_t.h.
        * sysvipc/sys/msg.h: Use bits/types/pid_t.h and bits/types/ssize_t.h.
        * sysvipc/sys/shm.h: Use bits/types/pid_t.h.
        * termios/termios.h: Use bits/types/pid_t.h.
        * time/sys/time.h: Use bits/types/suseconds_t.h.
        * time/time.h: Use bits/types/pid_t.h.

        * sunrpc/rpc/types.h: Consolidate all #includes at the top of
        the file.  If __BIT_TYPES_DEFINED__ is not defined after
        including sys/types.h, also include bits/types/caddr_t.h,
        bits/types/daddr_t.h, bits/types/fsid_t.h, and bits/types/u_int.h.

        * scripts/check-obsolete-constructs.py (OBSOLETE_TYPE_HDR_RE_): New.
        (ObsoleteIndirectDefinitionsAllowed): New; allows inclusion of
        bits/types/ headers that define obsolete typedefs, but not
        direct definitions of those types.
        (ObsoleteNotAllowed, ObsoletePrivateDefinitionsAllowed)
        (ObsoletePublicDefinitionsAllowed): Do not allow inclusion of
        bits/types/ headers that define obsolete typedefs.

	* include/bits/types/blkcnt64_t.h
	* include/bits/types/blkcnt_t.h
	* include/bits/types/blksize_t.h
	* include/bits/types/caddr_t.h
	* include/bits/types/daddr_t.h
	* include/bits/types/dev_t.h
	* include/bits/types/fsblkcnt64_t.h
	* include/bits/types/fsblkcnt_t.h
	* include/bits/types/fsfilcnt64_t.h
	* include/bits/types/fsfilcnt_t.h
	* include/bits/types/fsid_t.h
	* include/bits/types/gid_t.h
	* include/bits/types/id_t.h
	* include/bits/types/ino64_t.h
	* include/bits/types/ino_t.h
	* include/bits/types/intptr_t.h
	* include/bits/types/key_t.h
	* include/bits/types/loff_t.h
	* include/bits/types/mode_t.h
	* include/bits/types/nlink_t.h
	* include/bits/types/off64_t.h
	* include/bits/types/off_t.h
	* include/bits/types/pid_t.h
	* include/bits/types/register_t.h
	* include/bits/types/socklen_t.h
	* include/bits/types/ssize_t.h
	* include/bits/types/suseconds_t.h
	* include/bits/types/u_char.h
	* include/bits/types/u_intN_t.h
	* include/bits/types/uchar.h
	* include/bits/types/uid_t.h
	* include/bits/types/useconds_t.h: New wrappers.
</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>Change most internal uses of __gettimeofday to __clock_gettime.</title>
<updated>2019-10-30T20:04:10+00:00</updated>
<author>
<name>Zack Weinberg</name>
<email>zackw@panix.com</email>
</author>
<published>2019-08-17T00:38:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=4a39c34c4f85de57fb4e648cfa1e774437d69680'/>
<id>4a39c34c4f85de57fb4e648cfa1e774437d69680</id>
<content type='text'>
Since gettimeofday will shortly be implemented in terms of
clock_gettime on all platforms, internal code should use clock_gettime
directly; in addition to removing a layer of indirection, this will
allow us to remove the PLT-bypass gunk for gettimeofday.  (We can't
quite do that yet, but it'll be coming later in this patch series.)
In many cases, the changed code does fewer conversions.

The changed code always assumes __clock_gettime (CLOCK_REALTIME)
cannot fail.  Most of the call sites were assuming gettimeofday could
not fail, but a few places were checking for errors.  POSIX says
clock_gettime can only fail if the clock constant is invalid or
unsupported, and CLOCK_REALTIME is the one and only clock constant
that's required to be supported.  For consistency I grepped the entire
source tree for any other places that checked for errors from
__clock_gettime (CLOCK_REALTIME), found one, and changed it too.

(For the record, POSIX also says gettimeofday can never fail.)

(It would be nice if we could declare that GNU systems will always
support CLOCK_MONOTONIC as well as CLOCK_REALTIME; there are several
places where we are using CLOCK_REALTIME where _MONOTONIC would be
more appropriate, and/or trying to use _MONOTONIC and then falling
back to _REALTIME.  But the Hurd doesn't support CLOCK_MONOTONIC yet,
and it looks like adding it would involve substantial changes to
gnumach's internals and API.  Oh well.)

A few Hurd-specific files were changed to use __host_get_time instead
of __clock_gettime, as this seemed tidier.  We also assume this cannot
fail.  Skimming the code in gnumach leads me to believe the only way
it could fail is if __mach_host_self also failed, and our
Hurd-specific code consistently assumes that can't happen, so I'm
going with that.

With the exception of support/support_test_main.c, test cases are not
modified, mainly because I didn't want to have to figure out which
test cases were testing gettimeofday specifically.

The definition of GETTIME in sysdeps/generic/memusage.h had a typo and
was not reading tv_sec at all.  I fixed this.  It appears nobody has been
generating malloc traces on a machine that doesn't have a superseding
definition.

There are a whole bunch of places where the code could be simplified
by factoring out timespec subtraction and/or comparison logic, but I
want to keep this patch as mechanical as possible.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.

Reviewed-by: Adhemerval Zanella &lt;adhemerval.zanella@linaro.org&gt;
Reviewed-by: Lukasz Majewski &lt;lukma@denx.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since gettimeofday will shortly be implemented in terms of
clock_gettime on all platforms, internal code should use clock_gettime
directly; in addition to removing a layer of indirection, this will
allow us to remove the PLT-bypass gunk for gettimeofday.  (We can't
quite do that yet, but it'll be coming later in this patch series.)
In many cases, the changed code does fewer conversions.

The changed code always assumes __clock_gettime (CLOCK_REALTIME)
cannot fail.  Most of the call sites were assuming gettimeofday could
not fail, but a few places were checking for errors.  POSIX says
clock_gettime can only fail if the clock constant is invalid or
unsupported, and CLOCK_REALTIME is the one and only clock constant
that's required to be supported.  For consistency I grepped the entire
source tree for any other places that checked for errors from
__clock_gettime (CLOCK_REALTIME), found one, and changed it too.

(For the record, POSIX also says gettimeofday can never fail.)

(It would be nice if we could declare that GNU systems will always
support CLOCK_MONOTONIC as well as CLOCK_REALTIME; there are several
places where we are using CLOCK_REALTIME where _MONOTONIC would be
more appropriate, and/or trying to use _MONOTONIC and then falling
back to _REALTIME.  But the Hurd doesn't support CLOCK_MONOTONIC yet,
and it looks like adding it would involve substantial changes to
gnumach's internals and API.  Oh well.)

A few Hurd-specific files were changed to use __host_get_time instead
of __clock_gettime, as this seemed tidier.  We also assume this cannot
fail.  Skimming the code in gnumach leads me to believe the only way
it could fail is if __mach_host_self also failed, and our
Hurd-specific code consistently assumes that can't happen, so I'm
going with that.

With the exception of support/support_test_main.c, test cases are not
modified, mainly because I didn't want to have to figure out which
test cases were testing gettimeofday specifically.

The definition of GETTIME in sysdeps/generic/memusage.h had a typo and
was not reading tv_sec at all.  I fixed this.  It appears nobody has been
generating malloc traces on a machine that doesn't have a superseding
definition.

There are a whole bunch of places where the code could be simplified
by factoring out timespec subtraction and/or comparison logic, but I
want to keep this patch as mechanical as possible.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu,
powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu.

Reviewed-by: Adhemerval Zanella &lt;adhemerval.zanella@linaro.org&gt;
Reviewed-by: Lukasz Majewski &lt;lukma@denx.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>resolv/tst-idna_name_classify: Isolate from system libraries</title>
<updated>2019-10-30T16:44:09+00:00</updated>
<author>
<name>Florian Weimer</name>
<email>fweimer@redhat.com</email>
</author>
<published>2019-10-30T16:44:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.belthelziquor.com/glibc.git/commit/?id=8dddf0bd5a3d57fba8da27e93f3d1a7032fce184'/>
<id>8dddf0bd5a3d57fba8da27e93f3d1a7032fce184</id>
<content type='text'>
Loading NSS modules from static binaries uses installed system
libraries if LD_LIBRARY_PATH is not set.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Loading NSS modules from static binaries uses installed system
libraries if LD_LIBRARY_PATH is not set.
</pre>
</div>
</content>
</entry>
</feed>
