fixed for VC++ windows
authorGengbin Zheng <gzheng@illinois.edu>
Tue, 29 Mar 2011 19:44:14 +0000 (14:44 -0500)
committerGengbin Zheng <gzheng@illinois.edu>
Tue, 29 Mar 2011 19:44:14 +0000 (14:44 -0500)
src/ck-ldb/tm_bucket.c
src/ck-ldb/tm_mapping.c
src/ck-ldb/tm_timings.h

index 3e9f9be36f57da20bc1b92d37002c57dfe5f259f..5027615438a2357f2d312850fa02ff8465b6e623 100644 (file)
@@ -1,3 +1,9 @@
+#ifdef _WIN32
+#include <windows.h>
+#include <winbase.h>
+#define random() rand()
+#define srandom(x)  srand(x)
+#endif
 #include <stdio.h>
 #include <float.h>
 #include <math.h>
index b00beb9cf3f8b62b14707ce666d7d06f13f4a561..7bba126ef7288ca3492a2652f6ebe635675573d1 100644 (file)
@@ -6,6 +6,13 @@
 #include <ctype.h>
 #include <math.h>
 #include <assert.h> 
+#ifdef _WIN32
+#include <windows.h>
+#include <winbase.h>
+#define random() rand()
+#define srandom(x)  srand(x)
+#define strsep     strtok
+#endif
 #include "tm_mapping.h"
 #include "tm_timings.h"
 #include "tm_tree.h"
index 9952f9ab431343bc833b1b8e938b091b0e52f6b6..44d3fa9e2ab0941b5cad187e3a2673d5ea897e9a 100644 (file)
@@ -1,12 +1,17 @@
 #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;
 
 
@@ -15,6 +20,21 @@ typedef struct timeval CLOCK_T;
 ((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();