Fix 189089 - port nspr w32 now.c fix to directory.

See bug # 188396 - NSPR should not use ftime on windows.
	This fixes a potential Year 2038 issue.
This commit is contained in:
mcs%netscape.com 2003-03-21 16:41:42 +00:00
Родитель 34dba23152
Коммит 64c117c784
1 изменённых файлов: 16 добавлений и 6 удалений

Просмотреть файл

@ -39,7 +39,9 @@
#include <sys/timeb.h>
#elif defined(XP_UNIX) || defined(XP_OS2_EMX) || defined(XP_BEOS)
#include <sys/time.h>
#elif defined(WIN32) || defined(XP_OS2_VACPP)
#elif defined(WIN32)
#include <windows.h>
#elif defined(XP_OS2_VACPP)
#include <sys/timeb.h>
#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 */