This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC] time: Create a endian_t.h headerfile
- From: Joseph Myers <joseph at codesourcery dot com>
- To: Alistair Francis <alistair dot francis at wdc dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Thu, 19 Sep 2019 23:34:04 +0000
- Subject: Re: [RFC] time: Create a endian_t.h headerfile
- Ironport-sdr: 1stu+YF3/v4+pZqL/pD3ZdFa6XqX1yS69ocNd5yjX9iaC9PDvDKFgOevcCtMiiGhPXcXQUr//V WMvElNgxCk4IKWa4jSVWWD4f4kAHQBfeu0oWemV9AjMU2g6Z3Z4ens3UOcUOmNBP4FnOH4w6co Z8ThIqxSXLPHH5/KVlRlyvWaIjvKOlRVAhG7L1dsEFe+6PZeTivJT8BcvYe+zAlSa5v7WnEU9Y njdwWsyb/zPstECVtJ/oi2ENI8dZr3KBzJnXbEacOi0Kr2U+z8/Y8VCjW9yFMREuKn3CoGAU1f P/o=
- Ironport-sdr: dFrsve8IZ8W71X2RBc/aX0ItMMcWxp7UBpw0O5zVf/cLYfC8hMLoZ/O2tYptoKXcSuxpXgZAal CSlRN8CLzDbjfV3XaoSfJ3BFZpuTLmcBpBnPtenkabi1OZN0TjQkB7fgzEis703zewqPlzVUU9 kTYdzX1uMcrsQnTaihIIQkVmoi2YmUyRbNEKfuRzN/CGvPXCJ6CKiqkWQA2CUPH980ki5jhdpJ 00CGNT7pIueHJNIUSZ+95C99IZi0+IlrS55XwSIFjHdf1X/hBI9po+hskXFIeO/YgQIE/S7V/a cfw=
- References: <20190919221829.6137-1-alistair.francis@wdc.com>
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