From: Joseph Myers <joseph@codesourcery.com>
To: Alistair Francis <alistair23@gmail.com>
Cc: Lukasz Majewski <lukma@denx.de>, Zack Weinberg <zackw@panix.com>,
Arnd Bergmann <arnd@arndb.de>,
Alistair Francis <alistair.francis@wdc.com>,
GNU C Library <libc-alpha@sourceware.org>,
Adhemerval Zanella <adhemerval.zanella@linaro.org>,
Florian Weimer <fweimer@redhat.com>,
Carlos O'Donell <carlos@redhat.com>,
Stepan Golosunov <stepan@golosunov.pp.ru>
Subject: Re: [PATCH v7 0/3] y2038: Linux: Introduce __clock_settime64 function
Date: Wed, 18 Sep 2019 17:25:38 +0000 [thread overview]
Message-ID: <alpine.DEB.2.21.1909181713340.18433@digraph.polyomino.org.uk> (raw)
In-Reply-To: <CAKmqyKOXtCQ68G0DxEcesbKQCWGaXpvMV2SX-hzDdJJaQ+J_cA@mail.gmail.com>
On Wed, 18 Sep 2019, Alistair Francis wrote:
> +#include <endian.h>
>
> /* POSIX.1b structure for a time value. This is like a `struct timeval' but
> has nanoseconds instead of microseconds. */
> struct timespec
> {
> __time_t tv_sec; /* Seconds. */
> +#if __WORDSIZE == 64 \
> + || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64)
> __syscall_slong_t tv_nsec; /* Nanoseconds. */
> +#else
> +# if BYTE_ORDER == BIG_ENDIAN
> + __int32_t tv_pad; /* Padding */
> + __syscall_slong_t tv_nsec; /* Nanoseconds */
> +# else
> + __int32_t tv_nsec; /* Nanoseconds */
> + __syscall_slong_t tv_pad; /* Padding */
> +# endif
> +#endif
The padding must be an *unnamed bit-field* so that { tv_sec, tv_nsec }
initializers (common in practice even if not officially supported by the
standards) continue to work. Also, I think you should just use "long int"
for tv_nsec in the case where there is padding, as the standard-defined
type (and then the padding can be "int: 32", so avoiding any dependence on
whether compilers support non-int bit-fields). Certainly the choice of
types for tv_nsec and padding should not depend on the endianness (the
patch above is using __int32_t for the first field and __syscall_slong_t
for the second, regardless of which is tv_nsec and which is padding).
There are namespace issues when changing installed headers. You can't use
macros such as BYTE_ORDER or BIG_ENDIAN because they aren't in the
standard-reserved namespaces.
Unfortunately the definitions of __LITTLE_ENDIAN and __BIG_ENDIAN are in
<endian.h> (__BYTE_ORDER is in the architecture-specific <bits/endian.h>),
and while the non-reserved names therein are all conditional on
__USE_MISC, I don't think we really want to start exporting them from
every header that uses struct timespec. My inclination would be to have a
separate bits/ header that only defines the __LITTLE_ENDIAN / __BIG_ENDIAN
/ __PDP_ENDIAN macros (or that defines those and includes the
architecture-specific header for __BYTE_ORDER), so that other headers can
test endianness without bringing in all the other __USE_MISC
endian-related macros from <endian.h>, but Zack might advise on how such
changes would fit into his header cleanups.
--
Joseph S. Myers
joseph@codesourcery.com
next prev parent reply other threads:[~2019-09-18 17:25 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-06 14:59 [PATCH v7 0/3] y2038: Linux: Introduce __clock_settime64 function Lukasz Majewski
2019-09-06 14:59 ` [PATCH v7 1/3] y2038: Introduce internal for glibc struct __timespec64 Lukasz Majewski
2019-09-06 14:59 ` [PATCH v7 2/3] y2038: Provide conversion helpers for " Lukasz Majewski
2019-09-06 14:59 ` [PATCH v7 3/3] y2038: linux: Provide __clock_settime64 implementation Lukasz Majewski
2019-09-06 16:52 ` [PATCH v7 0/3] y2038: Linux: Introduce __clock_settime64 function Alistair Francis
2019-09-06 21:28 ` Joseph Myers
2019-09-16 22:45 ` Alistair Francis
2019-09-17 0:44 ` Joseph Myers
2019-09-17 10:11 ` Lukasz Majewski
2019-09-17 13:42 ` Joseph Myers
2019-09-17 15:53 ` Lukasz Majewski
2019-09-17 16:51 ` Joseph Myers
2019-09-18 17:03 ` Alistair Francis
2019-09-18 17:25 ` Joseph Myers [this message]
2019-09-18 21:37 ` Lukasz Majewski
2019-09-18 21:45 ` Joseph Myers
2019-09-19 21:56 ` Alistair Francis
2019-09-18 21:28 ` Lukasz Majewski
2019-09-18 22:26 ` Alistair Francis
2019-09-19 7:50 ` Lukasz Majewski
2019-09-06 21:55 ` Lukasz Majewski
2019-09-06 22:01 ` Alistair Francis
2019-09-13 14:36 ` Lukasz Majewski
2019-09-16 21:50 ` Alistair Francis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.21.1909181713340.18433@digraph.polyomino.org.uk \
--to=joseph@codesourcery.com \
--cc=adhemerval.zanella@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=arnd@arndb.de \
--cc=carlos@redhat.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=lukma@denx.de \
--cc=stepan@golosunov.pp.ru \
--cc=zackw@panix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).