2008-04-03 Dick Porter <dick@ximian.com>
authorDick Porter <dick@acm.org>
Thu, 3 Apr 2008 13:22:47 +0000 (13:22 -0000)
committerDick Porter <dick@acm.org>
Thu, 3 Apr 2008 13:22:47 +0000 (13:22 -0000)
* timefuncs.c (GetTickCount): Use mono_msec_ticks(), see bug
347476.

svn path=/trunk/mono/; revision=99743

mono/io-layer/ChangeLog
mono/io-layer/timefuncs.c
mono/utils/mono-time.h

index a9717ccc7fafbcac428fe3f5e1f191fabc2ed73c..fdbb9c27e4a82f0ed4715005d7d902a380d52e25 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-03  Dick Porter  <dick@ximian.com>
+
+       * timefuncs.c (GetTickCount): Use mono_msec_ticks(), see bug
+       347476.
+
 2008-04-01  Dick Porter  <dick@ximian.com>
 
        * versioninfo.c (get_string_block): Refine the fix for bug 354856
index e0f13ed4a95516201c9b43e5782de5382c8d8dbc..16d01f8246b6a57bc54b5a71bdbd4f36fe2f4dcf 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <mono/io-layer/wapi.h>
 #include <mono/io-layer/timefuncs-private.h>
+#include "mono/utils/mono-time.h"
 
 #undef DEBUG
 
@@ -47,50 +48,7 @@ gboolean QueryPerformanceFrequency(WapiLargeInteger *freq G_GNUC_UNUSED)
        return(FALSE);
 }
 
-static void
-get_uptime (struct timeval *start_tv)
-{
-       FILE *uptime = fopen ("/proc/uptime", "r");
-       if (uptime) {
-               double upt;
-               if (fscanf (uptime, "%lf", &upt) == 1) {
-                       gettimeofday (start_tv, NULL);
-                       start_tv->tv_sec -= (int)upt;
-                       start_tv->tv_usec = 0;
-                       fclose (uptime);
-                       return;
-               }
-               fclose (uptime);
-       }
-       /* a made up uptime */
-       gettimeofday (start_tv, NULL);
-       start_tv->tv_sec -= 300;
-}
-
 guint32 GetTickCount (void)
 {
-       struct timeval tv;
-       static struct timeval start_tv = {0};
-       guint32 ret;
-
-       if (!start_tv.tv_sec)
-               get_uptime (&start_tv);
-       ret=gettimeofday (&tv, NULL);
-       if(ret==-1) {
-               return(0);
-       }
-       
-       tv.tv_sec -= start_tv.tv_sec;
-       tv.tv_usec -= start_tv.tv_usec;
-       if (tv.tv_usec < 0) {
-               tv.tv_sec++;
-               tv.tv_usec += 1000000;
-       }
-       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 ();
 }
index 6e5a32917f251ab1a15d30e93dc5ec4c3a57ab48..dced878d9ee1acf6a13bfad5bfae791ad63ed78e 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __UTILS_MONO_TIME_H__
 #define __UTILS_MONO_TIME_H__
 
-#include <utils/mono-compiler.h>
+#include <mono/utils/mono-compiler.h>
 #include <glib.h>
 
 /* Returns the number of milliseconds from boot time: this should be monotonic */