g77 second function always returns 0.0 on mingw32/egcs-1.1

N8TM@aol.com N8TM@aol.com
Thu Sep 24 23:18:00 GMT 1998


In a message dated 9/24/98 10:57:09 PM Pacific Daylight Time,
David.Billinghurst@riotinto.com.au writes:

> double G77_etime_0 (real tarray[2]
>  {
>    tarray[0] = ((real)clock()) / CLOCK_PER_SEC;  /* user time */
>    tarray[1] = 0.0; /* system time */
>    return (tarray[0]+tarray[1]);
>  }
>  
I would have thought that the W9x- compatible etime_.c which Mumit used for
his egcs-1.1 cygwin32 distribution would work also for mingw32.  It should be
in his libf2c patches. It returns elapsed time, using the WinAPI
QueryPerformancexxxx(). The one distributed with standard egcs "always"
returns 0. on W95, but works with a resolution of .010 seconds on NT4.

clock() from the newlib used in cygwinb19.dll is broken also on W95.  If there
is one which works in mingw32, why isn't it used in the egcs-1.1 cygwin
distribution?

Using clock() this way fails when the 32-bit value rolls over from INT_MAX to
INT_MIN, even if you have a working clock(). Technically, clock is typed
clock_t, which isn't necessarily int. You may lose resolution by rounding off
low order bits when casting to (float).



More information about the Gcc mailing list