Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!decwrl!pa.dec.com!jrdzzz.jrd.dec.com!tkou02.enet.dec.com!jit533!diamond From: diamond@jit533.swstokyo.dec.com (Norman Diamond) Newsgroups: comp.std.c Subject: Re: POSIX conversions Keywords: POSIX Message-ID: <1991Jun11.005312.591@tkou02.enet.dec.com> Date: 11 Jun 91 00:53:12 GMT References: <298@mem.pe-nelson.com> Sender: usenet@tkou02.enet.dec.com (USENET News System) Reply-To: diamond@jit533.enet@tkou02.enet.dec.com (Norman Diamond) Organization: Digital Equipment Corporation Japan , Tokyo Lines: 32 In article <298@mem.pe-nelson.com> milt@mem.pe-nelson.com (Milt Ratcliff) writes: >I am trying to make several programs POSIX compliant. As part of the effort I >am confronted with a need to convert routines which measure time. >My question concerns a replacement for the gettimeofday function which will >provide [high] level of timing resolution within a POSIX routine. The POSIX >documents I am reading imply the use of either clock() or times(). My >intention is to use times() which is required by POSIX while clock() is >required by Standard C but not POSIX. The clock() function returns CPU usage, not time of day. If you want your program to be strictly conformant to ANSI C (i.e. usable on (approximately) all ANSI-conformant processors), then you want the time() function. But you hint that this may not have sufficient resolution for your application. So you only want to run on POSIX-conformant processors, and you can call a POSIX function which meets your needs; that might be times(). >Also, I am not sure of the meaning of 'Standard C' In this newsgroup, it seems to mean the ANSI 1989 standard, and the corresponding ISO standard. Also, a processor-supplied definition of the macro __STDC__ with value 1 is supposed to mean this standard (though some non-ANSI vendors have caused problems with this). >can I expect the results to be equivalent to [...] gettimeofday? The POSIX newsgroups might be more helpful for you. -- Norman Diamond diamond@tkov50.enet.dec.com If this were the company's opinion, I wouldn't be allowed to post it. Permission is granted to feel this signature, but not to look at it.