X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/47801f582a7b05f4cd4680f96fb44316fe4e7a89..7236b52536dbdf823a94fef2a07536f548ddcc21:/src/xbt/xbt_os_time.c diff --git a/src/xbt/xbt_os_time.c b/src/xbt/xbt_os_time.c index b93b0f1e29..bcdf8adfff 100644 --- a/src/xbt/xbt_os_time.c +++ b/src/xbt/xbt_os_time.c @@ -15,6 +15,50 @@ #include "portable.h" #include /* floor */ + +#ifdef WIN32 +#include +#include + +int +gettimeofday(struct timeval *tv, struct timezone *tz) +{ + + #if defined(WIN32_WCE) || (_WIN32_WINNT < 0x0400) + struct _timeb tm; + #else + FILETIME ft; + unsigned __int64 tm; + #endif + + if (!tv) + { + errno = EINVAL; + return -1; + } + + #if defined(WIN32_WCE) || (_WIN32_WINNT < 0x0400) + _ftime (&tm); + + tv->tv_sec = tm.time; + tv->tv_usec = tm.millitm * 1000; + #else + GetSystemTimeAsFileTime (&ft); + tm = (unsigned __int64)ft.dwHighDateTime << 32; + tm |= ft.dwLowDateTime; + tm /=10; + tm -= 11644473600000000ULL; + + tv->tv_sec = (long) (tm / 1000000L); + tv->tv_usec = (long) (tm % 1000000L); + #endif + + + + return 0; +} +#endif + double xbt_os_time(void) { #ifdef HAVE_GETTIMEOFDAY struct timeval tv;