From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 141B639A003A for ; Fri, 4 Jun 2021 19:38:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 141B639A003A Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-345-5_kXzdA2NuuyJ6RFns65Yg-1; Fri, 04 Jun 2021 15:38:51 -0400 X-MC-Unique: 5_kXzdA2NuuyJ6RFns65Yg-1 Received: by mail-qv1-f71.google.com with SMTP id i16-20020a0cf4900000b029022023514900so3022028qvm.11 for ; Fri, 04 Jun 2021 12:38:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=rseGqgrDm6kVXhNpcbWfzDmnvOE3aayqUfXBSn8IGaQ=; b=QrfknXFDSfzxmyuTM7XG3lpGVlI/JhvmWdz0R9oxsFyiBEDI0JCTUP7FqOg259iN1F 3UaFKDNvgic/I2TkyhJFhR454qIkoOAnDuWy/H+vZ4fPpqdcf6DsxSFPjIG/WMVvCg+n p5hjZjX5o+MF3dKDKAzB27IAeuS+AXFLdlXJtZ/XpD4Z5SH8zRzZ5ustSZ5c8t7wSkWI ur0GPVRdUv02QVxjvMvUI+VeHtBfRz6qwv9Z7wmqt8+1JiJ/EuMUu9jw5q5Ot6cjYAHZ ZSTgBKqXJN5LEsfE3Oe72x8S1R7GST+7kFza6o07edrt92N5jRrO0o/PB0ERjCAKXHzE XcFA== X-Gm-Message-State: AOAM533s/5ZAiEATObf3d2Ni448xzJwQ/hSx/chHo+MnR0swU99zdeyS Cxz58K+bJkwYVHVRyuVyJmvo89GQBQ16BDf6QzOPoFap0A/35Ma8uVlFUni8W2fHpP63Xd0AR6J B7aaVRCSEna9CYjmvGeB9 X-Received: by 2002:ac8:74d3:: with SMTP id j19mr1310445qtr.208.1622835530673; Fri, 04 Jun 2021 12:38:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyix+xxd8JGwTJSmYQuAH7rf6WcViTv3HwyIAX/xS3cmBYcG3D3nHjYc6XoNT+lbuSHAYVCqQ== X-Received: by 2002:ac8:74d3:: with SMTP id j19mr1310421qtr.208.1622835530386; Fri, 04 Jun 2021 12:38:50 -0700 (PDT) Received: from [192.168.1.16] (198-84-214-74.cpe.teksavvy.com. [198.84.214.74]) by smtp.gmail.com with ESMTPSA id d16sm4163295qtj.69.2021.06.04.12.38.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Jun 2021 12:38:49 -0700 (PDT) Subject: Re: [PATCH v2 18/25] time: Add 64 bit time support for getdate To: Adhemerval Zanella , libc-alpha@sourceware.org References: <20210518205613.1487824-1-adhemerval.zanella@linaro.org> <20210518205613.1487824-19-adhemerval.zanella@linaro.org> From: Carlos O'Donell Organization: Red Hat Message-ID: <6362393b-2e35-8484-7925-f89a08a17d1c@redhat.com> Date: Fri, 4 Jun 2021 15:38:49 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210518205613.1487824-19-adhemerval.zanella@linaro.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jun 2021 19:38:56 -0000 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 Tested-by: Carlos O'Donell > --- > 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.