From nobody Thu Apr 14 08:04:47 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B6F621B478D3; Thu, 14 Apr 2022 08:04:47 +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 4KfBnq4l7wz3D8H; Thu, 14 Apr 2022 08:04:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649923487; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=m0UPbXkqqUodKF+f7ZoxY0a3REIjIZgAwIRYaVVtfT4=; b=yJMmX2crEpcw2RJ0lH7FfS+isNkZ5IMLta6VcllBs7dsqwcJCcxxKTvmrXEIHUGhE9AFDe uPzhd3bE6GXWqdy8jRLBpmmsXWSG7sTW9I9/oIN0O7wkLFKASYDcXdonoLyC5myic1NSQi 9z6IuzZi8XQO2atakjwWJ9Pb3jWUC2045Id5wVvkp7QUI5OkPnvcwh2uoACHVNy5uNxgUD LqogJ4Qj/zSomN5J2NRHZyKzIO770SKx6UnpYcmYX99PtOZT5jgzFcgeeBq8SgkP6Ac2vc RuhFYsmIsq5aQRIKxSsc6nzGPEKlg6LOPK5wHGdCpY4vv1UGVoCFFfAcpIq4vA== 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 7F0FD1C7FA; Thu, 14 Apr 2022 08:04:47 +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 23E84lo4007643; Thu, 14 Apr 2022 08:04:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23E84l97007642; Thu, 14 Apr 2022 08:04:47 GMT (envelope-from git) Date: Thu, 14 Apr 2022 08:04:47 GMT Message-Id: <202204140804.23E84l97007642@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Bergling Subject: git: 3e0f3678eca7 - main - time(3): Refine history in the manual page List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3e0f3678eca7c3f296b9f702992737356f1792da Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649923487; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=m0UPbXkqqUodKF+f7ZoxY0a3REIjIZgAwIRYaVVtfT4=; b=L98hB3N1rbPgP6vLsdGvuqH9qgYGSJkyPH5UEx451/CGfTM7uCcADsMd/M5JxELAWMIjN3 y7wlk58NUUHnyRUayS1xsJu+6z1WoXwX0JrPtGjfQN8BGQEDhG1GAfHsS5YZ2qvnsECCF8 yDiZvK64jKYHyAdy+yvBSoKou2l+npEygyBQbcckT39rcSitFJ1+XW/b73HT/SggmNXd/N QDCbeM1BZNBFusxlM8GlSk0gND0Gdv4+84p1y2ChDzz5ALAHIVZ0EoY9ilowNVftePKkOL x13s7un+A3JHA5CsCwGXJh+tloXK5r4Xo6FUtoN2xipLqxKvXnF7Sb0lfiRaIg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649923487; a=rsa-sha256; cv=none; b=BhRid+G6GGyPBAsP9h1cLfM2Woitjgz6CzDNsSM4/25mNYO7l9liqIHVIZIvsLZO4d/kx5 S6RxxuOLSzT/8/KGL/1dKyaL8S9SpQY+kK7JQZmwvPEFGX6TxaWiLA/4lCY/4c7qGBosqp bVMZcFrmi/7JbUz4t++xZQi4CRCEmFJFxBhYmDlA4lWZP7CULe1F8peXp0m1YDqU5FxE0m 5rRr0YeA+ndJbfLch+bYbuoBjdsasHdnzCQ4XNiCTcBdvDimX4CTuJP9c+yxDpUIxOtVQ+ AX2rK+muU/qGqhOjt2tCf5fEZSUC8o/b96cEU7JDMDn4hIK5tlMC6ZBG6S8Gdw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=3e0f3678eca7c3f296b9f702992737356f1792da commit 3e0f3678eca7c3f296b9f702992737356f1792da Author: Gordon Bergling AuthorDate: 2022-04-14 08:04:14 +0000 Commit: Gordon Bergling CommitDate: 2022-04-14 08:04:14 +0000 time(3): Refine history in the manual page The time() system call first appeared in Version 1 AT&T UNIX. Through the Version 3 AT&T UNIX, it returned 60 Hz ticks since an epoch that changed occasionally, because it was a 32-bit value that overflowed in a little over 2 years. In Version 4 AT&T UNIX the granularity of the return value was reduced to whole seconds, delaying the aforementioned overflow until 2038. Version 7 AT&T UNIX introduced the ftime() system call, which returned time at a millisecond level, though retained the gtime() system call (exposed as time() in userland). time() could have been implemented as a wrapper around ftime(), but that wasn't done. 4.1cBSD implemented a higher-precision time function gettimeofday() to replace ftime() and reimplemented time() in terms of that. Since FreeBSD 9 the implementation of time() uses clock_gettime(CLOCK_SECOND) instead of gettimeofday() for performance reasons. With most valuable input from Warner (imp@). Reviewed by: 0mp, jilles, imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D34751 --- lib/libc/gen/time.3 | 57 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/lib/libc/gen/time.3 b/lib/libc/gen/time.3 index 1563e672b3ba..52785057a56b 100644 --- a/lib/libc/gen/time.3 +++ b/lib/libc/gen/time.3 @@ -32,7 +32,7 @@ .\" @(#)time.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd March 4, 2022 +.Dd April 14, 2022 .Dt TIME 3 .Os .Sh NAME @@ -49,7 +49,7 @@ The .Fn time function returns the value of time in seconds since 0 hours, 0 minutes, -0 seconds, January 1, 1970, Coordinated Universal Time. +0 seconds, January 1, 1970, Coordinated Universal Time (UTC). If an error occurs, .Fn time returns the value @@ -73,12 +73,54 @@ function may fail for any of the reasons described in The .Nm function conforms to -.St -p1003.1-2001 . +.St -p1003.1-2008 . .Sh HISTORY -A +The +.Fn time +system call first appeared in +.At v1 . +Through the +.At v3 , +it returned 60 Hz ticks since an epoch that changed occasionally, because it +was a 32-bit value that overflowed in a little over 2 years. +.Pp +In +.At v4 +the granularity of the return value was reduced to whole seconds, +delaying the aforementioned overflow until 2038. +.Pp +.At v7 +introduced the +.Fn ftime +system call, which returned time at a millisecond level, +though retained the +.Fn gtime +system call (exposed as +.Fn time +in userland). +.Fn time +could have been implemented as a wrapper around +.Fn ftime , +but that wasn't done. +.Pp +.Bx 4.1c +implemented a higher-precision time function +.Fn gettimeofday +to replace +.Fn ftime +and reimplemented +.Fn time +in terms of that. +.Pp +Since +.Fx 9 +the implementation of .Fn time -function appeared in -.At v6 . +uses +.Fn clock_gettime "CLOCK_SECOND" +instead of +.Fn gettimeofday +for performance reasons. .Sh BUGS Neither .St -isoC-99 @@ -92,8 +134,7 @@ on failure; thus, it is impossible for an application to distinguish the valid time value \-1 (representing the last UTC second of 1969) from the error return value. .Pp -Systems conforming to earlier versions of the C and -.Tn POSIX +Systems conforming to earlier versions of the C and POSIX standards (including older versions of .Fx ) did not set