From patchwork Wed Jul 17 00:08:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1132996 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-103686-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="v8Tq/Ftl"; dkim=pass (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="jx2zbNfq"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45pHkh4Szwz9s8m for ; Wed, 17 Jul 2019 10:11:56 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=N5D/6mG2sqOSFf+N7QljpFCyVKYcVlsMUZJqycaxFt1EpakHbFbQx hBu/nveYGSmM9D2PHRN9BIhcFsgH0vCpOAqx9npOmPOA1XZZp8gmXJJHLGA4XUGg N6AoUtUgDfCr4fniso74/ezAzojXlybJuHEYmgHt0lHAgIUdHlAYus= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=1VagezMIhmfRU4tBnczNt4cXQGE=; b=v8Tq/FtlV3R5UpeIHqXyKyBgi0Yg oTjtr25wy+XzIUBT3v9FTl0qSRsJxQOoOo/lYnWS/eJVeuVeBR3sdHwUU9pAe1yR 6fLf1npKqxmQK8Jca5M08/meIimNJ1XMwDMQvZmEdjywu55Gm5fp/c8qaKfaOVud H6Aia7mOeAE3WEc= Received: (qmail 14937 invoked by alias); 17 Jul 2019 00:11:41 -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 14866 invoked by uid 89); 17 Jul 2019 00:11:40 -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: 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=1563322300; x=1594858300; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7BcjHw/mfXm4bJKMMV4PVboGHVo7TskTMkdOq7F4FCE=; b=jx2zbNfqOn2A0dJUWyc5SukvNM1e3gBidGsRRaTg1mWvtBYVXMbPe9n/ +Fm+kCN1Mseh729z7PmbltogL5fjkeuluwm3BNZ4QOAEMi1jAXTNT7H9C t7jmCQsqQp32S8nHJR0oEiZNGgJLACaHwnbBfVLmdkYdcDUf9B9zDD8Lt 8C1GRU8HsF8D/FB1TORCQ1i0rv0Qlp70dJK6GuEJKa344mGrwtGHfQqg0 xMVFK579EuGQwkdEVcka1ytEoNe7FBVYnVVdQa0H6NkNQN5JTMjK/Ev0l 3K6ymsncz+aKdPDfQYcqQBAvLRpmPp4laYbbCGqKU9zVFuoURGrvpYcPW A==; IronPort-SDR: ydN58vf940vYSBeGucRj31qNqhBJuL4hXh2u5/7vASmLKubULXp1AXJ91402gGeZSTTGcRw0Ij pTkfTzg02I8tto3vqsJ/IIAO4dFy4jqzQweeonZfUh/lV+gPP2iMsvA44koV3af+l6YjuxUrW7 VjHhcAOTXbBCfUE3lZ7ysAOWaXze9EOkNfP9ZoKSh1Nb+u4p1NTl9h158psprzfYS98yM1JHGD bztMs1PXU6oCmYMNqHmj7vZqv4Oxp0sM51oG6GBPcOyAH9ZmRLt5jLqxj/mX/c/YMwX90MtSeo Jq4= IronPort-SDR: DSl3dJ5+6OU6cyqt3E5hrlx9z36sdEQ553L6BCZBt0WhyHNqPoNBOlWLntzgF0hP/Roqqmo7IM 7DqT/Hmt/IHqMQNq6sgSVGrvdebINrfhpAQxf+2ViGLJY9n9qHeHNDBehZhoGa7FKdlAxmzZHJ iezwQ9s4x4i97WqNhPXzsNBnW2Xh14rrHIGNPt/4ndgyRaM0GJ6bZ7Z3957DimxWz7J1bNsTMW SK6JfPm68YUgfKgB2Q7HqjQGdFH5ZX2wt4Kp0D9mr3RaIEVYbdqjlx2OkwM/pdUZwp/32ZKCCC +ZM2SW4u/d2qwbPLQUdocmEQ IronPort-SDR: Y2E4wkGxn9Gc9u98z798jGhO7depKPTcb1xcsz4Q3CFdRYUyuHtgb1YXHDyRJOj3FBfYcbqUEh tUKZSfVXMkt7ZJDETnITsNIlBCOOQj+RAZoDgXXtJ7WIZKAcFBbWkwTQMT8d2+ZqyLWKXRzdi6 9JAp4rSrw1OX62sVXC/RGU81aS60XFQe8BDVKm/bcgLoKRa4cX0HbkSer3alogqQ4n4I37OIro BYmWhF1n0/SWntC2GqH2OQWh0j3ZJRsOM2ctQdobBR+guM42X5xufZ8A6NRLQ4cR2lKSTq2pqD 7vM= 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 v3 02/23] sysdeps/gettimeofday: Use clock_gettime64 if avaliable Date: Tue, 16 Jul 2019 17:08:46 -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 477b9b49b3..9ca390a9c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1028,6 +1028,7 @@ * nptl/thrd_sleep.c: Use clock_nanosleep_time64 instead of nanosleep. * sysdeps/unix/sysv/linux/nanosleep.c: Likewise. * sysdeps/unix/sysv/linux/nanosleep_nocancel.c: Likewise. + * 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..151b1e606c 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 __timespec64 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 __timespec64 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)