🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #854

Re: CLOCKS_PER_SEC

#854
From: Doug Gwyn
Date: Fri, 27 Oct 1989 19:08
27 lines
1912 bytes
In article <20538@princeton.Princeton.EDU> nfs@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.
Technical Details
Message-ID: <11430@smoke.BRL.MIL>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!samsung!aplcen!haven!adm!smoke!gwyn
References: <20538@princeton.Princeton.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!samsung!aplcen!haven!adm!smoke!gwyn
From: gwyn@smoke.BRL.MIL (Doug Gwyn)
Newsgroups: comp.std.c
Subject: Re: CLOCKS_PER_SEC
Message-ID: <11430@smoke.BRL.MIL>
Date: 27 Oct 89 19:08:42 GMT
References: <20538@princeton.Princeton.EDU>
Reply-To: gwyn@brl.arpa (Doug Gwyn)
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 27