From owner-freebsd-bugs Tue Sep 4 13:20:10 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id B692037B401 for ; Tue, 4 Sep 2001 13:20:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id f84KK1V43324; Tue, 4 Sep 2001 13:20:01 -0700 (PDT) (envelope-from gnats) Date: Tue, 4 Sep 2001 13:20:01 -0700 (PDT) Message-Id: <200109042020.f84KK1V43324@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Bernd Luevelsmeyer Subject: Re: misc/30297: CLOCKS_PER_SEC non-standard Reply-To: Bernd Luevelsmeyer Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR misc/30297; it has been noted by GNATS. From: Bernd Luevelsmeyer To: Bruce Evans Cc: freebsd-gnats-submit@FreeBSD.ORG, David Malone Subject: Re: misc/30297: CLOCKS_PER_SEC non-standard Date: Tue, 04 Sep 2001 22:11:44 +0200 Bruce Evans wrote: > On Mon, 3 Sep 2001, Bernd Luevelsmeyer wrote: > > > >Description: > > CLOCKS_PER_SEC in the #include-file is 128. > > "The Single UNIX Specification" at > > http://www.UNIX-systems.org/online.html however says > > "CLOCKS_PER_SEC is defined to be one million in ", and > > the Red Hat Linux 7.2 manpage says "POSIX requires > > that CLOCKS_PER_SEC equals 1000000 independent of the actual > > resolution." > > This is an XSI extension. In POSIX, CLOCKS_PER_SECOND can be any > (arithmetic) (r)value, the same as in ISO C. Even in XSI, applications > should not use this misfeature. From POSIX.1-200x draft7: > > 13691 XSI Although the value of CLOCKS_PER_SEC is required to be 1 million on all XSI-conformant > 13692 systems, it may be variable on other systems, and it should not be assumed that > 13693 CLOCKS_PER_SEC is a compile-time constant. > > Constants like this shouldn't be standardized. A resolution of only 1 > part in a million is is potentially inadequate by a factor of about 1000 > even for today's 1GHz systems. POSIX's clock_getres() is similarly broken > as designed. Thanks for your explanations. I'm retracting the PR; please close it. Perhaps a comment in either the header file or the clock(3) man page might be appropriate, in order to prevent someone else from raising the issue again? I suggest to put it into the clock.3 "Standards" section. --- clock.3.old Tue Sep 4 22:02:01 2001 +++ lib/libc/gen/clock.3 Tue Sep 4 22:04:08 2001 @@ -69,3 +69,6 @@ .Fn clock function conforms to .St -isoC . +CLOCKS_PER_SEC is not 1 million (as required by XSI), because +this may be inadequate even on today's 1 GHz systems, and anyway +it's not a POSIX requirement. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message