From patchwork Thu Nov 29 22:10:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Albert ARIBAUD (3ADEV)" X-Patchwork-Id: 1005679 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-97715-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=3adev.fr Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="OpKMKO5/"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 435WtV1PMLz9s8r for ; Fri, 30 Nov 2018 09:10:42 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=aHHOQFYPNN2nYUvBmhC0AIAfkO44xnp XFu5fsIkWkmZOTk6O3MJESFMMoJXgHEzSgeu8VY6FlwNnxoE+wrVV6gm0tASsHaD GYN/pAhkGF8Kvfo+4lCtkxea4xblWRN/bnqHd5yJj8k6CqwwBFlt10j1HXddkaOT 6ONfdrLI++xU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=SxW7hzxsFvnZ0PcjHnG2drKkMJw=; b=OpKMK O5/mHc1m3tYi2YmfnEdk0ab4N7gUhS3ncP0DOMvqm/fjhFtxpNw80DDZ+LI/eom3 KkdSq6PexYf/CikkW+22+cINlEIPdIJmN5qRrD+UuZEsQAZY9sYdqEjT0N+byTUp P6Pf63vSInUzINbONInSMLOabaTYs0h1vYM40E= Received: (qmail 27204 invoked by alias); 29 Nov 2018 22:10:18 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 27042 invoked by uid 89); 29 Nov 2018 22:10:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_RP_RNBL autolearn=ham version=3.3.2 spammy=DAYS, Operations, 1900, subroutine X-HELO: smtp3-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Subject: [PATCH v2 1/9] Y2038: make __tz_convert compatible with 64-bit-time Date: Thu, 29 Nov 2018 23:10:02 +0100 Message-Id: <20181129221010.19589-2-albert.aribaud@3adev.fr> In-Reply-To: <20181129221010.19589-1-albert.aribaud@3adev.fr> References: <20181129221010.19589-1-albert.aribaud@3adev.fr> Now that __time64_t exists, we can switch internal function __tz_convert from 32-bit to 64-bit time. This involves switching some other internal functions as well, namely __tz_compute and __offtime. Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu. * include/time.h (__tz_compute): Replace time_t with __time64_t. (__tz_convert): Replace time_t* with __time64_t. (__offtime): Replace time_t* with __time64_t. * time/gmtime.c (__gmtime_r): Adjust call to __tz_convert. (gmtime): Likewise. * time/localtime.c (__localtime_r): Likewise. (localtime): Likewise. * time/offtime.c: Replace time_t with __time64_t. * time/tzset.c: Likewise. --- include/time.h | 8 ++++---- time/gmtime.c | 4 ++-- time/localtime.c | 4 ++-- time/offtime.c | 12 ++++++------ time/tzfile.c | 14 ++++---------- time/tzset.c | 27 ++++++++++----------------- 6 files changed, 28 insertions(+), 41 deletions(-) diff --git a/include/time.h b/include/time.h index 861b1acfb7..37964f7b76 100644 --- a/include/time.h +++ b/include/time.h @@ -46,7 +46,7 @@ extern void __tzfile_default (const char *std, const char *dst, long int stdoff, long int dstoff) attribute_hidden; extern void __tzset_parse_tz (const char *tz) attribute_hidden; -extern void __tz_compute (time_t timer, struct tm *tm, int use_localtime) +extern void __tz_compute (__time64_t timer, struct tm *tm, int use_localtime) __THROW attribute_hidden; /* Subroutine of `mktime'. Return the `time_t' representation of TP and @@ -63,11 +63,11 @@ extern struct tm *__gmtime_r (const time_t *__restrict __timer, struct tm *__restrict __tp); libc_hidden_proto (__gmtime_r) -/* Compute the `struct tm' representation of *T, +/* Compute the `struct tm' representation of T, offset OFFSET seconds east of UTC, and store year, yday, mon, mday, wday, hour, min, sec into *TP. Return nonzero if successful. */ -extern int __offtime (const time_t *__timer, +extern int __offtime (__time64_t __timer, long int __offset, struct tm *__tp) attribute_hidden; @@ -76,7 +76,7 @@ extern char *__asctime_r (const struct tm *__tp, char *__buf) extern void __tzset (void) attribute_hidden; /* Prototype for the internal function to get information based on TZ. */ -extern struct tm *__tz_convert (const time_t *timer, int use_localtime, +extern struct tm *__tz_convert (__time64_t timer, int use_localtime, struct tm *tp) attribute_hidden; extern int __nanosleep (const struct timespec *__requested_time, diff --git a/time/gmtime.c b/time/gmtime.c index dc33b3e68a..bda09bc021 100644 --- a/time/gmtime.c +++ b/time/gmtime.c @@ -23,7 +23,7 @@ struct tm * __gmtime_r (const time_t *t, struct tm *tp) { - return __tz_convert (t, 0, tp); + return __tz_convert (*t, 0, tp); } libc_hidden_def (__gmtime_r) weak_alias (__gmtime_r, gmtime_r) @@ -33,5 +33,5 @@ weak_alias (__gmtime_r, gmtime_r) struct tm * gmtime (const time_t *t) { - return __tz_convert (t, 0, &_tmbuf); + return __tz_convert (*t, 0, &_tmbuf); } diff --git a/time/localtime.c b/time/localtime.c index 8684a8a971..92dbfe0f8c 100644 --- a/time/localtime.c +++ b/time/localtime.c @@ -27,7 +27,7 @@ struct tm _tmbuf; struct tm * __localtime_r (const time_t *t, struct tm *tp) { - return __tz_convert (t, 1, tp); + return __tz_convert (*t, 1, tp); } weak_alias (__localtime_r, localtime_r) @@ -36,6 +36,6 @@ weak_alias (__localtime_r, localtime_r) struct tm * localtime (const time_t *t) { - return __tz_convert (t, 1, &_tmbuf); + return __tz_convert (*t, 1, &_tmbuf); } libc_hidden_def (localtime) diff --git a/time/offtime.c b/time/offtime.c index 04c48389fc..3309fcd484 100644 --- a/time/offtime.c +++ b/time/offtime.c @@ -21,18 +21,18 @@ #define SECS_PER_HOUR (60 * 60) #define SECS_PER_DAY (SECS_PER_HOUR * 24) -/* Compute the `struct tm' representation of *T, +/* Compute the `struct tm' representation of T, offset OFFSET seconds east of UTC, and store year, yday, mon, mday, wday, hour, min, sec into *TP. Return nonzero if successful. */ int -__offtime (const time_t *t, long int offset, struct tm *tp) +__offtime (__time64_t t, long int offset, struct tm *tp) { - time_t days, rem, y; + __time64_t days, rem, y; const unsigned short int *ip; - days = *t / SECS_PER_DAY; - rem = *t % SECS_PER_DAY; + days = t / SECS_PER_DAY; + rem = t % SECS_PER_DAY; rem += offset; while (rem < 0) { @@ -60,7 +60,7 @@ __offtime (const time_t *t, long int offset, struct tm *tp) while (days < 0 || days >= (__isleap (y) ? 366 : 365)) { /* Guess a corrected year, assuming 365 days per year. */ - time_t yg = y + days / 365 - (days % 365 < 0); + __time64_t yg = y + days / 365 - (days % 365 < 0); /* Adjust DAYS and Y to match the guessed year. */ days -= ((yg - y) * 365 diff --git a/time/tzfile.c b/time/tzfile.c index 844a68de8c..3920525bf3 100644 --- a/time/tzfile.c +++ b/time/tzfile.c @@ -633,16 +633,10 @@ __tzfile_compute (__time64_t timer, int use_localtime, /* Convert to broken down structure. If this fails do not use the string. */ - { - time_t truncated = timer; - if (__glibc_unlikely (truncated != timer - || ! __offtime (&truncated, 0, tp))) - goto use_last; - } - - /* Use the rules from the TZ string to compute the change. - timer fits into time_t due to the truncation check - above. */ + if (__glibc_unlikely (! __offtime (timer, 0, tp))) + goto use_last; + + /* Use the rules from the TZ string to compute the change. */ __tz_compute (timer, tp, 1); /* If tzspec comes from posixrules loaded by __tzfile_default, diff --git a/time/tzset.c b/time/tzset.c index a828b9fb75..834cc3ccec 100644 --- a/time/tzset.c +++ b/time/tzset.c @@ -16,7 +16,6 @@ . */ #include -#include #include #include #include @@ -27,7 +26,7 @@ #include -#define SECSPERDAY ((time_t) 86400) +#define SECSPERDAY ((__time64_t) 86400) char *__tzname[2] = { (char *) "GMT", (char *) "GMT" }; int __daylight = 0; @@ -55,7 +54,7 @@ typedef struct /* We cache the computed time of change for a given year so we don't have to recompute it. */ - time_t change; /* When to change to this zone. */ + __time64_t change; /* When to change to this zone. */ int computed_for; /* Year above is computed for. */ } tz_rule; @@ -416,7 +415,7 @@ tzset_internal (int always) tz_rules[0].name = tz_rules[1].name = "UTC"; if (J0 != 0) tz_rules[0].type = tz_rules[1].type = J0; - tz_rules[0].change = tz_rules[1].change = (time_t) -1; + tz_rules[0].change = tz_rules[1].change = -1; update_vars (); return; } @@ -424,13 +423,13 @@ tzset_internal (int always) __tzset_parse_tz (tz); } -/* Figure out the exact time (as a time_t) in YEAR +/* Figure out the exact time (as a __time64_t) in YEAR when the change described by RULE will occur and put it in RULE->change, saving YEAR in RULE->computed_for. */ static void compute_change (tz_rule *rule, int year) { - time_t t; + __time64_t t; if (year != -1 && rule->computed_for == year) /* Operations on times in 2 BC will be slower. Oh well. */ @@ -516,7 +515,7 @@ compute_change (tz_rule *rule, int year) /* Figure out the correct timezone for TM and set `__tzname', `__timezone', and `__daylight' accordingly. */ void -__tz_compute (time_t timer, struct tm *tm, int use_localtime) +__tz_compute (__time64_t timer, struct tm *tm, int use_localtime) { compute_change (&tz_rules[0], 1900 + tm->tm_year); compute_change (&tz_rules[1], 1900 + tm->tm_year); @@ -562,20 +561,14 @@ __tzset (void) } weak_alias (__tzset, tzset) -/* Return the `struct tm' representation of *TIMER in the local timezone. +/* Return the `struct tm' representation of TIMER in the local timezone. Use local time if USE_LOCALTIME is nonzero, UTC otherwise. */ struct tm * -__tz_convert (const time_t *timer, int use_localtime, struct tm *tp) +__tz_convert (__time64_t timer, int use_localtime, struct tm *tp) { long int leap_correction; int leap_extra_secs; - if (timer == NULL) - { - __set_errno (EINVAL); - return NULL; - } - __libc_lock_lock (tzset_lock); /* Update internal database according to current TZ setting. @@ -584,14 +577,14 @@ __tz_convert (const time_t *timer, int use_localtime, struct tm *tp) tzset_internal (tp == &_tmbuf && use_localtime); if (__use_tzfile) - __tzfile_compute (*timer, use_localtime, &leap_correction, + __tzfile_compute (timer, use_localtime, &leap_correction, &leap_extra_secs, tp); else { if (! __offtime (timer, 0, tp)) tp = NULL; else - __tz_compute (*timer, tp, use_localtime); + __tz_compute (timer, tp, use_localtime); leap_correction = 0L; leap_extra_secs = 0; } From patchwork Thu Nov 29 22:10:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Albert ARIBAUD (3ADEV)" X-Patchwork-Id: 1005678 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-97714-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=3adev.fr Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="L2YHD7EU"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 435WtH061Qz9s8r for ; Fri, 30 Nov 2018 09:10:30 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=bPRUxUkzsqJdjfKoWGxDKOso/x4dxRB YFXb7YjiVF20m44x6xFP9xOWeAR3Th4ashYtltoJRzBugw7jpvqsIiVGgQrRo48I q4E7DDeG5zOv44x4HjgyAvubX9I5crbxBe6S/FvsMWkgSmS1iMH89ETcZxaK8KiL t3Z3b2TdX2i4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=FuYVQItlV7pCBTShvEb9Pd67ei0=; b=L2YHD 7EUsX0a2/JBpuyAxNBJj4QvKB+/MXecTb9OyJ1H32LQVwoKsdLiRy+1jnuDjBAjU d3RY/xm/Nf9ImgzS4nCISlEG31cefohpaCXbixalNzHf8oewNxZ/24BD4yoKgvSU L9Gk+CNNF3O74R8fpKD3bTPcXshB94EPvS/JhU= Received: (qmail 26991 invoked by alias); 29 Nov 2018 22:10:17 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 26885 invoked by uid 89); 29 Nov 2018 22:10:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_RP_RNBL autolearn=ham version=3.3.2 spammy= X-HELO: smtp3-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Subject: [PATCH v2 2/9] Y2038: add function __localtime64 Date: Thu, 29 Nov 2018 23:10:03 +0100 Message-Id: <20181129221010.19589-3-albert.aribaud@3adev.fr> In-Reply-To: <20181129221010.19589-1-albert.aribaud@3adev.fr> References: <20181129221010.19589-1-albert.aribaud@3adev.fr> Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu. * include/time.h (__localtime64): Add. * time/localtime.c (__localtime64): Add. (__localtime): Compile only if __TIMERSIZE != 64. --- include/time.h | 9 ++++++++- time/localtime.c | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/time.h b/include/time.h index 37964f7b76..251a2b0329 100644 --- a/include/time.h +++ b/include/time.h @@ -56,9 +56,16 @@ extern time_t __mktime_internal (struct tm *__tp, struct tm *(*__func) (const time_t *, struct tm *), long int *__offset) attribute_hidden; + +#if __TIMESIZE == 64 +# define __localtime64 localtime +#else +extern struct tm *__localtime64 (const __time64_t *__timer); +libc_hidden_proto (__localtime64) +#endif + extern struct tm *__localtime_r (const time_t *__timer, struct tm *__tp) attribute_hidden; - extern struct tm *__gmtime_r (const time_t *__restrict __timer, struct tm *__restrict __tp); libc_hidden_proto (__gmtime_r) diff --git a/time/localtime.c b/time/localtime.c index 92dbfe0f8c..917e0db40a 100644 --- a/time/localtime.c +++ b/time/localtime.c @@ -21,7 +21,6 @@ /* The C Standard says that localtime and gmtime return the same pointer. */ struct tm _tmbuf; - /* Return the `struct tm' representation of *T in local time, using *TP to store the result. */ struct tm * @@ -31,11 +30,23 @@ __localtime_r (const time_t *t, struct tm *tp) } weak_alias (__localtime_r, localtime_r) - /* Return the `struct tm' representation of *T in local time. */ +struct tm * +__localtime64 (const __time64_t *t) +{ + return __tz_convert (*t, 1, &_tmbuf); +} +libc_hidden_def (__localtime64) + +/* Provide a 32-bit variant if needed */ + +#if __TIMESIZE != 64 + struct tm * localtime (const time_t *t) { return __tz_convert (*t, 1, &_tmbuf); } libc_hidden_def (localtime) + +#endif From patchwork Thu Nov 29 22:10:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Albert ARIBAUD (3ADEV)" X-Patchwork-Id: 1005680 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-97716-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=3adev.fr Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="w96rL6U0"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 435Wtg0Vy2z9s8r for ; Fri, 30 Nov 2018 09:10:50 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=y5wyXGCWHqzYCdpspCGrfS61qi/K0fc fFAqXYrId3JAlMA6DHXS701kid5/oBYdPCSz22qLmD/VQQwUM7K2tKZo7TI3bXL2 mbf+bAPTyMfHaRYqribuDbogmqtOGmMSRudlTvtoi5OtNHDVDlo5+QTug0UnKzjq BQdgpQ10GHV8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=6vYC7xYXuuYYrYOpEGDXSkkrWxs=; b=w96rL 6U0S0Ylc/+nrqh1P18OCOY2G5TiJ67C513TWKLhG0X3PEn61yo51qlqHtnnrSoOO +TPCNzdxxL5wSfvWrvJMYGcJzIddYgF49RVDaI2JrBuQGdYqEKFAmtNmuS+DxDh2 zNhIm0LDq1tcnpD8H0yEy9jpa6oTp0mJUt4YQs= Received: (qmail 27254 invoked by alias); 29 Nov 2018 22:10:18 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 27084 invoked by uid 89); 29 Nov 2018 22:10:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RCVD_IN_RP_RNBL autolearn=ham version=3.3.2 spammy=Hx-languages-length:1787 X-HELO: smtp3-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Subject: [PATCH v2 3/9] Y2038: add function __localtime64_r Date: Thu, 29 Nov 2018 23:10:04 +0100 Message-Id: <20181129221010.19589-4-albert.aribaud@3adev.fr> In-Reply-To: <20181129221010.19589-1-albert.aribaud@3adev.fr> References: <20181129221010.19589-1-albert.aribaud@3adev.fr> Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu. * include/time.h (__localtime64_r): Add. * time/localtime.c (__localtime64_r): Add. (__localtime_r): Compile only if __TIMERSIZE != 64. --- include/time.h | 8 ++++++++ time/localtime.c | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/time.h b/include/time.h index 251a2b0329..34368295a9 100644 --- a/include/time.h +++ b/include/time.h @@ -66,6 +66,14 @@ libc_hidden_proto (__localtime64) extern struct tm *__localtime_r (const time_t *__timer, struct tm *__tp) attribute_hidden; + +#if __TIMESIZE == 64 +# define __localtime64_r __localtime_r +#else +extern struct tm *__localtime64_r (const __time64_t *__timer, + struct tm *__tp) attribute_hidden; +#endif + extern struct tm *__gmtime_r (const time_t *__restrict __timer, struct tm *__restrict __tp); libc_hidden_proto (__gmtime_r) diff --git a/time/localtime.c b/time/localtime.c index 917e0db40a..bafea5548d 100644 --- a/time/localtime.c +++ b/time/localtime.c @@ -23,11 +23,27 @@ struct tm _tmbuf; /* Return the `struct tm' representation of *T in local time, using *TP to store the result. */ +struct tm * +__localtime64_r (const __time64_t *t, struct tm *tp) +{ + return __tz_convert (*t, 1, tp); +} + +/* Provide a 32-bit variant if needed */ + +#if __TIMESIZE != 64 + struct tm * __localtime_r (const time_t *t, struct tm *tp) { return __tz_convert (*t, 1, tp); } + +#endif + +/* This always works because either __TIMESIZE != 64 and __localtime_r + exists or __TIMESIZE == 64 and the definition of __localtime64_r above + actually defined __localtime_r. */ weak_alias (__localtime_r, localtime_r) /* Return the `struct tm' representation of *T in local time. */ From patchwork Thu Nov 29 22:10:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Albert ARIBAUD (3ADEV)" X-Patchwork-Id: 1005681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-97717-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=3adev.fr Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="rQHfaRFr"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 435Wts3SWRz9s8r for ; Fri, 30 Nov 2018 09:11:01 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=axzutzv6W389vnguAvZPKWJF7i01/IR tRUDM2BtLa4OYfNixlGrTMyXQbDl2kP2SN2bjLq4J9U/4IDAsbuG3/HE7Z9vQn1B OXxiw7oPvXm9LRU6owFTVZtVAkKYaEcQdIlbsm0BsaZn3mxzOupdifVw2hAkhERX a5kXAhx6pkfk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=ThIFThH96eAMEh8F1jcaV0PNStE=; b=rQHfa RFrKoRKbmY3gBvPf0K+ujMepuGIMWsUoANSYoPIHvKLHc7IvqRIobUrshzxImBAb Muuhy1awxhDfTiLqUSxy2x8Oq/h9XXBJWwOJAlq6V6pS3wnEMohzOdXpvZrYBdFW loqXnaRfqYqw6zDgvWNZ3GdjJ3WI1LTlFnZXCo= Received: (qmail 27438 invoked by alias); 29 Nov 2018 22:10:19 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 27249 invoked by uid 89); 29 Nov 2018 22:10:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_RP_RNBL autolearn=ham version=3.3.2 spammy= X-HELO: smtp3-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Subject: [PATCH v2 4/9] Y2038: add function __gmtime64 Date: Thu, 29 Nov 2018 23:10:05 +0100 Message-Id: <20181129221010.19589-5-albert.aribaud@3adev.fr> In-Reply-To: <20181129221010.19589-1-albert.aribaud@3adev.fr> References: <20181129221010.19589-1-albert.aribaud@3adev.fr> Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu. * include/time.h (__gmtime64): Add. * time/gmtime.c (__gmtime64): Add. (__gmtime): Compile only if __TIMERSIZE != 64. --- include/time.h | 4 ++++ time/gmtime.c | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/time.h b/include/time.h index 34368295a9..553bf74828 100644 --- a/include/time.h +++ b/include/time.h @@ -78,6 +78,10 @@ extern struct tm *__gmtime_r (const time_t *__restrict __timer, struct tm *__restrict __tp); libc_hidden_proto (__gmtime_r) +#if __TIMESIZE == 64 +# define __gmtime64 gmtime +#endif + /* Compute the `struct tm' representation of T, offset OFFSET seconds east of UTC, and store year, yday, mon, mday, wday, hour, min, sec into *TP. diff --git a/time/gmtime.c b/time/gmtime.c index bda09bc021..46db119e9c 100644 --- a/time/gmtime.c +++ b/time/gmtime.c @@ -25,13 +25,25 @@ __gmtime_r (const time_t *t, struct tm *tp) { return __tz_convert (*t, 0, tp); } + libc_hidden_def (__gmtime_r) weak_alias (__gmtime_r, gmtime_r) +/* Return the `struct tm' representation of *T in UTC. */ +struct tm * +__gmtime64 (const __time64_t *t) +{ + return __tz_convert (*t, 0, &_tmbuf); +} + +/* Provide a 32-bit variant if needed */ + +#if __TIMESIZE != 64 -/* Return the `struct tm' representation of *T in UTC. */ struct tm * gmtime (const time_t *t) { return __tz_convert (*t, 0, &_tmbuf); } + +#endif From patchwork Thu Nov 29 22:10:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Albert ARIBAUD (3ADEV)" X-Patchwork-Id: 1005686 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-97722-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=3adev.fr Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Sm52y3Mi"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 435Wvg4gYtz9s8r for ; Fri, 30 Nov 2018 09:11:43 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=Mw9xcvH+G9LUYiIFcmBxgX2pgB2tZ0X abjykEedhq9727KrrVQ+kA7R3dN/6bVLMFxWXlbAETZLmSvmkboKZ+YQYlGRib03 Yrd6Y6v2fl801++i6TRFEldzg/sEe3pDgZVTMF+17dtPJ7mlWWqFHPbhRLCAxwen rJzvVsYc2qbU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=X8nOj3GOsZAhuUBIVeYaNCAsVPA=; b=Sm52y 3MihGgK7mAlINd/uzQGR4fjbrWhU+PKXrbgd8gQSzvJXvDfKH46Z9iiO8dRCnR74 dClcpayIOB5YrjScjVTBbi4VVtACV24exCzd+WR5vYmJ3NPs+RunpIUOaWoPg2wn PDjKBHlgNWdFyIG23Vh0P8DxAO/MU119eRR120= Received: (qmail 28733 invoked by alias); 29 Nov 2018 22:10:28 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 28552 invoked by uid 89); 29 Nov 2018 22:10:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= X-HELO: smtpfb2-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Subject: [PATCH v2 5/9] Y2038: add function __gmtime64_r Date: Thu, 29 Nov 2018 23:10:06 +0100 Message-Id: <20181129221010.19589-6-albert.aribaud@3adev.fr> In-Reply-To: <20181129221010.19589-1-albert.aribaud@3adev.fr> References: <20181129221010.19589-1-albert.aribaud@3adev.fr> Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu. * include/time.h (__gmtime64_r): Add. * time/gmtime.c (__gmtime64_r): Add. (__gmtime): Compile only if __TIMERSIZE != 64. --- include/time.h | 7 +++++++ time/gmtime.c | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/time.h b/include/time.h index 553bf74828..80543e3673 100644 --- a/include/time.h +++ b/include/time.h @@ -82,6 +82,13 @@ libc_hidden_proto (__gmtime_r) # define __gmtime64 gmtime #endif +#if __TIMESIZE == 64 +# define __gmtime64_r __gmtime_r +#else +extern struct tm *__gmtime64_r (const __time64_t *__restrict __timer, + struct tm *__restrict __tp); +#endif + /* Compute the `struct tm' representation of T, offset OFFSET seconds east of UTC, and store year, yday, mon, mday, wday, hour, min, sec into *TP. diff --git a/time/gmtime.c b/time/gmtime.c index 46db119e9c..4674ffe01e 100644 --- a/time/gmtime.c +++ b/time/gmtime.c @@ -20,12 +20,27 @@ /* Return the `struct tm' representation of *T in UTC, using *TP to store the result. */ +struct tm * +__gmtime64_r (const __time64_t *t, struct tm *tp) +{ + return __tz_convert (*t, 0, tp); +} + +/* Provide a 32-bit variant if needed */ + +#if __TIMESIZE != 64 + struct tm * __gmtime_r (const time_t *t, struct tm *tp) { return __tz_convert (*t, 0, tp); } +#endif + +/* This always works because either __TIMESIZE != 64 and __gmtime_r exists + or __TIMESIZE == 64 and the definition of __gmtime64_r above actually + defined __gmtime_r. */ libc_hidden_def (__gmtime_r) weak_alias (__gmtime_r, gmtime_r) From patchwork Thu Nov 29 22:10:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Albert ARIBAUD (3ADEV)" X-Patchwork-Id: 1005682 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-97718-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=3adev.fr Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Qw9bdOL7"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 435Wv20P5Rz9s9m for ; Fri, 30 Nov 2018 09:11:09 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=jJpC3P4RtrdQ2WvdRPnF/WwVaCQmjT6 eMgIdPuVzJHJwreOyj2VH2DEy/3VZHLH7mwT33OUUE0owBceFF5BucCNOML0c5i2 g0rlFF7/PbHnHLZiQ82FzGH7lxuJ5CbKzHPAGnOAdLqwbQz+I2Cd5ewbJ63vlpKl JJOaSXHzU4Wo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=tTh/zcRU34kebLULkhdTal3mwKQ=; b=Qw9bd OL7KjcMz4D2hVslCmXIK+jq1SWcXQ+X0kAWLHK96e89XqaT70Hu9yVl6jwkV0Oq9 7P5kNdYcNj8SAAJgyV+Wum82nSznEi1K1FTx34rtR24lQXO1HDR4+y4foJ3S0O6c Cw53E493bz7/EZJNFNH4yKXBHPbqEd6DIdwVUc= Received: (qmail 27782 invoked by alias); 29 Nov 2018 22:10:22 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 27652 invoked by uid 89); 29 Nov 2018 22:10:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_RP_RNBL autolearn=ham version=3.3.2 spammy=385 X-HELO: smtp3-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Subject: [PATCH v2 6/9] Y2038: add function __ctime64 Date: Thu, 29 Nov 2018 23:10:07 +0100 Message-Id: <20181129221010.19589-7-albert.aribaud@3adev.fr> In-Reply-To: <20181129221010.19589-1-albert.aribaud@3adev.fr> References: <20181129221010.19589-1-albert.aribaud@3adev.fr> Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu. * include/time.h (__ctime64): Add. * time/gmtime.c (__ctime64): Add. (ctime): Compile only if __TIMERSIZE != 64. --- include/time.h | 7 +++++++ time/ctime.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/time.h b/include/time.h index 80543e3673..0247146211 100644 --- a/include/time.h +++ b/include/time.h @@ -57,6 +57,13 @@ extern time_t __mktime_internal (struct tm *__tp, struct tm *), long int *__offset) attribute_hidden; +/* nis/nis_print.c needs ctime, so even if ctime is not declared here, + we define __ctime64 as ctime so that nis/nis_print.c can get linked + against a function called ctime. */ +#if __TIMESIZE == 64 +# define __ctime64 ctime +#endif + #if __TIMESIZE == 64 # define __localtime64 localtime #else diff --git a/time/ctime.c b/time/ctime.c index 1222614f29..c20059c9a3 100644 --- a/time/ctime.c +++ b/time/ctime.c @@ -19,6 +19,18 @@ /* Return a string as returned by asctime which is the representation of *T in that form. */ +char * +__ctime64 (const __time64_t *t) +{ + /* The C Standard says ctime (t) is equivalent to asctime (localtime (t)). + In particular, ctime and asctime must yield the same pointer. */ + return asctime (__localtime64 (t)); +} + +/* Provide a 32-bit variant if needed */ + +#if __TIMESIZE != 64 + char * ctime (const time_t *t) { @@ -26,3 +38,5 @@ ctime (const time_t *t) In particular, ctime and asctime must yield the same pointer. */ return asctime (localtime (t)); } + +#endif From patchwork Thu Nov 29 22:10:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Albert ARIBAUD (3ADEV)" X-Patchwork-Id: 1005683 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-97719-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=3adev.fr Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="AnaSMr6V"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 435WvB4qzZz9s8r for ; Fri, 30 Nov 2018 09:11:18 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=af7IU1qWpGkkPzGZwYOTEtsvSPX++X3 JH/gXlg6f2IopsfzrDRKLIAkqJZQyv3aG8zRzZ4nhGodgMEVAd6870dbsu8NRQAQ T/GjuuNiJUM5EBckl3obyGifA+pNv7t7PbOnyrAXjS4uQOHNhylhYG7OpqKyW2Yc oFgOM28ggUcE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=BlUokyuLwLYDFr7JXVjo63IQwd0=; b=AnaSM r6VZPaNQziXmctWpWakHdyZpaKqLiE9pW7cgpGz3HgQX1hJ2TCptwRC5+CqbmnsB o2qlGnNoORTQ5MihTvGEtHogQP1USFrgcHVT1sEYc4A8H69pRcXWXasEoPUk4J4o 2uluAdftjhRKobpDgKwKW3fpx7VY0HbYxI896U= Received: (qmail 27934 invoked by alias); 29 Nov 2018 22:10:23 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 27802 invoked by uid 89); 29 Nov 2018 22:10:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RCVD_IN_RP_RNBL autolearn=ham version=3.3.2 spammy=2122, reentrant X-HELO: smtp3-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Subject: [PATCH v2 7/9] Y2038: add function __ctime64_r Date: Thu, 29 Nov 2018 23:10:08 +0100 Message-Id: <20181129221010.19589-8-albert.aribaud@3adev.fr> In-Reply-To: <20181129221010.19589-1-albert.aribaud@3adev.fr> References: <20181129221010.19589-1-albert.aribaud@3adev.fr> Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu. * include/time.h (__ctime64_r): Add. * time/ctime_r.c (__ctime64_r): Add. (__ctime_r): Compile only if __TIMERSIZE != 64. --- include/time.h | 4 ++++ time/ctime_r.c | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/time.h b/include/time.h index 0247146211..c26cfb40f6 100644 --- a/include/time.h +++ b/include/time.h @@ -64,6 +64,10 @@ extern time_t __mktime_internal (struct tm *__tp, # define __ctime64 ctime #endif +#if __TIMESIZE == 64 +# define __ctime64_r ctime_r +#endif + #if __TIMESIZE == 64 # define __localtime64 localtime #else diff --git a/time/ctime_r.c b/time/ctime_r.c index c111146d76..be4e62c86d 100644 --- a/time/ctime_r.c +++ b/time/ctime_r.c @@ -21,9 +21,22 @@ /* Return a string as returned by asctime which is the representation of *T in that form. Reentrant version. */ +char * +__ctime64_r (const __time64_t *t, char *buf) +{ + struct tm tm; + return __asctime_r (__localtime64_r (t, &tm), buf); +} + +/* Provide a 32-bit variant if needed */ + +#if __TIMESIZE != 64 + char * ctime_r (const time_t *t, char *buf) { struct tm tm; return __asctime_r (__localtime_r (t, &tm), buf); } + +#endif From patchwork Thu Nov 29 22:10:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Albert ARIBAUD (3ADEV)" X-Patchwork-Id: 1005685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-97721-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=3adev.fr Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="T2fEKJL1"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 435WvW1GtQz9s9m for ; Fri, 30 Nov 2018 09:11:34 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=o118RYmPgrcGW+hGN3Q4IPQ+lkvlYG0 RZnG3nTm2PZkTDPj72+NTpRXSiUa1mPRiOaV/GmVwm93dhm1zw3vF5jiRMglXkut r+aBMKFbrD1npJ8KwFFoVk61iyM3B0x4XvxGbnMOYLmGDh8EjHRqksiaDqp7BwTz ZfHq3ZvVi63o= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=GbF+0ZZnX86XWYVtYnUlNAABn9M=; b=T2fEK JL1LDrbuLQYcUdFZDpl1dEPlHX/nTFJseBFvmkmpDE65+0SF3OkJcBpe57XcUn9U kxVRrRl+EdmVuhtDkYFt/8WaHqNnxnLz6fg9ijCu0zr1NriQ6Zx8poqSMHbad+Fs X4q1SYYm6WPN18SR2KZpkj42BaYpQLQGctTZnk= Received: (qmail 28398 invoked by alias); 29 Nov 2018 22:10:26 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 28300 invoked by uid 89); 29 Nov 2018 22:10:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RCVD_IN_RP_RNBL autolearn=ham version=3.3.2 spammy=2213 X-HELO: smtp3-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Subject: [PATCH v2 8/9] Y2038: make __mktime_internal compatible with __time64_t Date: Thu, 29 Nov 2018 23:10:09 +0100 Message-Id: <20181129221010.19589-9-albert.aribaud@3adev.fr> In-Reply-To: <20181129221010.19589-1-albert.aribaud@3adev.fr> References: <20181129221010.19589-1-albert.aribaud@3adev.fr> From: Paul Eggert This implies also making its callers 64-bit-time compatible (these are mktime/localtime and timegm) and providing wrappers for 32-bit-time userland to call. Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu. * include/time.h (__mktime64): Add prototype. * include/time.h (__localtime64): Likewise. * include/time.h (fits_in_time_t): New static function. * time/mktime.c (__mktime64): New function. * time/timegm.c (__timegm64): Likewise. * time/mktime.c (mktime) [__TIMESIZE]: New wrapper function. * time/timegm.c (timegm) [__TIMESIZE]: Likewise. --- include/time.h | 36 +++++++++++++++++++---- time/mktime.c | 80 ++++++++++++++++++++++++++++++++++++-------------- time/timegm.c | 27 ++++++++++++++++- 3 files changed, 114 insertions(+), 29 deletions(-) diff --git a/include/time.h b/include/time.h index c26cfb40f6..d5e50a4e77 100644 --- a/include/time.h +++ b/include/time.h @@ -3,6 +3,7 @@ #ifndef _ISOMAC # include +# include extern __typeof (strftime_l) __strftime_l; libc_hidden_proto (__strftime_l) @@ -16,6 +17,21 @@ libc_hidden_proto (localtime) libc_hidden_proto (strftime) libc_hidden_proto (strptime) +#if __TIMESIZE == 64 +# define __timegm64 timegm +# define __mktime64 mktime +# define __timelocal64 timelocal +#else +extern __time64_t __timegm64 (struct tm *__tp) __THROW; +extern __time64_t __mktime64 (struct tm *__tp) __THROW; +/* Another name for `__mktime64'. */ +extern __time64_t __timelocal64 (struct tm *__tp) __THROW; + +libc_hidden_proto (__mktime64) +libc_hidden_proto (__timelocal64) +#endif + + extern __typeof (clock_getres) __clock_getres; extern __typeof (clock_gettime) __clock_gettime; libc_hidden_proto (__clock_gettime) @@ -49,13 +65,13 @@ extern void __tzset_parse_tz (const char *tz) attribute_hidden; extern void __tz_compute (__time64_t timer, struct tm *tm, int use_localtime) __THROW attribute_hidden; -/* Subroutine of `mktime'. Return the `time_t' representation of TP and - normalize TP, given that a `struct tm *' maps to a `time_t' as performed +/* Subroutine of mktime. Return the __time64_t representation of TP and + normalize TP, given that a struct tm * maps to a __time64_t as performed by FUNC. Record next guess for localtime-gmtime offset in *OFFSET. */ -extern time_t __mktime_internal (struct tm *__tp, - struct tm *(*__func) (const time_t *, - struct tm *), - long int *__offset) attribute_hidden; +extern __time64_t __mktime_internal (struct tm *__tp, + struct tm *(*__func) (const __time64_t *, + struct tm *), + long int *__offset) attribute_hidden; /* nis/nis_print.c needs ctime, so even if ctime is not declared here, we define __ctime64 as ctime so that nis/nis_print.c can get linked @@ -139,5 +155,13 @@ extern double __difftime (time_t time1, time_t time0); actual clock ID. */ #define CLOCK_IDFIELD_SIZE 3 +/* Check whether a time64_t value fits in a time_t. */ +static inline bool +fits_in_time_t (__time64_t t64) +{ + time_t t = t64; + return t == t64; +} + #endif #endif diff --git a/time/mktime.c b/time/mktime.c index 8faa9bc93d..6ff68f491a 100644 --- a/time/mktime.c +++ b/time/mktime.c @@ -112,11 +112,11 @@ my_tzset (void) added to them, and then with another timestamp added, without worrying about overflow. - Much of the code uses long_int to represent time_t values, to - lessen the hassle of dealing with platforms where time_t is + Much of the code uses long_int to represent __time64_t values, to + lessen the hassle of dealing with platforms where __time64_t is unsigned, and because long_int should suffice to represent all - time_t values that mktime can generate even on platforms where - time_t is excessively wide. */ + __time64_t values that mktime can generate even on platforms where + __time64_t is excessively wide. */ #if INT_MAX <= LONG_MAX / 4 / 366 / 24 / 60 / 60 typedef long int long_int; @@ -144,16 +144,17 @@ shr (long_int a, int b) : a / (one << b) - (a % (one << b) < 0)); } -/* Bounds for the intersection of time_t and long_int. */ +/* Bounds for the intersection of __time64_t and long_int. */ static long_int const mktime_min - = ((TYPE_SIGNED (time_t) && TYPE_MINIMUM (time_t) < TYPE_MINIMUM (long_int)) - ? TYPE_MINIMUM (long_int) : TYPE_MINIMUM (time_t)); + = ((TYPE_SIGNED (__time64_t) + && TYPE_MINIMUM (__time64_t) < TYPE_MINIMUM (long_int)) + ? TYPE_MINIMUM (long_int) : TYPE_MINIMUM (__time64_t)); static long_int const mktime_max - = (TYPE_MAXIMUM (long_int) < TYPE_MAXIMUM (time_t) - ? TYPE_MAXIMUM (long_int) : TYPE_MAXIMUM (time_t)); + = (TYPE_MAXIMUM (long_int) < TYPE_MAXIMUM (__time64_t) + ? TYPE_MAXIMUM (long_int) : TYPE_MAXIMUM (__time64_t)); -verify (TYPE_IS_INTEGER (time_t)); +verify (TYPE_IS_INTEGER (__time64_t)); #define EPOCH_YEAR 1970 #define TM_YEAR_BASE 1900 @@ -252,23 +253,23 @@ tm_diff (long_int year, long_int yday, int hour, int min, int sec, } /* Use CONVERT to convert T to a struct tm value in *TM. T must be in - range for time_t. Return TM if successful, NULL (setting errno) on + range for __time64_t. Return TM if successful, NULL (setting errno) on failure. */ static struct tm * -convert_time (struct tm *(*convert) (const time_t *, struct tm *), +convert_time (struct tm *(*convert) (const __time64_t *, struct tm *), long_int t, struct tm *tm) { - time_t x = t; + __time64_t x = t; return convert (&x, tm); } /* Use CONVERT to convert *T to a broken down time in *TP. If *T is out of range for conversion, adjust it so that it is the nearest in-range value and then convert that. - A value is in range if it fits in both time_t and long_int. + A value is in range if it fits in both __time64_t and long_int. Return TP on success, NULL (setting errno) on failure. */ static struct tm * -ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), +ranged_convert (struct tm *(*convert) (const __time64_t *, struct tm *), long_int *t, struct tm *tp) { long_int t1 = (*t < mktime_min ? mktime_min @@ -310,7 +311,7 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), } -/* Convert *TP to a time_t value, inverting +/* Convert *TP to a __time64_t value, inverting the monotonic and mostly-unit-linear conversion function CONVERT. Use *OFFSET to keep track of a guess at the offset of the result, compared to what the result would be for UTC without leap seconds. @@ -318,9 +319,9 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), If successful, set *TP to the canonicalized struct tm; otherwise leave *TP alone, return ((time_t) -1) and set errno. This function is external because it is used also by timegm.c. */ -time_t +__time64_t __mktime_internal (struct tm *tp, - struct tm *(*convert) (const time_t *, struct tm *), + struct tm *(*convert) (const __time64_t *, struct tm *), mktime_offset_t *offset) { struct tm tm; @@ -520,10 +521,13 @@ __mktime_internal (struct tm *tp, #if defined _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS -/* Convert *TP to a time_t value. */ -time_t -mktime (struct tm *tp) +/* Convert *TP to a __time64_t value. */ +__time64_t +__mktime64 (struct tm *tp) { + __time64_t t64; + time_t t; + struct tm tp0 = *tp; /* POSIX.1 8.1.1 requires that whenever mktime() is called, the time zone names contained in the external variable 'tzname' shall be set as if the tzset() function had been called. */ @@ -531,7 +535,15 @@ mktime (struct tm *tp) # if defined _LIBC || NEED_MKTIME_WORKING static mktime_offset_t localtime_offset; - return __mktime_internal (tp, __localtime_r, &localtime_offset); + t64 = __mktime_internal (&tp0, __localtime64_r, &localtime_offset); + t = t64; + if (t != t64) + { + __set_errno(EOVERFLOW); + return -1; + } + *tp = tp0; + return t; # else # undef mktime return mktime (tp); @@ -539,6 +551,28 @@ mktime (struct tm *tp) } #endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS */ +#ifdef weak_alias +weak_alias (__mktime64, __timelocal64) +#endif + +#ifdef _LIBC +libc_hidden_def (__mktime64) +libc_hidden_weak (__timelocal64) +#endif + +#if __TIMESIZE != 64 + +/* The 32-bit-time wrapper. */ +time_t +mktime (struct tm *tp) +{ + __time64_t t64 = __mktime64 (tp); + if (fits_in_time_t (t64)) + return t64; + __set_errno (EOVERFLOW); + return -1; +} + #ifdef weak_alias weak_alias (mktime, timelocal) #endif @@ -547,3 +581,5 @@ weak_alias (mktime, timelocal) libc_hidden_def (mktime) libc_hidden_weak (timelocal) #endif + +#endif diff --git a/time/timegm.c b/time/timegm.c index 229fff23c6..027c1cf575 100644 --- a/time/timegm.c +++ b/time/timegm.c @@ -22,13 +22,38 @@ #endif #include +#include #include "mktime-internal.h" +#include + +__time64_t +__timegm64 (struct tm *tmp) +{ + static long int gmtime_offset; + tmp->tm_isdst = 0; + return __mktime_internal (tmp, __gmtime64_r, &gmtime_offset); +} + +#if __TIMESIZE != 64 time_t timegm (struct tm *tmp) { + time_t t; + __time64_t t64; + struct tm tmp0 = *tmp; static mktime_offset_t gmtime_offset; tmp->tm_isdst = 0; - return __mktime_internal (tmp, __gmtime_r, &gmtime_offset); + t64 = __mktime_internal (&tmp0, __gmtime64_r, &gmtime_offset); + t = t64; + if (t != t64) + { + __set_errno(EOVERFLOW); + return -1; + } + *tmp = tmp0; + return t; } + +#endif From patchwork Thu Nov 29 22:10:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Albert ARIBAUD (3ADEV)" X-Patchwork-Id: 1005684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-97720-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=3adev.fr Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="WeBXRxFv"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 435WvL57sYz9s9J for ; Fri, 30 Nov 2018 09:11:26 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=myYuzJHVdKy3kssSFRMloaQZ/2OSRfA eFYtoY4dfuJMFNBjiQgHrpjEAxsoqurh5/jAE1fRvopoDoELsNFIIpMBFmRokIJj 4zL7/UxuyetZp8Zio6akULc2vwsI3xU1//swH67PCYOanS1iK53TXTbk8wy7iwIf 8tSy+mHqcC+0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=l8Qv/LBLsvlsUsRCp3p2DthBYgE=; b=WeBXR xFvEbjPyWam1aWXGbDtnCl0oY4Puzku0uHZHfcYWCA+pYElboGC9PkfHfOpMD1AE /8QqRuho8rXdL7hQA8lkXpCD74lt2ceN/CjHJXBuLhEWtzRM/K1R502c7w9szxEy JnsrHzmaDyR5VOxUSsTIywaaQ2Dusqj9lErQ8s= Received: (qmail 28259 invoked by alias); 29 Nov 2018 22:10:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 28166 invoked by uid 89); 29 Nov 2018 22:10:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RCVD_IN_RP_RNBL autolearn=ham version=3.3.2 spammy=Hx-languages-length:1684 X-HELO: smtp3-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Subject: [PATCH v2 9/9] Fix time/mktime.c and time/gmtime.c for gnulib compatibility Date: Thu, 29 Nov 2018 23:10:10 +0100 Message-Id: <20181129221010.19589-10-albert.aribaud@3adev.fr> In-Reply-To: <20181129221010.19589-1-albert.aribaud@3adev.fr> References: <20181129221010.19589-1-albert.aribaud@3adev.fr> From: Paul Eggert Tested with 'make check' on x86_64-linux-gnu and i686-linux.gnu. * time/mktime.c (__mktime64): Guard weak_alias with #ifdef (__mktime64): Guard libc_hidden_def with #if _LIBC (__mktime64): Guard libc_hidden_weak with #if _LIBC (mktime): Only build when _LIBC is defined * time/timegm.c: (timegm): Only build when _LIBC is defined --- time/mktime.c | 15 +++------------ time/timegm.c | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/time/mktime.c b/time/mktime.c index 6ff68f491a..b09834e47d 100644 --- a/time/mktime.c +++ b/time/mktime.c @@ -549,18 +549,14 @@ __mktime64 (struct tm *tp) return mktime (tp); # endif } -#endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS */ -#ifdef weak_alias weak_alias (__mktime64, __timelocal64) -#endif - -#ifdef _LIBC libc_hidden_def (__mktime64) libc_hidden_weak (__timelocal64) -#endif -#if __TIMESIZE != 64 +#endif /* _LIBC || NEED_MKTIME_WORKING || NEED_MKTIME_WINDOWS */ + +#if defined _LIBC && __TIMESIZE != 64 /* The 32-bit-time wrapper. */ time_t @@ -573,13 +569,8 @@ mktime (struct tm *tp) return -1; } -#ifdef weak_alias weak_alias (mktime, timelocal) -#endif - -#ifdef _LIBC libc_hidden_def (mktime) libc_hidden_weak (timelocal) -#endif #endif diff --git a/time/timegm.c b/time/timegm.c index 027c1cf575..94dada6b88 100644 --- a/time/timegm.c +++ b/time/timegm.c @@ -35,7 +35,7 @@ __timegm64 (struct tm *tmp) return __mktime_internal (tmp, __gmtime64_r, &gmtime_offset); } -#if __TIMESIZE != 64 +#if defined _LIBC && __TIMESIZE != 64 time_t timegm (struct tm *tmp)