From patchwork Wed Nov 21 00:28:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Albert ARIBAUD X-Patchwork-Id: 30230 Received: (qmail 59284 invoked by alias); 21 Nov 2018 00:28:56 -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 59178 invoked by uid 89); 21 Nov 2018 00:28:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 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 autolearn=ham version=3.3.2 spammy=Hx-languages-length:1200 X-HELO: smtp3-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Subject: [PATCH 7/8] Y2038: add function __ctime64_r Date: Wed, 21 Nov 2018 01:28:43 +0100 Message-Id: <20181121002844.14530-8-albert.aribaud@3adev.fr> In-Reply-To: <20181121002844.14530-1-albert.aribaud@3adev.fr> References: <20181121002844.14530-1-albert.aribaud@3adev.fr> * 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