From patchwork Thu Sep 7 22:41:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Albert ARIBAUD X-Patchwork-Id: 22719 Received: (qmail 68286 invoked by alias); 7 Sep 2017 22:43:15 -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 68229 invoked by uid 89); 7 Sep 2017 22:43:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.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_LOW autolearn=ham version=3.3.2 spammy= X-HELO: smtp6-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Cc: "Albert ARIBAUD (3ADEV)" Subject: [RFC PATCH 11/52] Y2038: add function __timespec_get64 Date: Fri, 8 Sep 2017 00:41:38 +0200 Message-Id: <20170907224219.12483-12-albert.aribaud@3adev.fr> In-Reply-To: <20170907224219.12483-11-albert.aribaud@3adev.fr> References: <20170907224219.12483-1-albert.aribaud@3adev.fr> <20170907224219.12483-2-albert.aribaud@3adev.fr> <20170907224219.12483-3-albert.aribaud@3adev.fr> <20170907224219.12483-4-albert.aribaud@3adev.fr> <20170907224219.12483-5-albert.aribaud@3adev.fr> <20170907224219.12483-6-albert.aribaud@3adev.fr> <20170907224219.12483-7-albert.aribaud@3adev.fr> <20170907224219.12483-8-albert.aribaud@3adev.fr> <20170907224219.12483-9-albert.aribaud@3adev.fr> <20170907224219.12483-10-albert.aribaud@3adev.fr> <20170907224219.12483-11-albert.aribaud@3adev.fr> Signed-off-by: Albert ARIBAUD (3ADEV) --- sysdeps/unix/sysv/linux/timespec_get.c | 35 ++++++++++++++++++++++++++++++++++ time/Versions | 7 +++++++ 2 files changed, 42 insertions(+) diff --git a/sysdeps/unix/sysv/linux/timespec_get.c b/sysdeps/unix/sysv/linux/timespec_get.c index 1f63e57e39..b43b5aec7b 100644 --- a/sysdeps/unix/sysv/linux/timespec_get.c +++ b/sysdeps/unix/sysv/linux/timespec_get.c @@ -44,3 +44,38 @@ 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) + { + res = INTERNAL_VSYSCALL (clock_gettime64, err, 2, CLOCK_REALTIME, ts); + } + else + { + struct timespec ts32; + res = INTERNAL_VSYSCALL (clock_gettime, err, 2, CLOCK_REALTIME, &ts32); + if (INTERNAL_SYSCALL_ERROR_P (res, err)) + return 0; + ts->tv_sec = ts32.tv_sec; + ts->tv_nsec = ts32.tv_nsec; + ts->tv_pad = 0; + } + break; + + default: + return 0; + } + + return base; +} diff --git a/time/Versions b/time/Versions index fd838181e4..3fe860862a 100644 --- a/time/Versions +++ b/time/Versions @@ -65,4 +65,11 @@ libc { GLIBC_2.16 { timespec_get; } + + # Y2038 symbols are given their own version until they can be put in + # the right place + + GLIBC_Y2038 { + __timespec_get64; + } }