public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: Joseph Myers <joseph@codesourcery.com>,
	Paul Eggert <eggert@cs.ucla.edu>,
	Alistair Francis <alistair23@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Alistair Francis <alistair.francis@wdc.com>,
	GNU C Library <libc-alpha@sourceware.org>,
	Florian Weimer <fweimer@redhat.com>,
	Carlos O'Donell <carlos@redhat.com>,
	Stepan Golosunov <stepan@golosunov.pp.ru>,
	Andreas Schwab <schwab@suse.de>, Zack Weinberg <zackw@panix.com>
Subject: Re: [PATCH] y2038: linux: Provide __time64 implementation
Date: Fri, 16 Oct 2020 12:18:22 +0200	[thread overview]
Message-ID: <20201016121822.61880806@jawa> (raw)
In-Reply-To: <aa5364fe-f694-ff23-2dd1-55cdf17ba2a1@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 4779 bytes --]

Hi Adhemerval,

> On 15/10/2020 09:34, Lukasz Majewski wrote:
> > In the glibc the time function can use vDSO (on power and x86 the
> > USE_IFUNC_TIME is defined), time syscall or 'default' time() from
> > ./time/time.c (as a fallback).
> > 
> > In this patch the last function (time) has been refactored and moved
> > to ./sysdeps/unix/sysv/linux/time.c to be Linux specific.
> > 
> > The new __time64 explicit 64 bit function for providing 64 bit
> > value of seconds after epoch (by internally calling
> > __clock_gettime64) has been introduced.
> > 
> > Moreover, a 32 bit version - __time has been refactored to
> > internally use __time64.
> > 
> > The __time is now supposed to be used on systems still supporting
> > 32 bit time (__TIMESIZE != 64) - hence the necessary check for
> > time_t potential overflow.
> > 
> > Build tests:
> > ./src/scripts/build-many-glibcs.py glibcs
> > 
> > Run-time tests:
> > - Run specific tests on ARM/x86 32bit systems (qemu):
> > https://github.com/lmajewski/meta-y2038 and run tests:
> > https://github.com/lmajewski/y2038-tests/commits/master
> > 
> > Above tests were performed with Y2038 redirection applied as well
> > as without to test proper usage of both __time64 and __time.  
> 
> Looks good in general, some comments below.

I'm going to send v2 of this patch.

> 
> > ---
> >  include/time.h                 |  7 ++++++
> >  sysdeps/unix/sysv/linux/time.c | 39
> > +++++++++++++++++++++++++++++++++- 2 files changed, 45
> > insertions(+), 1 deletion(-)
> > 
> > diff --git a/include/time.h b/include/time.h
> > index edf6cdf829..caf2af5e74 100644
> > --- a/include/time.h
> > +++ b/include/time.h
> > @@ -317,6 +317,13 @@ extern int __timespec_get64 (struct
> > __timespec64 *ts, int base); libc_hidden_proto (__timespec_get64)
> >  #endif
> >  
> > +#if __TIMESIZE == 64
> > +# define __time64 __time
> > +#else
> > +extern __time64_t __time64 (__time64_t *timer);
> > +libc_hidden_proto (__time64)
> > +#endif
> > +
> >  /* Use in the clock_* functions.  Size of the field representing
> > the actual clock ID.  */
> >  #define CLOCK_IDFIELD_SIZE	3  
> 
> Ok.
> 
> > diff --git a/sysdeps/unix/sysv/linux/time.c
> > b/sysdeps/unix/sysv/linux/time.c index 9d8e573c0a..1a9a7c0413 100644
> > --- a/sysdeps/unix/sysv/linux/time.c
> > +++ b/sysdeps/unix/sysv/linux/time.c
> > @@ -47,5 +47,42 @@ time (time_t *t)
> >  }
> >  # endif /* !SHARED */
> >  #else /* USE_IFUNC_TIME  */  
> 
> You need to handle USE_IFUNC_TIME, which is still used for powerpc32
> and i686.  I don't think optimizing for vDSO access pay for the
> complexity in these cases, so disable it with:
> 
>  20 #ifdef USE_IFUNC_TIME && __TIMESIZE == 64
>  21 # include <time.h>
> 

In the gettimeofday() conversion patch it was enough to use 
#ifdef __x86_64__ and #ifdef __powerpc64__ in arch specific time.c so

(SHA1: 7455b700279ec8baccf8dd7b119648f8b3e34eec)

> 
> > -# include <time/time.c>
> > +/* Conversion of time function to support 64 bit time on archs
> > +   with __WORDSIZE == 32 and __TIMESIZE == 32/64  */  
> 
> I think this comment is kinda unnecessary, but if would still want
> to add it I would put close to '__time' implementation rather than
> the '__time64'.

Ok. I will remove it.

> 
> > +# include <time.h>
> > +# include <time-clockid.h>
> > +# include <errno.h>
> > +/* Return the time now, and store it in *TIMER if not NULL.  */  
> 
> Space after the include.

Those #includes are following the 
#else /* USE_IFUNC_TIME  */
and the same indentation is used in other places in this file. I've
just followed it.

> 
> > +
> > +__time64_t
> > +__time64 (__time64_t *timer)
> > +{
> > +  struct __timespec64 ts;
> > +  __clock_gettime64 (TIME_CLOCK_GETTIME_CLOCKID, &ts);
> > +
> > +  if (timer)  
> 
> No implicit checks, use 'if (timer != NULL)'.

Ok.

> 
> > +    *timer = ts.tv_sec;
> > +  return ts.tv_sec;
> > +}
> > +
> > +# if __TIMESIZE != 64
> > +libc_hidden_def (__time64)  
> 
> Ok.
> 
> > +
> > +time_t
> > +__time (time_t *timer)
> > +{
> > +  __time64_t t = __time64 (NULL);
> > +
> > +  if (! in_time_t_range (t))
> > +    {
> > +      __set_errno (EOVERFLOW);
> > +      return -1;
> > +    }
> > +
> > +  if (timer)  
> 
> No implicit checks, use 'if (timer != NULL)'.

Ok.

> 
> > +    *timer = t;
> > +  return t;
> > +}
> > +# endif
> > +weak_alias (__time, time)
> >  #endif
> >   




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

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2020-10-16 10:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15 12:34 Lukasz Majewski
2020-10-15 13:03 ` Adhemerval Zanella
2020-10-16 10:18   ` Lukasz Majewski [this message]

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=20201016121822.61880806@jawa \
    --to=lukma@denx.de \
    --cc=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=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@suse.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).