From patchwork Thu Aug 29 16:50:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 34331 Received: (qmail 128109 invoked by alias); 29 Aug 2019 16:53:59 -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 128050 invoked by uid 89); 29 Aug 2019 16:53:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: esa2.hgst.iphmx.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1567097702; x=1598633702; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kfArp6/WSN+DYNjrsV5gES1BCuEyOAJXcq2atTxaJZs=; b=Bss9+kRUJwSx48F2n6rYMviJAHr+9bzOsQEZdORI2jz20sKdjNJCXEln RG/m40qL82tQt1u+VgLJApSOFkbAw86zk5UWBMsAh7Y5Z0vGECreEhYjQ LNDKXxVCEcDe/O0SVe8RfLABtXnxv1N2hxAfTt6EuUUUr3guhmfEGRWYG VRSXBMGoa+hW+WzoOQYdtcqa2Sm0wB29judPdkV1kBsoWlrUc4b/FCU/g Fcqv36muF8VVZKvt4u4F4d6SNgPV44FueLQHb3Hvbj+Xg8WyO9Mh6I/3I rZe9z1fWbJn4n+ZOcmmkdysDxrpGcKRcFuACd8oR81PHSxwRhUj6hx22K Q==; IronPort-SDR: AnoQU4n4FmzC/CytAQCtn0dOmCNBEsaftNBrgGtp11j1Y6vYuUu3AXar7b7lhbKhDDo7p2A7xg mfvMFYhKfZQ+FR69i2iGOebjbbBZAmE2mq04y3ZL4UrsxN1UxCZuxYMSjh6eblEv3yXZ5MUGUO vu4V5SosCnjIUvOGyUK0CFCcXIBfXpVSVs/kHvR3MODiqzLX18/DIg/3xI0N12F7oMwDar6eT2 oIG1pDiBfqpYGp2mn1Ztw5/+rXv6Nh1ZPzbCoWC2cVI81l+Tq4QfrgfJfn0pQYd0Eg3o80NwC+ hBk= IronPort-SDR: Af/xawCzTklhgdXSPahC2nxCyvEeLwoEmqzmjRO13HFBBxXcP7xBriwFCtmgRwYyx83gbyxebe 6aVKgEB+GyVUfYtEzzPimI2fnwmVqjsZ6/Rgppz7cxxfzfTBoSQc3hed17BEPXwm7xG6qfAWWv S6cXb5byhw4Ez3t3Clu6UCK/YMAevdcFiDmilMwhVshnZy6wOthFXQ7gjKIdhHJ5WEf7MVTbbz nDXrLkBAEh7GwzCxheWDRSet62Z4easuM9bUPZV3MlHoZucL2lr4SnFJaFC8YAvMuaGAjiYJ38 Riq2hh8awbG5jp3cqiJIfn9N IronPort-SDR: MnfmaZTy1mN9hjBD+ZBlBIK5N6g2d8VPYLCQ0r/0f5D0vQYZmbg1U+yqIgaYpc7eE3QAt6/V69 ZE1KznWDs/H0AuxgAKG7b7ytD69uPJvf1nw/hKQMzoKZFSgWUnc63dL3joPNKti2RFdJjEdoc4 hGhs5sBRM+m1PrxI7tdj4afPCOms9I95RQF74kyT1Th704jGbfxDd/u/yUgaLGXSZICtxelaUh Nd7Xd3h3GNh1b/oMxi67iDQovHGG6LpT1UZhy4L6oHT8O10RwduuekpLxwRutRSojlSHxnyeOy ldY= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: arnd@arndb.de, adhemerval.zanella@linaro.org, fweimer@redhat.com, palmer@sifive.com, macro@wdc.com, zongbox@gmail.com, alistair.francis@wdc.com, alistair23@gmail.com Subject: [RFC v5 05/21] sysdeps/clock_gettime: Use clock_gettime64 if avaliable Date: Thu, 29 Aug 2019 09:50:13 -0700 Message-Id: <513e8d86c5d7a44fcf269f9c38883222fbbc168d.1567097252.git.alistair.francis@wdc.com> In-Reply-To: References: MIME-Version: 1.0 Signed-off-by: Alistair Francis * sysdeps/unix/sysv/linux/clock_gettime.c: Use clock_gettime64 if avaliable. --- include/time.h | 1 + sysdeps/unix/sysv/linux/clock_gettime.c | 48 ++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/include/time.h b/include/time.h index 6d81f91384b..1e33f34e1f6 100644 --- a/include/time.h +++ b/include/time.h @@ -177,6 +177,7 @@ extern double __difftime (time_t time1, time_t time0); #define __clock_nanosleep_time64 __clock_nanosleep #define __nanosleep_time64 __nanosleep #define __nanosleep_nocancel_time64 __nanosleep_nocancel +#define __clock_gettime64 __clock_gettime #endif /* Use in the clock_* functions. Size of the field representing the diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c b/sysdeps/unix/sysv/linux/clock_gettime.c index 5fc47fb7dc7..ea98af9bf1a 100644 --- a/sysdeps/unix/sysv/linux/clock_gettime.c +++ b/sysdeps/unix/sysv/linux/clock_gettime.c @@ -28,9 +28,55 @@ /* Get current value of CLOCK and store it in TP. */ int +__clock_gettime64 (clockid_t clock_id, struct timespec *tp) +{ +#ifdef __ASSUME_TIME64_SYSCALLS +# ifndef __NR_clock_gettime64 +# define __NR_clock_gettime64 __NR_clock_gettime +# endif + return INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp); +#else + int ret; +# ifdef __NR_clock_gettime64 + ret = INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp); + + if (ret == 0 || errno != ENOSYS) + return ret; +# endif /* __NR_clock_gettime64 */ + struct timespec tp32; + + ret = INLINE_VSYSCALL (clock_gettime, 2, clock_id, &tp32); + + if (ret == 0 || errno != ENOSYS) + valid_timespec_to_timespec64(tp32, tp); + + return ret; +#endif /* __ASSUME_TIME64_SYSCALLS */ +} + +#if __TIMESIZE != 64 +int __clock_gettime (clockid_t clock_id, struct timespec *tp) { - return INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); + int ret; + struct __timespec64 tp64; + + ret = __clock_gettime64 (clock_id, &tp64); + + if (ret == 0 || errno != ENOSYS) + { + if (! in_time_t_range (tp64.tv_sec)) + { + __set_errno (EOVERFLOW); + return -1; + } + + valid_timespec64_to_timespec(&tp64, tp); + + return ret; + } } +#endif + weak_alias (__clock_gettime, clock_gettime) libc_hidden_def (__clock_gettime)