diff --git a/directory/c-sdk/config/now.c b/directory/c-sdk/config/now.c index 784b5ceabde..28beb7bef80 100644 --- a/directory/c-sdk/config/now.c +++ b/directory/c-sdk/config/now.c @@ -39,7 +39,9 @@ #include #elif defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS) #include -#elif defined(WIN32) || defined(XP_OS2_VACPP) +#elif defined(WIN32) +#include +#elif defined(XP_OS2_VACPP) #include #else #error "Architecture not supported" @@ -86,12 +88,20 @@ int main(int argc, char **argv) #elif defined(WIN32) __int64 now; - struct timeb b; - ftime(&b); - now = b.time; - now *= 1000000; - now += (1000 * b.millitm); + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + CopyMemory(&now, &ft, sizeof(now)); + /* + * 116444736000000000 is the number of 100-nanosecond intervals + * between Jan. 1, 1601 and Jan. 1, 1970. + */ +#ifdef __GNUC__ + now = (now - 116444736000000000LL) / 10LL; + fprintf(stdout, "%lld", now); +#else + now = (now - 116444736000000000i64) / 10i64; fprintf(stdout, "%I64d", now); +#endif #elif defined(XP_OS2_VACPP) /* no long long or i64 so we use a string */