From patchwork Tue Jun 25 00:09:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 33376 Received: (qmail 19792 invoked by alias); 25 Jun 2019 00:11:40 -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 19230 invoked by uid 89); 25 Jun 2019 00:11:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 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=3235 X-HELO: esa6.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=1561421495; x=1592957495; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=800UBHmq2qg2jrDkOYjZ5pTpUddf652QYejZKhJ+GaY=; b=Q65hTHZHZJL8tmXj53lYGZ1RjS2Pg3+JjhPuc9eiLVNyQTL62On/A25F XTKJ1pBqmelnlz8E5KTY8Td5d9/gT/TPLIqew1uyRvBpiV9hUrI4UcKWe u3xOsyryWaEbYruQ7WS+X0LnRuZoEqVfnpWQOKPcZw82CTWkWQ/mQOWiK +g/t9QPkku2In9c+4ncT/U0gfCb5xBo+I7X0vnPWhZUY+dufyoMWb+uRW hM36rZDzKWGiG2U5qoB8W9jRYsSSn54HnzBVqgPoFS22jyRTVONQKBDX+ nUSeR8xOcCWaUcRXqG9xjk9j7opAFuGh8siEmX4WZuz+61A46sXe0vXq1 w==; IronPort-SDR: a/3A60mHI0xL1gQ1kXWXC+MY4NGgJyJt8CqodeY06zFABRTLPWICbV6dkGM35YI6eBsQEzxABG wy9DA1FsO9w9RErJ7iqKXW5zM/S8C9TNY/jEFfcY8A7Kvg/pI1UI1ndN1RAn/JxjPUCt7Y7Lr9 UZHOUbDAvLtDHSPPIlN1Ti3YeGIamlhY9C70slsK+rjjrYZ0LOoZgcBoj58FmLEMcCm7e2HTSD zWnY1Y2wChOwIFIAXgKBss8xuvCqHvndpB9cRN9IaWJicEGGD0aqFMrwY66xAdr16apIm3PuQ+ 9dr+AKqeQxYhfZBVMK1OxQbt IronPort-SDR: /mxpbohggUL0XPGc0RBOUKL3GWeQEPHmqmK8QnZ5xNExlO54wRxFRlgJCtziYPnJJHDfUZGT22 WGoe9qZfmKcKxS8ldYj60JIkZMRoc72iAREx0MgMNH+XttKG927pempIGWId52zII72d13LAHV +jUMHPJRcBBFVUIekf1mQ3O1A9TUmog8pFQvVPF9WiHShhYMbeVoFkKJ+iDSQhxz2+42yDnCkO C31gy1w05IvtOdYh5zsT3ExB6i3aM10FNGG2L0U5juD4kJr+jfpfA3JCNZBwE/XBELBA/mJLkP 9Ss= 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, zong@andestech.com, alistair.francis@wdc.com, alistair23@gmail.com Subject: [RFC v2 07/20] sysdeps/gettimeofday: Use clock_gettime64 if avaliable Date: Mon, 24 Jun 2019 17:09:04 -0700 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Not all architectures support the obsolete gettimeofday so use the newer clock_gettime64 syscall if it is avaliable. This fixes RV32 build issues. Signed-off-by: Alistair Francis --- ChangeLog | 1 + sysdeps/unix/sysv/linux/gettimeofday.c | 28 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/ChangeLog b/ChangeLog index a700783ef3..f1c7acb6ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ * sysdeps/unix/sysv/linux/nanosleep.c: Likewise. * sysdeps/unix/sysv/linux/nanosleep_nocancel.c: Likewise. * sysdeps/unix/sysv/linux/lowlevellock-futex.h: Use __NR_futex_time64 if we don't have __NR_futex. + * sysdeps/unix/sysv/linux/gettimeofday.c: Use clock_gettime64 syscall for gettimeofday. 2019-06-20 Dmitry V. Levin Florian Weimer diff --git a/sysdeps/unix/sysv/linux/gettimeofday.c b/sysdeps/unix/sysv/linux/gettimeofday.c index a74f03825a..3d2b943123 100644 --- a/sysdeps/unix/sysv/linux/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/gettimeofday.c @@ -32,7 +32,35 @@ int __gettimeofday (struct timeval *tv, struct timezone *tz) { +#ifdef __ASSUME_TIME64_SYSCALLS + int ret; + struct timespec now; + + ret = INLINE_VSYSCALL (clock_gettime64, 2, CLOCK_REALTIME, + &now); + + /* Convert from timespec to timeval */ + tv->tv_sec = now.tv_sec; + tv->tv_usec = now.tv_nsec / 1000; + + return ret; +#else +# ifdef __NR_clock_gettime64 + long int ret; + struct timespec now; + + ret = INLINE_VSYSCALL (clock_gettime64, 2, CLOCK_REALTIME, + &now); + + /* Convert from timespec to timeval */ + tv->tv_sec = now.tv_sec; + tv->tv_usec = now.tv_nsec / 1000; + + if (ret == 0 || errno != ENOSYS) + return ret; +# endif return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); +#endif } libc_hidden_def (__gettimeofday) weak_alias (__gettimeofday, gettimeofday)