POSIX conversions

Norman Diamond diamond at jit533.swstokyo.dec.com
Tue Jun 11 10:53:12 AEST 1991


In article <298 at mem.pe-nelson.com> milt at 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 at 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.



More information about the Comp.std.c mailing list