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);
#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;
}
/* 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" {
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" */
#endif /* HAVE_CLOCK_GETTIME */
#endif /*__CVC4__LIB__CLOCK_GETTIME_H */
-
AntlrInputStream::newFileInputStream(const std::string& name,
bool useMmap)
throw (InputStreamException) {
+#ifdef _WIN32
+ if(useMmap) {
+ useMmap = false;
+ }
+#endif
pANTLR3_INPUT_STREAM input = NULL;
- if( useMmap ) {
+ if(useMmap) {
input = MemoryMappedInputBufferNew(name);
} else {
// libantlr3c v3.2 isn't source-compatible with v3.4
input = antlr3FileStreamNew((pANTLR3_UINT8) name.c_str(), ANTLR3_ENC_8BIT);
#endif /* CVC4_ANTLR3_OLD_INPUT_STREAM */
}
- if( input == NULL ) {
+ if(input == NULL) {
throw InputStreamException("Couldn't open file: " + name);
}
return new AntlrInputStream( name, input );
#include "util/statistics_registry.h"
#include "expr/expr_manager.h"
-#ifndef __WIN32__
-# include "lib/clock_gettime.h"
-#endif /* ! __WIN32__ */
+#include "lib/clock_gettime.h"
#include "smt/smt_engine.h"
#ifndef __BUILDING_STATISTICS_FOR_EXPORT
}
void TimerStat::start() {
-#ifndef __WIN32__
if(__CVC4_USE_STATISTICS) {
CheckArgument(!d_running, *this, "timer already running");
clock_gettime(CLOCK_MONOTONIC, &d_start);
d_running = true;
}
-#endif /* ! __WIN32__ */
}/* TimerStat::start() */
void TimerStat::stop() {
-#ifndef __WIN32__
if(__CVC4_USE_STATISTICS) {
CheckArgument(d_running, *this, "timer not running");
::timespec end;
d_data += end - d_start;
d_running = false;
}
-#endif /* ! __WIN32__ */
}/* TimerStat::stop() */
RegisterStatistic::RegisterStatistic(ExprManager& em, Stat* stat) :
#include "util/statistics.h"
#include "util/exception.h"
+#include "lib/clock_gettime.h"
#include <sstream>
#include <iomanip>
};/* class StatisticsRegistry */
-#ifndef __WIN32__
-
/****************************************************************************/
/* Some utility functions for timespec */
/****************************************************************************/
};/* class TimerStat */
-#else /* __WIN32__ */
-
-class CodeTimer;
-
-class TimerStat : public IntStat {
-public:
-
- typedef CVC4::CodeTimer CodeTimer;
-
- TimerStat(const std::string& name) :
- IntStat(name, 0) {
- }
-
- void start();
- void stop();
-
-};/* class TimerStat */
-
-#endif /* __WIN32__ */
-
/**
* Utility class to make it easier to call stop() at the end of a
* code block. When constructed, it starts the timer. When