From 4e3a599f688413984fa79c9e52ecdc2a73236390 Mon Sep 17 00:00:00 2001 From: Alexey Zelkin Date: Tue, 9 Aug 2016 15:48:48 +0000 Subject: [PATCH] Add hack to fix MacOS X build --- src/utils.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/utils.cc b/src/utils.cc index 1c1e19d1..029c6fdc 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -321,13 +321,19 @@ void createDir(std::string dir, int mode) { double cpu_seconds(void) { - struct timespec t; - if (!clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t)) - return static_cast(t.tv_sec) - + static_cast(t.tv_nsec / 1000000000.0); - else - return static_cast(clock()) / - static_cast(CLOCKS_PER_SEC); + /* + * FIXME: Temporary hack to fix build on MacOS X. Very issuficient way, but + * works. Worth reimplementing using mach_absolute_time(). + */ +#ifndef MACOSX + struct timespec t; + if (!clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &t)) + return static_cast(t.tv_sec) + + static_cast(t.tv_nsec / 1000000000.0); + else + return static_cast(clock()) / + static_cast(CLOCKS_PER_SEC); +#endif return 0; }