_ftime patch

Johannes Gajdosik johannes.gajdosik at artibrain.at
Mon Mar 8 06:56:42 CST 2004


Dear Wine developers,

I found that the _ftime-function only returns seconds, not milliseconds.
Therefore I would like to send you a patch that uses gettimeofday().
I hope that you will include in a future release.
I use wine for testing cross-compiled programs and therefore need
a working _ftime(). Thanks in advance and also thank you very much
for your great work.

Johannes Gajdosik
-------------- next part --------------
? patch_ftime.diff
Index: dlls/msvcrt/time.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/time.c,v
retrieving revision 1.11
diff -u -r1.11 time.c
--- dlls/msvcrt/time.c	4 Mar 2003 02:19:15 -0000	1.11
+++ dlls/msvcrt/time.c	8 Mar 2004 12:49:02 -0000
@@ -24,6 +24,7 @@
 #include "config.h"
 
 #include <time.h>
+#include <sys/time.h>
 #ifdef HAVE_SYS_TIMES_H
 # include <sys/times.h>
 #endif
@@ -135,10 +136,13 @@
  */
 void _ftime(struct _timeb *buf)
 {
-  buf->time = MSVCRT_time(NULL);
-  buf->millitm = 0; /* FIXME */
-  buf->timezone = 0;
-  buf->dstflag = 0;
+  struct timeval tv;
+  struct timezone tz;
+  gettimeofday(&tv,&tz);
+  buf->time = tv.tv_sec;
+  buf->millitm = tv.tv_usec / 1000;
+  buf->timezone = tz.tz_minuteswest;
+  buf->dstflag = tz.tz_dsttime;
 }
 
 /*********************************************************************


More information about the wine-patches mailing list