Several corrections thanks to Johan Lorensson
[mono.git] / mono / io-layer / timefuncs.c
index 57977b7d90aa7decc71c7dc0d6d12cb0b3d1eb58..8a79f3b4d577f3b171d082c396e3d9181e6551cc 100644 (file)
 #include <glib.h>
 #include <sys/time.h>
 #include <stdlib.h>
+#include <stdio.h>
 
 #include <mono/io-layer/wapi.h>
 #include <mono/io-layer/timefuncs-private.h>
+#include "mono/utils/mono-time.h"
 
 #undef DEBUG
 
@@ -36,6 +38,12 @@ void _wapi_timeval_to_filetime (struct timeval *tv, WapiFileTime *filetime)
        filetime->dwHighDateTime = ticks >> 32;
 }
 
+void _wapi_guint64_to_filetime (guint64 ticks, WapiFileTime *filetime)
+{
+       filetime->dwLowDateTime = ticks & 0xFFFFFFFF;
+       filetime->dwHighDateTime = ticks >> 32;
+}
+
 gboolean QueryPerformanceCounter(WapiLargeInteger *count G_GNUC_UNUSED)
 {
        return(FALSE);
@@ -48,23 +56,5 @@ gboolean QueryPerformanceFrequency(WapiLargeInteger *freq G_GNUC_UNUSED)
 
 guint32 GetTickCount (void)
 {
-       struct timeval tv;
-       guint32 ret;
-       
-       ret=gettimeofday (&tv, NULL);
-       if(ret==-1) {
-               return(0);
-       }
-       
-       /* This is supposed to return milliseconds since reboot but I
-        * really can't be bothered to work out the uptime, especially
-        * as the 32bit value wraps around every 47 days
-        */
-       ret=(guint32)((tv.tv_sec * 1000) + (tv.tv_usec / 1000));
-
-#ifdef DEBUG
-       g_message ("%s: returning %d", __func__, ret);
-#endif
-
-       return(ret);
+       return mono_msec_ticks ();
 }