CLOCKS_PER_SEC
Doug Gwyn
gwyn at smoke.BRL.MIL
Sat Oct 28 05:08:42 AEST 1989
In article <20538 at princeton.Princeton.EDU> nfs at notecnirp.UUCP (Norbert Schlenker) writes:
>What happened to the macro CLK_TCK in <time.h>? Really old copies of
>the draft standard have it, but Dec 1988 has CLOCKS_PER_SEC instead.
>The POSIX documentation is full of stuff that depends on X3J11 defining
>this in <time.h>. What should I do?
CLOCKS_PER_SEC was a last-minute correction to a longstanding error in
the draft proposed C standard; somebody had pointed out to X3J11 that
P1003 was using CLK_TCK for the conversion constant, and we picked it
up for X3.159 as well, only realizing much later that we had made a
horrible mistake, because the X3.159 and 1003.1 uses were NOT the same!
My recommendation is to include the following in <time.h>:
#define CLOCKS_PER_SEC 1000 /* all UNIX System V systems */
#ifdef _POSIX_SOURCE
#define CLK_TCK 60 /* or whatever HZ is */
#endif
CLK_TCK should really be defined in a POSIX-specific header, not in
<time.h>, but due to IEEE Std 1003.1-1988 stating that it is defined
in <time.h>, the above seems like the best solution.
Note that you cannot conform to X3.159 if CLK_TCK is #defined by
<time.h> without some form of extra-standard "feature test" like
the above. Applications that expect to use the facilities that
IEEE Std 1003.1 says are defined by the Standard C headers should
always set _POSIX_SOURCE before including the standard headers,
so the above kludge is fairly transparent.
More information about the Comp.std.c
mailing list