Date: Tue, 4 Sep 2001 13:20:01 -0700 (PDT) From: Bernd Luevelsmeyer <bdluevel@heitec.net> To: freebsd-bugs@FreeBSD.org Subject: Re: misc/30297: CLOCKS_PER_SEC non-standard Message-ID: <200109042020.f84KK1V43324@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/30297; it has been noted by GNATS. From: Bernd Luevelsmeyer <bdluevel@heitec.net> To: Bruce Evans <bde@zeta.org.au> Cc: freebsd-gnats-submit@FreeBSD.ORG, David Malone <dwmalone@maths.tcd.ie> 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 <time.h> 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 <time.h>", 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109042020.f84KK1V43324>