[or-cvs] When faking gettimeofday with ftime, do it right.

Nick Mathewson nickm at seul.org
Tue Jul 20 21:23:52 UTC 2004


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv9140/src/common

Modified Files:
	util.c util.h 
Log Message:
When faking gettimeofday with ftime, do it right.

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -d -r1.113 -r1.114
--- util.c	16 Jul 2004 22:23:17 -0000	1.113
+++ util.c	20 Jul 2004 21:23:50 -0000	1.114
@@ -808,7 +808,10 @@
     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

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- util.h	15 Jul 2004 02:00:43 -0000	1.74
+++ util.h	20 Jul 2004 21:23:50 -0000	1.75
@@ -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
 



More information about the tor-commits mailing list