--- a/drivers/timers_win32/timers_win32.c Thu Dec 22 13:46:00 2011 +0100
+++ b/drivers/timers_win32/timers_win32.c Thu May 12 12:23:20 2011 +0000
@@ -38,7 +38,7 @@
};
#endif
-struct _timeb timebuffer;
+DWORD timebuffer;
/* Synchronization Object Implementation */
CRITICAL_SECTION CanFestival_mutex;
@@ -90,8 +90,8 @@
WaitForSingleObject(timer, INFINITE);
if(stop_timer)
break;
- _ftime(&timebuffer);
EnterMutex();
+ timebuffer = GetTickCount();
TimeDispatch();
LeaveMutex();
}
@@ -112,7 +112,7 @@
}
// Take first absolute time ref in milliseconds.
- _ftime(&timebuffer);
+ timebuffer = GetTickCount();
}
void TimerCleanup(void)
@@ -158,7 +158,7 @@
LARGE_INTEGER liDueTime;
/* arg 2 of SetWaitableTimer take 100 ns interval */
- liDueTime.QuadPart = (-1 * value);
+ liDueTime.QuadPart = ((long long) (-1) * value * 10000);
//printf("SetTimer(%llu)\n", value);
if (!SetWaitableTimer(timer, &liDueTime, 0, NULL, NULL, FALSE))
@@ -171,8 +171,7 @@
/* Get the elapsed time since the last occured alarm */
TIMEVAL getElapsedTime(void)
{
- struct _timeb timetmp;
- _ftime(&timetmp);
- return (timetmp.time - timebuffer.time) * 10000000 + (timetmp.millitm - timebuffer.millitm) * 10000;
+ DWORD timetmp = GetTickCount();
+ return (timetmp - timebuffer);
}
--- a/include/win32/timerscfg.h Thu Dec 22 13:46:00 2011 +0100
+++ b/include/win32/timerscfg.h Thu May 12 12:23:20 2011 +0000
@@ -26,12 +26,12 @@
#include <windows.h>
-// Time unit : 100 ns
-#define TIMEVAL unsigned long long
+// Time unit : 1msec
+#define TIMEVAL DWORD
#define TIMEVAL_MAX ~(TIMEVAL)0
-#define MS_TO_TIMEVAL(ms) ms*10000
-#define US_TO_TIMEVAL(us) us*10
+#define MS_TO_TIMEVAL(ms) ms
+#define US_TO_TIMEVAL(us) (us / 1000)
#define TASK_HANDLE HANDLE