Waldek Hebisch a écrit:
Prof A Olowofoyeku wrote:
To get GPC runtime tries to use the 'gettimeofday' function if available, otherwise the 'time' function is used. I think that the 'gettimeofday' is not available in MinGW or at least GPC can not detect it. To check if GPC detected 'gettimeofday' one could look at p/rts/rts-config.h file generated during build and check if it contains line:
#define HAVE_GETTIMEOFDAY 1
If not GPC will use 'time' function which has limited resolution: it can not return microsecond part.
One solution is to ask Mingw maintainers to provide 'gettimeofday'. Alternatively, we can look for appropriate native Windows function...
HAVE_GETTIMEOFDAY 1 is defined in p/rts/rts-config.h and the function gettimeofday() is declared in <sys/time.h>
But os-hacks.h used to compile gpc with mingw contains: ----------------------------------------------------------------------- /* we undefine HAVE_GETTIMEOFDAY because of Cygwin's date/time bug */ #undef HAVE_GETTIMEOFDAY
/* new time() that uses the WinAPI to call GetLocalTime */ #undef time #define time(_timer) \ ( \ { \ time_t *timer = (_timer); \ SYSTEMTIME tmp; \ time_t tmp2 = 0; \ struct tm gnu; \ memset (&gnu, 0, sizeof (gnu)); \ GetLocalTime (&tmp); \ gnu.tm_isdst = -1; \ gnu.tm_year = tmp.wYear - 1900; \ gnu.tm_mon = tmp.wMonth - 1; \ gnu.tm_mday = tmp.wDay; \ gnu.tm_hour = tmp.wHour; \ gnu.tm_min = tmp.wMinute; \ gnu.tm_sec = tmp.wSecond; \ tmp2 = mktime (&gnu); \ if (timer) *timer = tmp2; \ tmp2; \ } \ ) ----------------------------------------------------------- this function time() apparently does not set microseconds.
Maurice