This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 1/6] y2038: Use __clock_settime64 in deprecated stime function
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: Lukasz Majewski <lukma at denx dot de>, Joseph Myers <joseph at codesourcery dot com>, Paul Eggert <eggert at cs dot ucla dot edu>, Samuel Thibault <samuel dot thibault at ens-lyon dot org>
- Cc: Alistair Francis <alistair23 at gmail dot com>, Alistair Francis <alistair dot francis at wdc dot com>, GNU C Library <libc-alpha at sourceware dot org>, Siddhesh Poyarekar <siddhesh at gotplt dot org>, Florian Weimer <fweimer at redhat dot com>, Florian Weimer <fw at deneb dot enyo dot de>, Zack Weinberg <zackw at panix dot com>, Carlos O'Donell <carlos at redhat dot com>, Andreas Schwab <schwab at suse dot de>
- Date: Mon, 20 Jan 2020 13:58:36 -0300
- Subject: Re: [PATCH 1/6] y2038: Use __clock_settime64 in deprecated stime function
- References: <20200118072047.23071-1-lukma@denx.de> <20200118072047.23071-2-lukma@denx.de>
On 18/01/2020 04:20, Lukasz Majewski wrote:
> Now, internally the deprecated stime uses __clock_settime64. This patch is
> necessary for having architectures with __WORDSIZE == 32 &&
> __TIMESIZE == 32 (like e.g. ARM32) Y2038 safe.
>
> Build tests:
> ./src/scripts/build-many-glibcs.py glibcs
> ---
> time/stime.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/time/stime.c b/time/stime.c
> index 576fa9c0c9..963902126b 100644
> --- a/time/stime.c
> +++ b/time/stime.c
> @@ -27,11 +27,11 @@ int
> attribute_compat_text_section
> __stime (const time_t *when)
> {
> - struct timespec ts;
> + struct __timespec64 ts;
> ts.tv_sec = *when;
> ts.tv_nsec = 0;
>
> - return __clock_settime (CLOCK_REALTIME, &ts);
> + return __clock_settime64 (CLOCK_REALTIME, &ts);
> }
>
> compat_symbol (libc, __stime, stime, GLIBC_2_0);
>
For !__ASSUME_TIME64_SYSCALLS builds time_t will continue to be 32 bits
and stime will continue to be non Y2038 safe. Also, internally
__clock_settime will first try to issue __NR_clock_settime64, so current
code already accomplishes what this patch is aiming to do.