Bug 463562: load mmtimer.dll and look up timeGetTime at run time because
authorwtc%google.com
Fri, 21 Nov 2008 21:14:50 +0000
changeset 4013 6f286cfdb9266f9d505c2671443273d3a15d9de6
parent 4012 7b72364003c6c58701238339901a12ede42d64ea
child 4014 3a269221a6f7a2db77aa92da5aa1782c0de89f21
push idunknown
push userunknown
push dateunknown
bugs463562
Bug 463562: load mmtimer.dll and look up timeGetTime at run time because not all WINCE systems have mmtimer.dll. The patch is contributed by Brad Lassey <blassey@mozilla.com>. r=wtc.
pr/src/md/windows/ntinrval.c
--- a/pr/src/md/windows/ntinrval.c
+++ b/pr/src/md/windows/ntinrval.c
@@ -37,24 +37,43 @@
 
 /*
  * NT interval timers
  *
  */
 
 #include "primpl.h"
 
+#ifdef WINCE
+typedef DWORD (*IntervalFuncType)(void);
+static IntervalFuncType intervalFunc;
+#endif
+
 void
 _PR_MD_INTERVAL_INIT()
 {
+#ifdef WINCE
+    HMODULE mmtimerlib = LoadLibraryW(L"mmtimer.dll");  /* XXX leaked! */
+    if (mmtimerlib) {
+        intervalFunc = (IntervalFuncType)GetProcAddress(mmtimerlib,
+                                                        "timeGetTime");
+    } else {
+        intervalFunc = &GetTickCount;
+    }
+#endif
 }
 
 PRIntervalTime 
 _PR_MD_GET_INTERVAL()
 {
-    return timeGetTime();  /* milliseconds since system start */
+    /* milliseconds since system start */
+#ifdef WINCE
+    return (*intervalFunc)();
+#else
+    return timeGetTime();
+#endif
 }
 
 PRIntervalTime 
 _PR_MD_INTERVAL_PER_SEC()
 {
     return 1000;
 }