Path: 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 In article <20538@princeton.Princeton.EDU> nfs@notecnirp.UUCP (Norbert Schlenker) writes: >What happened to the macro CLK_TCK in ? 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 . 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 : #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 , but due to IEEE Std 1003.1-1988 stating that it is defined in , the above seems like the best solution. Note that you cannot conform to X3.159 if CLK_TCK is #defined by 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.