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 X-Patchwork-Id: 30401 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