From owner-dev-commits-src-all@freebsd.org Wed Jun 23 21:36:41 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8A0F4658793; Wed, 23 Jun 2021 21:36:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4G9Gmn3bHdz4V1X; Wed, 23 Jun 2021 21:36:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5FDBD3D8B; Wed, 23 Jun 2021 21:36:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15NLafis077078; Wed, 23 Jun 2021 21:36:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15NLafqJ077077; Wed, 23 Jun 2021 21:36:41 GMT (envelope-from git) Date: Wed, 23 Jun 2021 21:36:41 GMT Message-Id: <202106232136.15NLafqJ077077@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: e912fbe16757 - main - vdso gettimeofday: minor restructuring MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e912fbe1675714aab0179999923c171615e78c07 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2021 21:36:41 -0000 The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e912fbe1675714aab0179999923c171615e78c07 commit e912fbe1675714aab0179999923c171615e78c07 Author: Konstantin Belousov AuthorDate: 2021-06-22 23:58:32 +0000 Commit: Konstantin Belousov CommitDate: 2021-06-23 21:36:33 +0000 vdso gettimeofday: minor restructuring Call binuptime inside switch statement, instead of pre-calculating the abs argument. Change the type of the abs argument to bool. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30873 --- lib/libc/sys/__vdso_gettimeofday.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/libc/sys/__vdso_gettimeofday.c b/lib/libc/sys/__vdso_gettimeofday.c index 32c416a54392..4c1f4bda23e1 100644 --- a/lib/libc/sys/__vdso_gettimeofday.c +++ b/lib/libc/sys/__vdso_gettimeofday.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -59,7 +60,7 @@ tc_delta(const struct vdso_timehands *th, u_int *delta) * is based on the kernel implementation. */ static int -binuptime(struct bintime *bt, struct vdso_timekeep *tk, int abs) +binuptime(struct bintime *bt, struct vdso_timekeep *tk, bool abs) { struct vdso_timehands *th; uint32_t curr, gen; @@ -123,7 +124,7 @@ __vdso_gettimeofday(struct timeval *tv, struct timezone *tz) } if (tk->tk_ver != VDSO_TK_VER_CURR) return (ENOSYS); - error = binuptime(&bt, tk, 1); + error = binuptime(&bt, tk, true); if (error != 0) return (error); bintime2timeval(&bt, tv); @@ -135,7 +136,7 @@ int __vdso_clock_gettime(clockid_t clock_id, struct timespec *ts) { struct bintime bt; - int abs, error; + int error; if (tk == NULL) { error = _elf_aux_info(AT_TIMEKEEP, &tk, sizeof(tk)); @@ -149,7 +150,7 @@ __vdso_clock_gettime(clockid_t clock_id, struct timespec *ts) case CLOCK_REALTIME_PRECISE: case CLOCK_REALTIME_FAST: case CLOCK_SECOND: - abs = 1; + error = binuptime(&bt, tk, true); break; case CLOCK_MONOTONIC: case CLOCK_MONOTONIC_PRECISE: @@ -157,12 +158,12 @@ __vdso_clock_gettime(clockid_t clock_id, struct timespec *ts) case CLOCK_UPTIME: case CLOCK_UPTIME_PRECISE: case CLOCK_UPTIME_FAST: - abs = 0; + error = getnanouptime(&bt, tk); break; default: - return (ENOSYS); + error = ENOSYS; + break; } - error = binuptime(&bt, tk, abs); if (error != 0) return (error); bintime2timespec(&bt, ts);