public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@redhat.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	libc-alpha@sourceware.org
Subject: Re: [PATCH v2 18/25] time: Add 64 bit time support for getdate
Date: Fri, 4 Jun 2021 15:38:49 -0400	[thread overview]
Message-ID: <6362393b-2e35-8484-7925-f89a08a17d1c@redhat.com> (raw)
In-Reply-To: <20210518205613.1487824-19-adhemerval.zanella@linaro.org>

On 5/18/21 4:56 PM, Adhemerval Zanella wrote:
> The getdate is basically a wrapper localtime and mktime.  The 64 bit
> time support is done calling the 64 bit internal functions, there is
> no need to add a new symbol version.
> 
> Checked on x86_64-linux-gnu and i686-linux-gnu.

LGTM.

No regressions on x86_64, i686, ppc64le, aarch64, s390x.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  include/sys/stat.h |  2 +-
>  include/time.h     | 12 ++++++++++--
>  time/getdate.c     | 22 ++++++++++------------
>  time/tst-getdate.c | 14 ++++----------
>  4 files changed, 25 insertions(+), 25 deletions(-)
> 
> diff --git a/include/sys/stat.h b/include/sys/stat.h
> index b4c9344628..13e777b3c7 100644
> --- a/include/sys/stat.h
> +++ b/include/sys/stat.h
> @@ -46,7 +46,7 @@ hidden_proto (__lstat64)
>  hidden_proto (__fstatat64)
>  # endif
>  
> -# if __TIMESIZE == 64
> +# if __TIMESIZE == 64 || defined NO_RTLD_HIDDEN

OK. For hurd.

>  #  define __stat64_time64  __stat64
>  #  define __fstat64_time64  __fstat64
>  #  define __lstat64_time64  __lstat64
> diff --git a/include/time.h b/include/time.h
> index 4372bfbd96..980c6bd924 100644
> --- a/include/time.h
> +++ b/include/time.h
> @@ -283,8 +283,8 @@ hidden_proto (__nanosleep64)
>  #endif
>  
>  
> -extern int __getdate_r (const char *__string, struct tm *__resbufp)
> -  attribute_hidden;
> +extern int __getdate_r (const char *__string, struct tm *__resbufp);
> +libc_hidden_proto (__getdate_r);

OK.

>  
>  
>  /* Determine CLK_TCK value.  */
> @@ -509,6 +509,14 @@ time_now (void)
>    return ts.tv_sec;
>  }
>  
> +static inline __time64_t
> +time64_now (void)
> +{
> +  struct __timespec64 ts;
> +  __clock_gettime64 (TIME_CLOCK_GETTIME_CLOCKID, &ts);
> +  return ts.tv_sec;
> +}

OK.

> +
>  #define NSEC_PER_SEC    1000000000L  /* Nanoseconds per second.  */
>  #define USEC_PER_SEC    1000000L     /* Microseconds per second.  */
>  #define NSEC_PER_USEC   1000L        /* Nanoseconds per microsecond.  */
> diff --git a/time/getdate.c b/time/getdate.c
> index 6e2f75566b..cdcc898517 100644
> --- a/time/getdate.c
> +++ b/time/getdate.c
> @@ -112,16 +112,16 @@ __getdate_r (const char *string, struct tm *tp)
>    size_t len;
>    char *datemsk;
>    char *result = NULL;
> -  time_t timer;
> +  __time64_t timer;
>    struct tm tm;
> -  struct stat64 st;
> -  int mday_ok = 0;
> +  struct __stat64_t64 st;
> +  bool mday_ok = false;
>  
>    datemsk = getenv ("DATEMSK");
>    if (datemsk == NULL || *datemsk == '\0')
>      return 1;
>  
> -  if (__stat64 (datemsk, &st) < 0)
> +  if (__stat64_time64 (datemsk, &st) < 0)
>      return 3;
>  
>    if (!S_ISREG (st.st_mode))
> @@ -219,8 +219,8 @@ __getdate_r (const char *string, struct tm *tp)
>      return 7;
>  
>    /* Get current time.  */
> -  timer = time_now ();
> -  __localtime_r (&timer, &tm);
> +  timer = time64_now ();
> +  __localtime64_r (&timer, &tm);
>  
>    /* If only the weekday is given, today is assumed if the given day
>       is equal to the current day and next week if it is less.  */
> @@ -230,7 +230,7 @@ __getdate_r (const char *string, struct tm *tp)
>        tp->tm_year = tm.tm_year;
>        tp->tm_mon = tm.tm_mon;
>        tp->tm_mday = tm.tm_mday + (tp->tm_wday - tm.tm_wday + 7) % 7;
> -      mday_ok = 1;
> +      mday_ok = true;
>      }
>  
>    /* If only the month is given, the current month is assumed if the
> @@ -242,7 +242,7 @@ __getdate_r (const char *string, struct tm *tp)
>        if (tp->tm_year == INT_MIN)
>  	tp->tm_year = tm.tm_year + (((tp->tm_mon - tm.tm_mon) < 0) ? 1 : 0);
>        tp->tm_mday = first_wday (tp->tm_year, tp->tm_mon, tp->tm_wday);
> -      mday_ok = 1;
> +      mday_ok = true;
>      }
>  
>    /* If no hour, minute and second are given the current hour, minute
> @@ -285,15 +285,13 @@ __getdate_r (const char *string, struct tm *tp)
>       call normalizes the struct tm.  */
>    if ((!mday_ok && !check_mday (TM_YEAR_BASE + tp->tm_year, tp->tm_mon,
>  				tp->tm_mday))
> -      || mktime (tp) == (time_t) -1)
> +      || __mktime64 (tp) == (time_t) -1)
>      return 8;
>  
>    return 0;
>  }
> -#ifdef weak_alias
>  weak_alias (__getdate_r, getdate_r)
> -#endif
> -
> +libc_hidden_def (__getdate_r)
>  

OK.

>  struct tm *
>  getdate (const char *string)
> diff --git a/time/tst-getdate.c b/time/tst-getdate.c
> index c37ba3083a..3bb0e96707 100644
> --- a/time/tst-getdate.c
> +++ b/time/tst-getdate.c
> @@ -115,20 +115,14 @@ do_test (void)
>      {
>        setenv ("TZ", tests[i].tz, 1);
>  
> -      int expected_err;
> -      if (sizeof (time_t) == 4 && tests[i].time64)
> -	expected_err = 8;
> -      else
> -	expected_err = 0;

OK.

> -
>        tm = getdate (tests[i].str);
> -      TEST_COMPARE (getdate_err, expected_err);
> -      if (getdate_err != expected_err)
> +      TEST_COMPARE (getdate_err, 0);
> +      if (getdate_err != 0)
>  	{
>  	  support_record_failure ();
>  	  printf ("%s\n", report_date_error ());
>  	}
> -      else if (getdate_err == 0)
> +      else
>  	{
>  	  TEST_COMPARE (tests[i].tm.tm_mon, tm->tm_mon);
>  	  TEST_COMPARE (tests[i].tm.tm_year, tm->tm_year);
> @@ -139,7 +133,7 @@ do_test (void)
>  	}
>  
>        struct tm tms;
> -      TEST_COMPARE (getdate_r (tests[i].str, &tms), expected_err);
> +      TEST_COMPARE (getdate_r (tests[i].str, &tms), 0);
>        if (getdate_err == 0)
>  	{
>  	  TEST_COMPARE (tests[i].tm.tm_mon, tms.tm_mon);
> 


-- 
Cheers,
Carlos.


  parent reply	other threads:[~2021-06-04 19:38 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 20:55 [PATCH v2 00/25] Add 64 bit time support on legacy ABIs Adhemerval Zanella
2021-05-18 20:55 ` [PATCH v2 01/25] linux: mips: Split libpthread.abilist in n32 and n64 Adhemerval Zanella
2021-05-19  8:24   ` Lukasz Majewski
2021-05-20  6:38   ` Florian Weimer
2021-05-20 10:43     ` Adhemerval Zanella
2021-06-04 19:29   ` Carlos O'Donell
2021-05-18 20:55 ` [PATCH v2 02/25] linux: mips: Split librt.abilist " Adhemerval Zanella
2021-05-19  8:25   ` Lukasz Majewski
2021-06-04 19:29   ` Carlos O'Donell
2021-05-18 20:55 ` [PATCH v2 03/25] linux: mips: Split libanl.abilist " Adhemerval Zanella
2021-05-19  8:25   ` Lukasz Majewski
2021-06-04 19:30   ` Carlos O'Donell
2021-05-18 20:55 ` [PATCH v2 04/25] linux: s390: Add libanl.abilist in s390 and s390x Adhemerval Zanella
2021-05-19  8:26   ` Lukasz Majewski
2021-06-04 19:30   ` Carlos O'Donell
2021-05-18 20:55 ` [PATCH v2 05/25] linux: Add fallback for 64-bit time_t SO_{RCV, SND}TIMEO Adhemerval Zanella
2021-05-19  8:36   ` [PATCH v2 05/25] linux: Add fallback for 64-bit time_t SO_{RCV,SND}TIMEO Lukasz Majewski
2021-05-20  6:44   ` [PATCH v2 05/25] linux: Add fallback for 64-bit time_t SO_{RCV, SND}TIMEO Florian Weimer
2021-05-20 18:01     ` Adhemerval Zanella
2021-05-21 18:37       ` Florian Weimer
2021-05-21 19:17         ` Adhemerval Zanella
2021-06-04 19:30   ` [PATCH v2 05/25] linux: Add fallback for 64-bit time_t SO_{RCV,SND}TIMEO Carlos O'Donell
2021-06-07 17:52     ` Adhemerval Zanella
2021-05-18 20:55 ` [PATCH v2 06/25] linux: Add fallback for 64-bit time_t SO_TIMESTAMP{NS} Adhemerval Zanella
2021-05-19  8:50   ` Lukasz Majewski
2021-05-20  6:50   ` Florian Weimer
2021-05-20 18:46     ` Adhemerval Zanella
2021-05-21 18:38       ` Florian Weimer
2021-05-21 19:02         ` Adhemerval Zanella
2021-06-04 19:30   ` Carlos O'Donell
2021-05-18 20:55 ` [PATCH v2 07/25] linux: Add recvvmsg " Adhemerval Zanella
2021-05-19  9:02   ` Lukasz Majewski
2021-06-04 19:30   ` Carlos O'Donell
2021-05-18 20:55 ` [PATCH v2 08/25] y2038: Add __USE_TIME_BITS64 support for time_t Adhemerval Zanella
2021-05-19  9:02   ` Lukasz Majewski
2021-06-04 19:30   ` Carlos O'Donell
2021-05-18 20:55 ` [PATCH v2 09/25] y2038: Add __USE_TIME_BITS64 support for struct timeval Adhemerval Zanella
2021-05-19  9:03   ` Lukasz Majewski
2021-06-04 19:31   ` Carlos O'Donell
2021-05-18 20:55 ` [PATCH v2 10/25] y2038: Add __USE_TIME_BITS64 support for struct timespec Adhemerval Zanella
2021-05-19  9:03   ` Lukasz Majewski
2021-06-04 19:31   ` Carlos O'Donell
2021-05-18 20:55 ` [PATCH v2 11/25] y2038: Add __USE_TIME_BITS64 support for struct utimbuf Adhemerval Zanella
2021-05-19  9:04   ` Lukasz Majewski
2021-06-04 19:31   ` Carlos O'Donell
2021-05-18 20:56 ` [PATCH v2 12/25] y2038: linux: Add __USE_TIME_BITS64 support for struct timex Adhemerval Zanella
2021-05-19  9:04   ` Lukasz Majewski
2021-06-04 19:31   ` Carlos O'Donell
2021-05-18 20:56 ` [PATCH v2 13/25] y2038: Use a common definition for stat Adhemerval Zanella
2021-06-04 19:37   ` Carlos O'Donell
2021-06-07 18:07     ` Adhemerval Zanella
2021-05-18 20:56 ` [PATCH v2 14/25] y2038: Use a common definition for msqid_ds Adhemerval Zanella
2021-06-04 19:38   ` Carlos O'Donell
2021-06-07 18:29     ` Adhemerval Zanella
2021-05-18 20:56 ` [PATCH v2 15/25] y2038: Use a common definition for semid_ds Adhemerval Zanella
2021-05-19  9:09   ` Lukasz Majewski
2021-06-04 19:38   ` Carlos O'Donell
2021-06-07 18:46     ` Adhemerval Zanella
2021-05-18 20:56 ` [PATCH v2 16/25] y2038: Use a common definition for shmid_ds Adhemerval Zanella
2021-05-19  9:09   ` Lukasz Majewski
2021-06-04 19:38   ` Carlos O'Donell
2021-05-18 20:56 ` [PATCH v2 17/25] y2038: Add __USE_TIME_BITS64 support for socket-constants.h Adhemerval Zanella
2021-05-19  9:13   ` Lukasz Majewski
2021-06-04 19:38   ` Carlos O'Donell
2021-05-18 20:56 ` [PATCH v2 18/25] time: Add 64 bit time support for getdate Adhemerval Zanella
2021-05-19  9:15   ` Lukasz Majewski
2021-06-04 19:38   ` Carlos O'Donell [this message]
2021-05-18 20:56 ` [PATCH v2 19/25] y2038: Add support for 64 bit time on legacy ABIs Adhemerval Zanella
2021-05-19  9:18   ` Lukasz Majewski
2021-05-20  6:58   ` Florian Weimer
2021-05-20 10:37     ` Adhemerval Zanella
2021-06-04 19:38   ` Carlos O'Donell
2021-05-18 20:56 ` [PATCH v2 20/25] posix: Add glob64 with 64 bit time_t support Adhemerval Zanella
2021-05-19 10:44   ` Lukasz Majewski
2021-06-04 19:39   ` Carlos O'Donell
2021-06-07 18:52     ` Adhemerval Zanella
2021-05-18 20:56 ` [PATCH v2 21/25] io: Add fts64 " Adhemerval Zanella
2021-05-19 10:50   ` Lukasz Majewski
2021-06-04 19:39   ` Carlos O'Donell
2021-05-18 20:56 ` [PATCH v2 22/25] io: Add ftw64 " Adhemerval Zanella
2021-05-19 10:57   ` Lukasz Majewski
2021-06-04 19:39   ` Carlos O'Donell
2021-05-18 20:56 ` [PATCH v2 23/25] libsupport: Add 64 bit time_t support for time functions Adhemerval Zanella
2021-05-19 11:00   ` Lukasz Majewski
2021-06-04 19:39   ` Carlos O'Donell
2021-05-18 20:56 ` [PATCH v2 24/25] libsupport: Add 64 bit time_t support for stat functions Adhemerval Zanella
2021-05-19 11:04   ` Lukasz Majewski
2021-06-04 19:39   ` Carlos O'Donell
2021-05-18 20:56 ` [PATCH v2 25/25] y2038: Add test coverage Adhemerval Zanella
2021-05-19 11:08   ` Lukasz Majewski
2021-06-04 19:39   ` Carlos O'Donell
2021-06-04 19:29 ` [PATCH v2 00/25] Add 64 bit time support on legacy ABIs Carlos O'Donell

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=6362393b-2e35-8484-7925-f89a08a17d1c@redhat.com \
    --to=carlos@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    /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).