From patchwork Thu Aug 29 16:50:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 34332 Received: (qmail 128776 invoked by alias); 29 Aug 2019 16:54:04 -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 128720 invoked by uid 89); 29 Aug 2019 16:54:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.5 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=1567097644; x=1598633644; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h2Gi22fxrHZaaLWUcdKtyrtb5y6IRIKg1y2gCnYj3/g=; b=HriMv+b0+eGvFUmSqieK9PHsiGPIZS3xXdMbjIZ2L0/w2dZ0BeRt2Oei 7aQtdXrBVClJKErNO6IPRQdBnglGvEclRQ61Yu264dmWddt7P4WEmsFzI bsmKkSHjiFqpFUDG+9OB8VpDkzvGUdD55iqgMv9UyOdzU4lX616GGodrF T+8LHDFsosMBDlAeT++r8NfTpiEkVmoUSPcuXNztVjIpx27jQm4fy2IsC T7TnnIwpK545Ow18UjAVxL3LjqBFg+Jl4eOtH5Md6B8+QObi15tUfHXFc YY9O/JYbSfjMHReemdhk4WBkbeanercx1ph8SDE9JCc/59hOr/gyixruG Q==; IronPort-SDR: x1c472ffU9fmqB1jCmujWAa+PZ+2Bv99H2Q7cezz5ZtYABJZwILP9JTjhHZS7EeU2wH0sPZv8z jrWt2ubmEnNU5bdMHiSkjU7p0i8sErH/JHkdPvCJAp0YsYd0QvOGF6k3TGtQuRR2M7CKTy29eY PUCwAf3Js86wKg/fKtpKzxzbeKY1RYN/lycirpz4nSVvGZ7aYBLAepCQ0cYEK2Ef3Ai41JJGQT 9IaXvoVmvEeuPJU0g2OiNxJr4gAQVj66xPmxFh8Er5MCpwAuNvGTDszIr1zNFep+Kz7AoVbHnc 0Wg= IronPort-SDR: n0qZb69qm4uzwU6VU2VVBY9j7MqZhVYrAPcJcmcMirpHWckKw8zYlDy5WT29aM142j62/1nwGH fGHvlILzZc6ETCVtWPCenFHonl9/ldL3SuU3s/ebQnklGO8Op8Xod0WY4iIHjysq8Ej+uxqKce V7Up1wfORDUJYLcLz3rJ3ASzszE3KuLO2PK4BLX5ilMQ7Cd2DqtQ7RGIsshLES88gT7z1aPOvM hYSLs10W3UCST30xPMVUy8F01ZF1Ea6MwxVcngAKal8yg/vmLigYLN0WnveJ7o9iZ3N8685QXz C/KmxVnIqLnJVwODvU0z8EaK IronPort-SDR: WyA8Esck6jUxVdwzGn/D89lTmOpjWUKk6t1KfYt3WI+TnnU7ADghKNa0wh9+XYK86PIzW3VXiR KNSO3iMTZIAfFOvt2LoYBJ/PvH9Yfi7oHFDN5UDq9O0ZrbcG+tEVgvNw36bjZpkduSkBe9VpAX +uy5/OKEES2s/Gync5uGC4CWvLRMbKSnRO7ng4m/pD9c0D/D4QK5ckN36Z660vtcLD4yithKuC P/5PfPqzL7eMflUIcMbq8b//oLyDJuaYU4e/4mAWE0UwtD3XOOr3OuS1M64siCEN7k/tA9sB3X oK8= 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 06/21] sysdeps/timespec_get: Use clock_gettime64 if avaliable Date: Thu, 29 Aug 2019 09:50:16 -0700 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Signed-off-by: Alistair Francis * sysdeps/unix/sysv/linux/timespec_get.c: Use clock_gettime64 if avaliable. --- include/time.h | 1 + sysdeps/unix/sysv/linux/timespec_get.c | 48 ++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/include/time.h b/include/time.h index 1e33f34e1f6..ae88eac62d6 100644 --- a/include/time.h +++ b/include/time.h @@ -178,6 +178,7 @@ extern double __difftime (time_t time1, time_t time0); #define __nanosleep_time64 __nanosleep #define __nanosleep_nocancel_time64 __nanosleep_nocancel #define __clock_gettime64 __clock_gettime +#define __timespec_get64 timespec_get #endif /* Use in the clock_* functions. Size of the field representing the diff --git a/sysdeps/unix/sysv/linux/timespec_get.c b/sysdeps/unix/sysv/linux/timespec_get.c index 52080ddf08a..f53e75d5719 100644 --- a/sysdeps/unix/sysv/linux/timespec_get.c +++ b/sysdeps/unix/sysv/linux/timespec_get.c @@ -26,16 +26,34 @@ /* Set TS to calendar time based in time base BASE. */ int -timespec_get (struct timespec *ts, int base) +__timespec_get64 (struct timespec *ts, int base) { switch (base) { int res; INTERNAL_SYSCALL_DECL (err); case TIME_UTC: - res = INTERNAL_VSYSCALL (clock_gettime, err, 2, CLOCK_REALTIME, ts); +#ifdef __ASSUME_TIME64_SYSCALLS +# ifndef __NR_clock_gettime64 +# define __NR_clock_gettime64 __NR_clock_gettime +# endif + res = INTERNAL_VSYSCALL (clock_gettime64, err, 2, CLOCK_REALTIME, ts); +#else +# ifdef __NR_clock_gettime64 + res = INTERNAL_VSYSCALL (clock_gettime64, err, 2, CLOCK_REALTIME, ts); +# endif /* __NR_clock_gettime64 */ + struct timespec ts32; + + res = INTERNAL_VSYSCALL (clock_gettime, err, 2, CLOCK_REALTIME, &ts32); + + if (res == 0 || !INTERNAL_SYSCALL_ERROR_P (res, err)) + { + ts->tv_sec = ts32.tv_sec; + ts->tv_nsec = ts32.tv_nsec; + } +#endif if (INTERNAL_SYSCALL_ERROR_P (res, err)) - return 0; + return 0; break; default: @@ -44,3 +62,27 @@ timespec_get (struct timespec *ts, int base) return base; } + +#if __TIMESIZE != 64 +int +timespec_get (struct timespec *ts, int base) +{ + int ret; + struct __timespec64 ts64; + + ret = __timespec_get64 (&ts64, base); + + if (ret == 0 || !INTERNAL_SYSCALL_ERROR_P (ret, err)) + { + ts->tv_sec = ts64.tv_sec; + ts->tv_nsec = ts64.tv_nsec; + if (! in_time_t_range (ts64.tv_sec)) + { + __set_errno (EOVERFLOW); + return -1; + } + } + + return ret; +} +#endif