Windows: fix Time_tToSystemTime function to be 64-bit compliant
authorJosh Sinykin <josh.sinykin@broadcom.com>
Mon, 19 Sep 2016 03:17:30 +0000 (04:17 +0100)
committerJens Axboe <axboe@fb.com>
Mon, 19 Sep 2016 14:28:11 +0000 (08:28 -0600)
Use LONGLONG instead of LARGE_INTEGER to avoid problems on 64-bit
systems causing a crash.

Signed-off-by: Jens Axboe <axboe@fb.com>
os/windows/posix.c

index fd3d9ab38111c0ecd46f86c664b62a7ec15bb145..5830e4c4edab4cd7bee764873fb9aafa61de3fdf 100755 (executable)
@@ -232,10 +232,12 @@ char *dlerror(void)
 /* Copied from http://blogs.msdn.com/b/joshpoley/archive/2007/12/19/date-time-formats-and-conversions.aspx */
 void Time_tToSystemTime(time_t dosTime, SYSTEMTIME *systemTime)
 {
-    LARGE_INTEGER jan1970FT;
-    LARGE_INTEGER utcFT;
-    jan1970FT.QuadPart = 116444736000000000LL; // january 1st 1970
-    utcFT.QuadPart = ((unsigned __int64)dosTime) * 10000000 + jan1970FT.QuadPart;
+    FILETIME utcFT;
+    LONGLONG jan1970;
+
+    jan1970 = Int32x32To64(dosTime, 10000000) + 116444736000000000;
+    utcFT.dwLowDateTime = (DWORD)jan1970;
+    utcFT.dwHighDateTime = jan1970 >> 32;
 
     FileTimeToSystemTime((FILETIME*)&utcFT, systemTime);
 }