diff options
author | Kenneth Heafield <github@kheafield.com> | 2013-06-18 11:34:20 -0700 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2013-06-18 11:34:20 -0700 |
commit | 8dc383a74c12d44ab3f51947575ed5828653f4f1 (patch) | |
tree | 30371d17e6c2daf3837068b2617e357ad6b37d89 /klm/util/usage.cc | |
parent | 354787aa16539702802b9ea075c4bd8a72071035 (diff) |
lazy dd880b4 including kenlm 6eef0f1
Diffstat (limited to 'klm/util/usage.cc')
-rw-r--r-- | klm/util/usage.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/klm/util/usage.cc b/klm/util/usage.cc index 5fa3cc9a..8db375e1 100644 --- a/klm/util/usage.cc +++ b/klm/util/usage.cc @@ -21,6 +21,21 @@ namespace util { #if !defined(_WIN32) && !defined(_WIN64) namespace { + +// On Mac OS X, clock_gettime is not implemented. +// CLOCK_MONOTONIC is not defined either. +#ifdef __MACH__ +#define CLOCK_MONOTONIC 0 + +int clock_gettime(int clk_id, struct timespec *tp) { + struct timeval tv; + gettimeofday(&tv, NULL); + tp->tv_sec = tv.tv_sec; + tp->tv_nsec = tv.tv_usec * 1000; + return 0; +} +#endif // __MACH__ + float FloatSec(const struct timeval &tv) { return static_cast<float>(tv.tv_sec) + (static_cast<float>(tv.tv_usec) / 1000000.0); } |