[RFC] time: Create a endian_t.h headerfile
Joseph Myers
joseph@codesourcery.com
Thu Sep 19 23:34:00 GMT 2019
On Thu, 19 Sep 2019, Alistair Francis wrote:
> To allow struct __timespec64 and struct timespec to be the same on a
> 32-bit architecture with a 64-bit time_t we need to add padding to the
> struct timespec. This padding requires knowledge of the machines
> endianess, which requires us exporting the endianness in
> time/bits/types/struct_timespec.h.
>
> To reduce the number of macros that we are exporting let's split out an
> endian_t.h header file that can be used.
An installed header has to be appropriately listed in "headers" in some
directory's Makefile to cause it to be installed; otherwise you get code
that builds file in the glibc source tree but breaks with an installed
compiler and headers.
The bits/types/ namespace is *only* for headers defining a single type
(that is, bits/types/endian_t.h would be a header that defines the
endian_t typedef and nothing else). So it's not appropriate for this
header.
You can't use "#include <time/...>" in an installed header because that
would also break when using an installed compiler and headers. #includes
in installed headers need to use the <bits/*> path the included header
would have when installed. Then you add an include/bits/ wrapper in the
glibc source tree to allow the uninstalled header to be found when
building glibc. (And time/ is not the right location for a header about
endianness. Either string/, or use the top-level bits/ directory and so
avoid the need for any wrapper at all.)
If anything, I think the cleanest naming would be to have <bits/endian.h>
be the architecture-independent header that defines these three macros and
includes <bits/endian-arch.h>, where the existing <bits/endian.h> headers
that define __BYTE_ORDER all get renamed to <bits/endian-arch.h>. So
you'd need to add bits/endian-arch.h to the "headers" setting in
string/Makefile.
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list