From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Lukasz Majewski <lukma@denx.de>, Arnd Bergmann <arnd@arndb.de>
Cc: Alistair Francis <alistair23@gmail.com>,
Joseph Myers <joseph@codesourcery.com>,
Paul Eggert <eggert@cs.ucla.edu>,
Samuel Thibault <samuel.thibault@ens-lyon.org>,
Alistair Francis <alistair.francis@wdc.com>,
GNU C Library <libc-alpha@sourceware.org>,
Siddhesh Poyarekar <siddhesh@gotplt.org>,
Florian Weimer <fweimer@redhat.com>,
Florian Weimer <fw@deneb.enyo.de>,
Zack Weinberg <zackw@panix.com>,
Carlos O'Donell <carlos@redhat.com>,
Andreas Schwab <schwab@suse.de>
Subject: Re: [PATCH 3/6] y2038: Introduce struct __timeval64 - new internal glibc type
Date: Tue, 21 Jan 2020 17:31:00 -0000 [thread overview]
Message-ID: <12ffdfbd-376b-e770-e071-40d2236ebad8@linaro.org> (raw)
In-Reply-To: <20200121174556.49568f8b@jawa>
On 21/01/2020 13:45, Lukasz Majewski wrote:
> Hi Arnd, Adhemerval,
>
>> On Mon, Jan 20, 2020 at 5:46 PM Adhemerval Zanella
>> <adhemerval.zanella@linaro.org> wrote:
>>> On 20/01/2020 10:00, Arnd Bergmann wrote:
>>>> On Mon, Jan 20, 2020 at 1:34 PM Lukasz Majewski <lukma@denx.de>
>>>> wrote:
>>>>>>> On Sun, Jan 19, 2020 at 4:22 PM Lukasz Majewski <lukma@denx.de>
>>>>>>> wrote:
>>>>>>>>> On Sat, Jan 18, 2020 at 11:48 PM Alistair Francis
>>>>>>>>> <alistair23@gmail.com> wrote:
>>>>>>>
>>>>>>> It would certainly help if this could be consistent across
>>>>>>> architectures and libraries.
>>>>>>
>>>>>> Ok. Thanks for the input.
>>>>>
>>>>> Would it be OK to have:
>>>>>
>>>>> struct __timeval64
>>>>> {
>>>>> __time64_t tv_sec; /* Seconds */
>>>>> __int64_t tv_usec; /* Microseconds */
>>>>> };
>>>>
>>>> This would not work if you pass it into a kernel interface that
>>>> expects a 32-bit suseconds_t on sparc64, but it should work as an
>>>> internal type on all 32-bit architectures.
>>>>
>>>>> I would prefer to avoid changing typedef of suseconds_t as it may
>>>>> affect struct timeval related operations.
>>>>>
>>>>> Using explicitly __int64_t for tv_usec seems better option,
>>>>> isn't it?
>>>>
>>>> Maybe a __suseconds64_t that happens to be 32-bit wide on
>>>> sparc64?
>>>
>>> If timeval64 kernel ABI expects tv_usec being a different type
>>> depending of the architecture, it is an indication we should
>>> parametrize with a __suseconds64_t.
>>>
>>> As a side note, why tv_usec for timeval64 is a 64-bit value? Is it
>>> related to some alignment constraint?
>>
>> I think it's mostly for simplicity: we do need the microseconds to be
>> in the low bytes for compatibility with the 64-bit syscalls in the
>> kernel, so it's either a 64-bit microseconds value or the same
>> conditional padding that exists in timespec, with an extra special
>> case for sparc64.
>>
>> The 64-bit case is slightly simpler for the few kernel interfaces that
>> take a timeval as input and then can avoid conditionally zeroing out
>> the upper 32 bits before checking the lower 32 bits again 1000000.
>> I think that is only needed for clock_adjtimex, VIDIOC_QBUF and
>> PPSETTIME though, everything else only passes a timeval
>> to user space.
>
> I would opt for simpler approach :-)
>
> Is the below code correct?
> ./include/time.h
>
> struct __timeval64
> {
> __time64_t tv_sec; /* Seconds */
> __suseconds64_t tv_usec; /* Microseconds */
> };
>
> However, I'm a bit confused on the correct place to define
> __suseconds64_t.
>
> Shall it be added to posix/bits/types.h?
> __STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of
> microseconds. */
Yes, the idea is to add on posix/bits/types.h:
__STD_TYPE __SUSECONDS64_T_TYPE __suseconds64_t;
Then on generic bits bits/typesizes.h:
#define __SUSECONDS_T_TYPE __SQUAD_TYPE;
And then also define it on each Linux bits/typesizes.h.
>
> If yes, then wouldn't we break the compatibility by adding new type to
> this file?
What do you mean by break compatibility? It is a new type on an
installed header used by new types.
next prev parent reply other threads:[~2020-01-21 17:25 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-18 7:34 [PATCH 0/6] y2038: Convert settimeofday to be Y2038 safe Lukasz Majewski
2020-01-18 7:21 ` [PATCH 4/6] y2038: alpha: Rename valid_timeval_to_timeval64 to valid_timeval32_to_timeval Lukasz Majewski
2020-01-18 23:03 ` Alistair Francis
2020-01-18 7:21 ` [PATCH 6/6] y2038: linux: Provide __settimeofday64 implementation Lukasz Majewski
2020-01-19 1:13 ` Alistair Francis
2020-01-18 7:21 ` [PATCH 3/6] y2038: Introduce struct __timeval64 - new internal glibc type Lukasz Majewski
2020-01-18 22:49 ` Alistair Francis
2020-01-19 15:22 ` Arnd Bergmann
2020-01-19 15:39 ` Lukasz Majewski
2020-01-19 21:30 ` Arnd Bergmann
2020-01-20 2:12 ` Lukasz Majewski
2020-01-20 13:01 ` Lukasz Majewski
2020-01-20 13:03 ` Arnd Bergmann
2020-01-20 16:58 ` Adhemerval Zanella
2020-01-20 19:25 ` Arnd Bergmann
2020-01-21 16:55 ` Lukasz Majewski
2020-01-21 17:31 ` Adhemerval Zanella [this message]
2020-01-21 22:02 ` Lukasz Majewski
2020-01-18 7:21 ` [PATCH 2/6] y2038: hurd: Provide __clock_settime64 function Lukasz Majewski
2020-01-20 17:12 ` Adhemerval Zanella
2020-01-20 18:10 ` Lukasz Majewski
2020-01-20 18:29 ` Adhemerval Zanella
2020-01-21 16:46 ` Lukasz Majewski
2020-01-21 17:22 ` Adhemerval Zanella
2020-01-21 17:25 ` Samuel Thibault
2020-01-28 0:36 ` Samuel Thibault
2020-01-18 7:21 ` [PATCH 1/6] y2038: Use __clock_settime64 in deprecated stime function Lukasz Majewski
2020-01-20 17:01 ` Adhemerval Zanella
2020-01-20 18:01 ` Lukasz Majewski
2020-01-20 18:26 ` Adhemerval Zanella
2020-01-21 17:16 ` Lukasz Majewski
2020-01-21 17:20 ` Adhemerval Zanella
2020-01-18 7:21 ` [PATCH 5/6] y2038: Provide conversion helpers for struct __timeval64 Lukasz Majewski
2020-01-18 23:47 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12ffdfbd-376b-e770-e071-40d2236ebad8@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=arnd@arndb.de \
--cc=carlos@redhat.com \
--cc=eggert@cs.ucla.edu \
--cc=fw@deneb.enyo.de \
--cc=fweimer@redhat.com \
--cc=joseph@codesourcery.com \
--cc=libc-alpha@sourceware.org \
--cc=lukma@denx.de \
--cc=samuel.thibault@ens-lyon.org \
--cc=schwab@suse.de \
--cc=siddhesh@gotplt.org \
--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).