Browse Source

When faking gettimeofday with ftime, do it right.

svn:r2068
Nick Mathewson 21 years ago
parent
commit
06c11a61ce
2 changed files with 8 additions and 4 deletions
  1. 4 1
      src/common/util.c
  2. 4 3
      src/common/util.h

+ 4 - 1
src/common/util.c

@@ -808,7 +808,10 @@ void tor_gettimeofday(struct timeval *timeval) {
     exit(1);
   }
 #elif defined(HAVE_FTIME)
-  ftime(timeval);
+  struct timeb tb;
+  ftime(&tb);
+  timeval->tv_sec = tb.time;
+  timeval->tv_usec = tb.millitm * 1000;
 #else
 #error "No way to get time."
 #endif

+ 4 - 3
src/common/util.h

@@ -30,9 +30,10 @@
 #ifdef HAVE_FTIME
 #define USING_FAKE_TIMEVAL
 #include <sys/timeb.h>
-#define timeval timeb
-#define tv_sec time
-#define tv_usec millitm
+struct timeval {
+  time_t tv_sec;
+  unsigned int tv_usec;
+};
 #endif
 #endif