This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC v2 03/20] y2038: linux: Provide __clock_settime64 implementation
- From: Alistair Francis <alistair23 at gmail dot com>
- To: Lukasz Majewski <lukma at denx dot de>
- Cc: Arnd Bergmann <arnd at arndb dot de>, Joseph Myers <joseph at codesourcery dot com>, Alistair Francis <alistair dot francis at wdc dot com>, GNU C Library <libc-alpha at sourceware dot org>, Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, Florian Weimer <fweimer at redhat dot com>, Palmer Dabbelt <palmer at sifive dot com>, macro at wdc dot com, Zong Li <zongbox at gmail dot com>, Zong Li <zong at andestech dot com>
- Date: Wed, 3 Jul 2019 17:04:51 -0700
- Subject: Re: [RFC v2 03/20] y2038: linux: Provide __clock_settime64 implementation
- References: <cover.1561421042.git.alistair.francis@wdc.com> <CAK8P3a1fpqmFWMXAmV9KmuYFegRG958tLr9u=spELuRwXKfRiQ@mail.gmail.com> <20190625175125.03375ead@jawa> <CAK8P3a3AUgWzuZaZR5p2brmK16cMviidTf6A4aZ=mXVuNySbpA@mail.gmail.com> <20190626110711.64e8cd2f@jawa> <CAK8P3a0FVRV5H9f=wcU+C47R7FEckyjPtGVD2VaTAXsguEzyqw@mail.gmail.com> <20190626170344.2c9d1d47@jawa> <CAK8P3a2i1FktDrk1j5+qrTcUfqW=a=OviTVxyvTq8Vr0=Mw41Q@mail.gmail.com> <20190627005517.418d26c2@jawa> <CAK8P3a2SCjaR5OjQRRUVPMHbobYQUVXO1CEcp8gG0RhKjUoEpg@mail.gmail.com> <20190627123557.01356d4d@jawa> <CAK8P3a0UN1wy3BvTUD7UpOOS15O6hCJRP-+VdwQdinwKTnvmQA@mail.gmail.com> <20190627160758.6fe824cf@jawa> <CAK8P3a1XBLBnkTMiBD8-ReR3Qmf67m5gfS1AciYeuy8hf2_R5A@mail.gmail.com> <20190627172333.1a979f6d@jawa> <CAK8P3a1Q0zuv4d6Svbif2x60Z5JQMgFJujcsKtcJ9Dc1JQu=Gg@mail.gmail.com> <20190627181654.1d08392a@jawa> <CAK8P3a33Yxy3f6b1YjzxjmCcTcR=Y7OdicdJ+JxVSZj4S_JNAQ@mail.gmail.com> <20190628000805.65b6dfc9@jawa>
On Thu, Jun 27, 2019 at 3:08 PM Lukasz Majewski <lukma@denx.de> wrote:
>
> Hi Arnd,
>
> > On Thu, Jun 27, 2019 at 6:17 PM Lukasz Majewski <lukma@denx.de> wrote:
> >
> > > >
> > > > Ok, so you redirect both __clock_settime64 to __clock_settime
> > > > and __NR_settime64 to __NR_settime, in order to get back to the
> > > > same definition that you have today on 64-bit.
> > > >
> > > > Sorry for taking so long to understand that.
> > >
> > > Not only you had a hard time to understand it.
> >
> > Here is how I had imagined it would be done in a way that I find
> > easier to understand:
> >
> > #if __WORDSIZE == 32 /* yes, all of them including rv32 and x32 */
> > __clock_settime64 (clockid_t clock_id, const struct __timespec64 *tp)
> > {
> > int ret;
> >
> > /* Make sure the time cvalue is OK. */
> > if (tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000)
> > {
> > __set_errno (EINVAL);
> > return -1;
> > }
> > #ifdef __NR_clock_settime64
> > ret = INLINE_SYSCALL_CALL (clock_settime64, clock_id, tp);
> > #endif
> >
> > #ifndef __ASSUME_TIME64_SYSCALLS
> > if (ret == 0 || errno != ENOSYS)
> > return ret;
> >
> > if (! in_time_t_range (tp->tv_sec))
> > {
> > __set_errno (EOVERFLOW);
> > return -1;
> > }
> >
> > struct timespec ts32;
> > valid_timespec64_to_timespec (tp, &ts32);
> > ret = INLINE_SYSCALL_CALL (clock_settime, clock_id, &ts32);
> > #endif
> >
> > return ret;
> > }
> > #endif
> >
> > This should be functionally identical to what you have, but avoid
> > some of the complexity, especially once linux-5.1 becomes the
> > minimum version.
This implementation looks good to me. It shouldn't be too hard to
extend this to all the problematic y2038 syscalls.
>
> The semantics for __ASSUME_TIME64_SYSCALLS is under the discussion for
> some time [1].
I don't see any comments on this, do you know the status?
>
> Also the __clock_settime64() implementation from [2] takes into
> account some corner cases (like support for all archs since 3.2
> kernel, x32, legacy systems, etc). The implementation from [2] IMHO
> seems to be more concise and fits into the 64 bit conversion paradigm
> for glibc [3].
This one also works for RV32 :)
Alistair
>
> However, this is only my opinion and we shall wait for other community
> members to express their opinions.
>
> >
> > Arnd
>
>
> Note:
>
> [1] - https://patchwork.ozlabs.org/patch/1117100/
> [2] - https://patchwork.ozlabs.org/patch/1107235/
> [3] -
> https://www.gnu.org/software/libc/manual/html_mono/libc.html
> "D.2.1 64-bit time symbol handling in the GNU C Library"
>
>
>
> Best regards,
>
> Lukasz Majewski
>
> --
>
> DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de