From patchwork Tue Nov 5 23:42:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 35664 Received: (qmail 31959 invoked by alias); 5 Nov 2019 23:48:36 -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 31777 invoked by uid 89); 5 Nov 2019 23:48:25 -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, KAM_SHORT autolearn=ham version=3.3.1 spammy= X-HELO: esa4.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=1572997693; x=1604533693; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/B6OdpRxacjIyLeF8dWTWuLPexA3jBsyJz/SVvQxPpE=; b=ihOuM4polB2XfcAsngs5v37esE4X0Q+RSDgEixUxxt1ZAJoCAEzLoylo 5qqrOWa8orXvF4kD0wHURUoZhuHEApgAXLkXHOEhLz2iL6UPO22XW/h+E 8h8gVQ6mofEVgI+f2iD3K7Nzzqhi4BKa6OkBllQq8xk77SEXmTFi5XkBD nCYIBkdagZzGnQTSFwBqXUFWfk5GVKluXLxHUo6+FTZl2EV2011tYN3qZ fnfXwuuKfjXimC0ISidgRz2DW7pD55NmwH14Wg31v4PJwgrt4PmQXl8Mg dC2+TxY6qUKsZPiC8bIj7JyzlezTECa55ruZSnwH/dKqR8U3tEmQ3dCPQ A==; IronPort-SDR: LhGQYgPPzzeuzzlBCQpLDuZuzW9wIUlBNoKbS3V5pgal3FoECEJNg/hWFY6qkAYhY/2D5Sj22m 3OSH372lCiPE/bPwEnMJd3S3aheVZgSPUgTE8n81nSTZNfVXYn/pFwKq/tGAzstD3WJhWsATbA upoTeTQSGaPeRQ+Bp3IvzQfbzqKoFvAnTvW2lXCa+TswVaPI6DwLMEV0EnnveP+Yze2bhEbRi9 YjXiCvPgwtck2pzqgx5+p8J9Hqs+LpvDvNS2xNDF47kAhpRVZzxBxGXYO5zgRYbp4CPR8SGGg8 b9A= IronPort-SDR: WMCDL0caazsAcouysveAT4H+mtfhcb81+obofMgiCjvq9/0Zp4gD88eB3egiDrD1MFwKAxQvLs WFqOsh83quV65orqLsZjtlu+Ul/OcIbh2xcsZe/ZeRwRTSANwAC25XkBZGapXheS7I2aYpVoID w4gJtAXivFmJ/WhqshpgsZeHJfDFvOu6F9NBGbWKuRQFmffu1zw5z9qCxH6p/gmWcvRIIVthcO +yEUr03SCYgHXYiD1QO0hJXPkA+ryFSGQTbjsvs6DAQngHSWU48NKbp2UmlJp6UKiyZXMWC4pR ZEUTb+i9Nsz7mm92r7L2zEMv IronPort-SDR: VbInlyglIwi8cbJ4qPhqXeRD7x5ey/AhTW0qR2x7xIkFaN5hkMttvqxRCFiXkOEVds5BhFZYz9 Scuc7Iu8khTnz+ubD3r90LVQOVWErCLsRFUo89uG56x88C51QhColO3xeJhcMoHTpiz6FQhMrc hfZ55vnxL3vItljYH2gGh0CUFQyW0+oSQAZXyT5+wLICa2GIzPu1KL9AbChhBwycyd1PSevOnC 32dERZZpF95QkaKHQ8A9jb/0sPfVj1F3ork5JBloeJOnQIByLjd7HqXlwtesh9ijsECL5vv6n4 NB4= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: alistair23@gmail.com, Alistair Francis Subject: [PATCH 2/2] sysdeps/clock_gettime: Use clock_gettime64 if avaliable Date: Tue, 5 Nov 2019 15:42:49 -0800 Message-Id: <20191105234249.25626-2-alistair.francis@wdc.com> In-Reply-To: <20191105234249.25626-1-alistair.francis@wdc.com> References: <20191105234249.25626-1-alistair.francis@wdc.com> MIME-Version: 1.0 --- This was patch was runtime tested with RV32 and RV64 It was build tested using the ./scripts/build-many-glibcs.py script. I will run: $ make ; make install ; make check tests on native ARM (32-bit) with the following three confiugrations: - 4.19 Kernel and 4.19 Headers - 5.2 Kernel and 4.19 Headers - 5.2 Kernel and 5.2 Headers I should have the results later this week. include/time.h | 3 ++ sysdeps/unix/sysv/linux/clock_gettime.c | 50 ++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/include/time.h b/include/time.h index e0974309726..d4cdfdf38e8 100644 --- a/include/time.h +++ b/include/time.h @@ -214,6 +214,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 #else extern int __thrd_sleep_time64 (const struct __timespec64* time_point, struct __timespec64* remaining); @@ -228,6 +229,8 @@ libc_hidden_proto (__nanosleep_time64) extern int __nanosleep_nocancel_time64 (const struct __timespec64 *requested_time, struct __timespec64 *remaining); libc_hidden_proto (__nanosleep_nocancel_time64) +extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp); +libc_hidden_proto (__clock_gettime64) #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 ca40983f6ca..b2ed3f2b698 100644 --- a/sysdeps/unix/sysv/linux/clock_gettime.c +++ b/sysdeps/unix/sysv/linux/clock_gettime.c @@ -17,6 +17,7 @@ . */ #include +#include #include #include #include "kernel-posix-cpu-timers.h" @@ -30,10 +31,57 @@ /* Get current value of CLOCK and store it in TP. */ int +__clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp) +{ +#ifdef __ASSUME_TIME64_SYSCALLS +# ifndef __NR_clock_gettime64 +# define __NR_clock_gettime64 __NR_clock_gettime +# define __vdso_clock_gettime64 __vdso_clock_gettime +# endif + return INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp); +#else +# if defined __NR_clock_gettime64 && defined HAVE_CLOCK_GETTIME64_VSYSCALL + long int ret_64; + ret_64 = INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp); + + if (ret_64 == 0 || errno != ENOSYS) + return ret_64; +# endif /* __NR_clock_gettime64 && HAVE_CLOCK_GETTIME64_VSYSCALL */ + int ret; + struct timespec tp32; + + ret = INLINE_VSYSCALL (clock_gettime, 2, clock_id, &tp32); + + if (ret == 0 || errno != ENOSYS) + *tp = valid_timespec_to_timespec64 (tp32); + + 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; + } + + *tp = valid_timespec64_to_timespec (tp64); + } + + return ret; } +#endif libc_hidden_def (__clock_gettime) versioned_symbol (libc, __clock_gettime, clock_gettime, GLIBC_2_17);