From patchwork Sun Apr 28 22:45:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Eggert X-Patchwork-Id: 32445 Received: (qmail 82682 invoked by alias); 28 Apr 2019 22:46: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 82582 invoked by uid 89); 28 Apr 2019 22:46:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_PASS autolearn=ham version=3.3.1 spammy=hour, moved, Stop, Florian X-HELO: zimbra.cs.ucla.edu Subject: Re: [PATCH v2 1/2] Y2038: make __mktime_internal compatible with __time64_t To: Lukasz Majewski References: <20190227112042.1794-1-lukma@denx.de> <20190312075856.33ac3c5b@jawa> <20190319143956.52f83a48@jawa> <910c75f2-86ea-34cd-7279-71fcbf5edabc@cs.ucla.edu> <20190323125906.699ce15e@jawa> <20190404120715.150a5d44@jawa> <20190424135748.502c34af@jawa> From: Paul Eggert Cc: GNU C Library Message-ID: Date: Sun, 28 Apr 2019 15:45:54 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190424135748.502c34af@jawa> Lukasz Majewski wrote: > Paul, will you find any time soon to provide next version of mktime > compatibility patch? As far as mktime compatibility goes, I think I'd rather first cause mktime to be compatible with __time64_t, and worry about _TIME_BITS later. Proposed mktime patch attached; it's similar to my previous proposal except it leaves the __time64_t definition in posix/bits/types.h rather than moving it to time/mktime-internal.h. This patch exposes __time64_t to user code if _LIBC is defined (because glibc needs __time64_t internally), or if __TIMESIZE != 64 (because of the compromise to expose __time64_t only on 32-bit time_t platforms). Once we add _TIME_BITS I expect that we should change the visibility rule to something that also involves _TIME_BITS, because __time64_t should not be exposed to user code if _TIME_BITS == 64. However, that can wait for the patches involving _TIME_BITS. Tested-by: Lukasz Majewski From 1a7cfd679d96b48335731c65f3e4e4d2e57fd086 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 18 Mar 2019 14:14:15 -0700 Subject: [PATCH] Make mktime etc. compatible with __time64_t Keep these functions compatible with Gnulib while adding __time64_t support. The basic idea is to move private API declarations from include/time.h to time/mktime-internal.h, since the former file cannot easily be shared with Gnulib whereas the latter can. Also, do some other minor cleanup while in the neighborhood. * include/time.h: Include stdbool.h, time/mktime-internal.h. (__mktime_internal): Move this prototype to time/mktime-internal.h, since Gnulib needs it. (__localtime64_r, __gmtime64_r) [__TIMESIZE == 64]: Move these macros to time/mktime-internal.h, since Gnulib needs them. (__mktime64, __timegm64) [__TIMESIZE != 64]: New prototypes. (in_time_t_range): New static function. * posix/bits/types.h (__time64_t) [__TIMESIZE == 64 && !defined __LIBC]: Do not define as a macro in this case, so that portable code is less tempted to use __time64_t. * time/mktime-internal.h: Rewrite so that it does both glibc and Gnulib work. Include time.h if not _LIBC. (mktime_offset_t) [!_LIBC]: Define for gnulib. (__time64_t, __gmtime64_r, __localtime64_r, __mktime64, __timegm64) [!_LIBC || __TIMESIZE == 64]: New macros, mostly moved here from include/time.h. (__gmtime_r, __localtime_r, __mktime_internal) [!_LIBC]: New macros, taken from GNulib. (__mktime_internal): New prototype, moved here from include/time.h. * time/mktime.c (mktime_min, mktime_max, convert_time) (ranged_convert, __mktime_internal, __mktime64): * time/timegm.c (__timegm64): Use __time64_t, not time_t. * time/mktime.c: Stop worrying about whether time_t is floating-point. (__mktime64) [! (_LIBC && __TIMESIZE != 64)]: Rename from mktime. (mktime) [_LIBC && __TIMESIZE != 64]: New function. * time/timegm.c [!_LIBC]: Include libc-config.h, not config.h, for libc_hidden_def. Include errno.h. (__timegm64) [! (_LIBC && __TIMESIZE != 64)]: Rename from timegm. (timegm) [_LIBC && __TIMESIZE != 64]: New function. First cut at publicizing __time64_t --- ChangeLog | 44 +++++++++++++++++++++++ include/time.h | 39 +++++++++++---------- posix/bits/types.h | 9 +++-- time/mktime-internal.h | 79 +++++++++++++++++++++++++++++++++++++++++- time/mktime.c | 71 ++++++++++++++++++++++--------------- time/timegm.c | 32 ++++++++++++++--- 6 files changed, 220 insertions(+), 54 deletions(-) diff --git a/ChangeLog b/ChangeLog index aac356bb69..e513c0ea06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,47 @@ +2019-04-28 Paul Eggert + + Make mktime etc. compatible with __time64_t + Keep these functions compatible with Gnulib while adding + __time64_t support. The basic idea is to move private API + declarations from include/time.h to time/mktime-internal.h, since + the former file cannot easily be shared with Gnulib whereas the + latter can. + Also, do some other minor cleanup while in the neighborhood. + * include/time.h: Include stdbool.h, time/mktime-internal.h. + (__mktime_internal): Move this prototype to time/mktime-internal.h, + since Gnulib needs it. + (__localtime64_r, __gmtime64_r) [__TIMESIZE == 64]: + Move these macros to time/mktime-internal.h, since Gnulib needs them. + (__mktime64, __timegm64) [__TIMESIZE != 64]: New prototypes. + (in_time_t_range): New static function. + * posix/bits/types.h (__time64_t): Move to time/mktime-internal.h, + so that glibc users are not tempted to use __time64_t. + * time/mktime-internal.h: Rewrite so that it does both glibc + and Gnulib work. Include time.h if not _LIBC. + (mktime_offset_t) [!_LIBC]: Define for gnulib. + (__time64_t): New type or macro, moved here from + posix/bits/types.h. + (__gmtime64_r, __localtime64_r, __mktime64, __timegm64) + [!_LIBC || __TIMESIZE == 64): New macros, mostly moved here + from include/time.h. + (__gmtime_r, __localtime_r, __mktime_internal) [!_LIBC]: + New macros, taken from GNulib. + (__mktime_internal): New prototype, moved here from include/time.h. + * time/mktime.c (mktime_min, mktime_max, convert_time) + (ranged_convert, __mktime_internal, __mktime64): + * time/timegm.c (__timegm64): + Use __time64_t, not time_t. + * time/mktime.c: Stop worrying about whether time_t is floating-point. + (__mktime64) [! (_LIBC && __TIMESIZE != 64)]: + Rename from mktime. + (mktime) [_LIBC && __TIMESIZE != 64]: New function. + * time/timegm.c [!_LIBC]: Include libc-config.h, not config.h, + for libc_hidden_def. + Include errno.h. + (__timegm64) [! (_LIBC && __TIMESIZE != 64)]: + Rename from timegm. + (timegm) [_LIBC && __TIMESIZE != 64]: New function. + 2019-04-26 Florian Weimer elf: Link sotruss-lib.so with BIND_NOW for --enable-bind-now. diff --git a/include/time.h b/include/time.h index 61dd9e180b..ac3163c2a5 100644 --- a/include/time.h +++ b/include/time.h @@ -3,6 +3,8 @@ #ifndef _ISOMAC # include +# include +# include