Merge branch 'charm' of charmgit:charm into charm
[charm.git] / src / ck-ldb / tm_timings.h
index 9952f9ab431343bc833b1b8e938b091b0e52f6b6..ad6e115668586a27866c50e222257441149b1c5e 100644 (file)
@@ -1,20 +1,38 @@
 #ifndef TIMINGS_H
 #define TIMINGS_H
 
+#ifndef _WIN32
 #include <sys/time.h>
+#else
+#include <sys/timeb.h>
+#endif
 #include <stdlib.h>
 #include <unistd.h>
 
 #define MAX_CLOCK 100
 
+#ifndef _WIN32
 typedef struct timeval CLOCK_T;
 
-
 #define CLOCK(c) gettimeofday(&c,(struct timezone *)NULL)
 #define CLOCK_DIFF(c1,c2)  \
 ((double)(c1.tv_sec-c2.tv_sec)+(double)(c1.tv_usec-c2.tv_usec)/1e+6)
 #define CLOCK_DISPLAY(c) fprintf(stderr,"%d.%d",(int)c.tv_sec,(int)c.tv_usec)
 
+#else    /* for windows */
+
+#ifdef __CYGWIN__
+typedef struct timeb CLOCK_T;
+#else
+typedef struct _timeb CLOCK_T;
+#endif
+
+#define CLOCK(c) _ftime(&c)
+#define CLOCK_DIFF(c1,c2)  \
+((double)(c1.time-c2.time)+(double)(c1.millitm-c2.millitm)/1e+3)
+#define CLOCK_DISPLAY(c) fprintf(stderr,"%d.%d",(int)c.time,(int)c.millitm*1e+3)
+#endif
+
 double time_diff();
 void get_time();