summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@cs.nyu.edu>2013-01-28 15:21:52 -0500
committerMorgan Deters <mdeters@cs.nyu.edu>2013-01-28 15:23:18 -0500
commit4d19bda6b8ac42b4800a2ccd01541e10b0bbef54 (patch)
tree0a6e209087ff1dfa584f93351d8e4fdd96d6e13b /src/lib
parent32b48a0265a416b577f83500a541c9673026e95c (diff)
Fixes for Win32 (closes bugs 488 and 489)
* timer statistics now supported (closes bug 488) * use of --mmap doesn't crash anymore (closes bug 489)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/clock_gettime.c15
-rw-r--r--src/lib/clock_gettime.h22
2 files changed, 30 insertions, 7 deletions
diff --git a/src/lib/clock_gettime.c b/src/lib/clock_gettime.c
index e9d347438..054a8c112 100644
--- a/src/lib/clock_gettime.c
+++ b/src/lib/clock_gettime.c
@@ -36,7 +36,7 @@ extern "C" {
static double s_clockconv = 0.0;
-long clock_gettime(clockid_t which_clock, struct timespec *tp) {
+long clock_gettime(clockid_t which_clock, struct timespec* tp) {
if( s_clockconv == 0.0 ) {
mach_timebase_info_data_t tb;
kern_return_t err = mach_timebase_info(&tb);
@@ -66,8 +66,17 @@ long clock_gettime(clockid_t which_clock, struct timespec *tp) {
#else /* else we're __WIN32__ */
-long clock_gettime(clockid_t which_clock, struct timespec *tp) {
- // unsupported on Windows
+#include <time.h>
+#include <windows.h>
+
+long clock_gettime(clockid_t which_clock, struct timespec* tp) {
+ if(tp != NULL) {
+ FILETIME ft;
+ GetSystemTimeAsFileTime(&ft);
+ uint64_t nanos = ((((uint64_t)ft.dwHighDateTime) << 32) | ft.dwLowDateTime) * 100;
+ tp->tv_sec = nanos / 1000000000ul;
+ tp->tv_nsec = nanos % 1000000000ul;
+ }
return 0;
}
diff --git a/src/lib/clock_gettime.h b/src/lib/clock_gettime.h
index ea14f885c..6a8dd57ff 100644
--- a/src/lib/clock_gettime.h
+++ b/src/lib/clock_gettime.h
@@ -30,12 +30,27 @@
/* otherwise, we have to define it */
-#ifndef __WIN32__
+#ifdef __WIN32__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct timespec {
+ uint64_t tv_sec;
+ int32_t tv_nsec;
+};/* struct timespec */
+
+#ifdef __cplusplus
+}/* extern "C" */
+#endif /* __cplusplus */
+
+#else /* ! __WIN32__ */
/* get timespec from <time.h> */
#include <time.h>
-#endif /* ! __WIN32__ */
+#endif /* __WIN32__ */
#ifdef __cplusplus
extern "C" {
@@ -50,7 +65,7 @@ typedef enum {
CLOCK_MONOTONIC_HR
} clockid_t;
-long clock_gettime(clockid_t which_clock, struct timespec *tp);
+long clock_gettime(clockid_t which_clock, struct timespec* tp);
#ifdef __cplusplus
}/* extern "C" */
@@ -58,4 +73,3 @@ long clock_gettime(clockid_t which_clock, struct timespec *tp);
#endif /* HAVE_CLOCK_GETTIME */
#endif /*__CVC4__LIB__CLOCK_GETTIME_H */
-
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback