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: Arnd Bergmann <arnd at arndb dot de>
- To: Lukasz Majewski <lukma at denx dot de>
- Cc: 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>, Alistair Francis <alistair23 at gmail dot com>
- Date: Thu, 27 Jun 2019 23:25:46 +0200
- Subject: Re: [RFC v2 03/20] y2038: linux: Provide __clock_settime64 implementation
- References: <cover.1561421042.git.alistair.francis@wdc.com> <4a1304510a5c9b5c2f6432bfdc5c9fd1740a081f.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>
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.
Arnd