From patchwork Wed Apr 18 20:17:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Albert ARIBAUD X-Patchwork-Id: 26798 Received: (qmail 107592 invoked by alias); 18 Apr 2018 20:19:58 -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 107528 invoked by uid 89); 18 Apr 2018 20:19:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.8 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_LOW, 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 Cc: "Albert ARIBAUD (3ADEV)" Subject: [[PATCH RFC 2] 19/63] Y2038: add function __timespec_get64 Date: Wed, 18 Apr 2018 22:17:35 +0200 Message-Id: <20180418201819.15952-20-albert.aribaud@3adev.fr> In-Reply-To: <20180418201819.15952-19-albert.aribaud@3adev.fr> References: <20180418201819.15952-1-albert.aribaud@3adev.fr> <20180418201819.15952-2-albert.aribaud@3adev.fr> <20180418201819.15952-3-albert.aribaud@3adev.fr> <20180418201819.15952-4-albert.aribaud@3adev.fr> <20180418201819.15952-5-albert.aribaud@3adev.fr> <20180418201819.15952-6-albert.aribaud@3adev.fr> <20180418201819.15952-7-albert.aribaud@3adev.fr> <20180418201819.15952-8-albert.aribaud@3adev.fr> <20180418201819.15952-9-albert.aribaud@3adev.fr> <20180418201819.15952-10-albert.aribaud@3adev.fr> <20180418201819.15952-11-albert.aribaud@3adev.fr> <20180418201819.15952-12-albert.aribaud@3adev.fr> <20180418201819.15952-13-albert.aribaud@3adev.fr> <20180418201819.15952-14-albert.aribaud@3adev.fr> <20180418201819.15952-15-albert.aribaud@3adev.fr> <20180418201819.15952-16-albert.aribaud@3adev.fr> <20180418201819.15952-17-albert.aribaud@3adev.fr> <20180418201819.15952-18-albert.aribaud@3adev.fr> <20180418201819.15952-19-albert.aribaud@3adev.fr> --- sysdeps/unix/sysv/linux/timespec_get.c | 41 ++++++++++++++++++++++++++++++++++ time/Versions | 1 + 2 files changed, 42 insertions(+) diff --git a/sysdeps/unix/sysv/linux/timespec_get.c b/sysdeps/unix/sysv/linux/timespec_get.c index b14a302ee9..b40bdedb57 100644 --- a/sysdeps/unix/sysv/linux/timespec_get.c +++ b/sysdeps/unix/sysv/linux/timespec_get.c @@ -44,3 +44,44 @@ timespec_get (struct timespec *ts, int base) return base; } + +/* 64-bit time version */ + +extern int __y2038_linux_support; + +int +__timespec_get64 (struct __timespec64 *ts, int base) +{ + switch (base) + { + int res; + INTERNAL_SYSCALL_DECL (err); + case TIME_UTC: + if (__y2038_linux_support) +/* Check that we are built with a 64-bit-time kernel */ +#ifdef __NR_clock_nanosleep64 + { + res = INTERNAL_VSYSCALL (clock_gettime64, err, 2, CLOCK_REALTIME, ts); + } + else +#endif + { + res = -1; + __set_errno(ENOSYS); + } + if (res == -1 && errno == ENOSYS) + { + struct timespec ts32; + res = INTERNAL_VSYSCALL (clock_gettime, err, 2, CLOCK_REALTIME, &ts32); + if (INTERNAL_SYSCALL_ERROR_P (res, err)) + return 0; + timespec_to_timespec64(&ts32, ts); + } + break; + + default: + return 0; + } + + return base; +} diff --git a/time/Versions b/time/Versions index 6fe9373913..668c134f12 100644 --- a/time/Versions +++ b/time/Versions @@ -78,5 +78,6 @@ libc { __clock_settime64; __clock_getres64; __clock_nanosleep64; + __timespec_get64; } }