summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--win32/contrib/timer/timer.c33
1 files changed, 9 insertions, 24 deletions
diff --git a/win32/contrib/timer/timer.c b/win32/contrib/timer/timer.c
index 179b7e18f..3b171117c 100644
--- a/win32/contrib/timer/timer.c
+++ b/win32/contrib/timer/timer.c
@@ -24,41 +24,26 @@
*
*/
-#include "stdio.h"
+#include <sys/timeb.h>
+#include <signal.h>
#include "timer.h"
-#include <signal.h>
#ifndef SIGALRM
#define SIGALRM 14
#endif
- /*
- this function returns somewhat
- accurate unix time with the data
- accurate to the first call to get
- of day and the resolution accurate
- to ~ miliseconds.
-*/
-static time_t startseconds = 0;
-
-int gettimeofday( struct timeval *tp, struct timezone *tzp )
-{
- MMTIME mmtime;
+int gettimeofday(struct timeval *tv, struct timezone *tz) {
+ struct timeb timebuffer;
- // clock() returns time in miliseconds
+ ftime(&timebuffer);
+ tv->tv_sec = timebuffer.time;
+ tv->tv_usec = timebuffer.millitm * 1000;
- if( !startseconds )
- startseconds = time( 0 );
-
- timeGetSystemTime( &mmtime, sizeof( mmtime ) );
-
- tp->tv_sec = ( mmtime.u.ms / 1000 ) + startseconds;
- tp->tv_usec = ( mmtime.u.ms % 1000 ) * 1000;
+ return 0;
+}
- return 0;
-};
/*
These functions are designed to mimick