Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mem!milt From: milt@mem.pe-nelson.com (Milt Ratcliff) Newsgroups: comp.std.c Subject: POSIX conversions Summary: How to convert time routines to POSIX Keywords: POSIX Message-ID: <301@mem.pe-nelson.com> Date: 10 Jun 91 23:15:24 GMT Organization: PE-Nelson, Cupertino, CA Lines: 32 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. To provide formatted time strings, the strftime function is relatively easy to use. To provide the input to the strftime function, gettimeofday has been used and the seconds part of the timeval struct(tv_sec) passed to localtime. This, in turn, has provided the tm struct used by strftime. The use of gettimeofday has served a dual purpose, the first described above. In addition it provides a very high resolution timer capatility, returning the elapsed time in u-seconds since Jan. 1, 1970. Obviously, the resolution is actually controlled by the hardware clock, but it will provide resolution within that restraint. My question concerns a replacement for the gettimeofday function which will provide this 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. Also, I am not sure of the meaning of 'Standard C'(I am using "POSIX Programmer's Guide by Donald Lewine, O'Reilly & Associates, Inc.). Is this the correct approach and can I expect the results to be equivalent to the data obtained from gettimeofday? Thanks, Milt Milt Ratcliff milt@pe-nelson.com PE-Nelson Cupertino, CA