From patchwork Mon Apr 29 10:46:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 32447 Received: (qmail 97204 invoked by alias); 29 Apr 2019 10:46:43 -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 97175 invoked by uid 89); 29 Apr 2019 10:46:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=H*Ad:D*ucla.edu, H*r:192.168.8, HX-Languages-Length:1838, our X-HELO: mail-out.m-online.net From: Lukasz Majewski To: libc-alpha@sourceware.org Cc: Stepan Golosunov , Arnd Bergmann , Paul Eggert , Joseph Myers , Lukasz Majewski Subject: [PATCH v2 1/7] y2038: Introduce internal for glibc struct __timespec64 Date: Mon, 29 Apr 2019 12:46:07 +0200 Message-Id: <20190429104613.16209-2-lukma@denx.de> In-Reply-To: <20190429104613.16209-1-lukma@denx.de> References: <20190414220841.20243-1-lukma@denx.de> <20190429104613.16209-1-lukma@denx.de> This type is a glibc's type similar to struct timespec but whose tv_sec field is a __time64_t rather than a time_t, which makes it Y2038-proof and usable to pass between user code and Y2038-proof kernel syscalls (e.g. clock_gettime()). To support passing this structure to the kernel - the tv_pad, 32 bit padding field has been introduced. The placement of it depends on endiannes of the SoC. Tested on x86_64 and ARM. * include/time.h: Add struct __timespec64 definition --- Changes for v2: - None --- include/time.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/time.h b/include/time.h index 61dd9e180b..7540ac0f8b 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) @@ -58,6 +59,27 @@ extern time_t __mktime_internal (struct tm *__tp, long int *__offset) attribute_hidden; #if __TIMESIZE == 64 +# define __timespec64 timespec +#else +/* The glibc Y2038-proof struct __timespec64 structure for a time value. + To keep things Posix-ish, we keep the nanoseconds field a 32-bit + signed long, but since the Linux field is a 64-bit signed int, we + pad our tv_nsec with a 32-bit bitfield, which should always be 0. */ + +struct __timespec64 +{ + __time64_t tv_sec; /* Seconds */ +# if BYTE_ORDER == BIG_ENDIAN + int tv_pad: 32; /* Padding named for checking/setting */ + __int32_t tv_nsec; /* Nanoseconds */ +# else + __int32_t tv_nsec; /* Nanoseconds */ + int tv_pad: 32; /* Padding named for checking/setting */ +# endif +}; +#endif + +#if __TIMESIZE == 64 # define __ctime64 ctime #else extern char *__ctime64 (const __time64_t *__timer) __THROW;