From a8b35e6689f210f804dccb644e507a18a897f6ff Mon Sep 17 00:00:00 2001 From: Ketasaja Date: Sun, 11 Aug 2024 20:35:46 +0000 Subject: [PATCH] Make `os.clock` use `clock_gettime` on FreeBSD --- Ast/src/TimeTrace.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ast/src/TimeTrace.cpp b/Ast/src/TimeTrace.cpp index 4782b25c..e8be59eb 100644 --- a/Ast/src/TimeTrace.cpp +++ b/Ast/src/TimeTrace.cpp @@ -40,7 +40,7 @@ static double getClockPeriod() mach_timebase_info_data_t result = {}; mach_timebase_info(&result); return double(result.numer) / double(result.denom) * 1e-9; -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) return 1e-9; #else return 1.0 / double(CLOCKS_PER_SEC); @@ -55,7 +55,7 @@ static double getClockTimestamp() return double(result.QuadPart); #elif defined(__APPLE__) return double(mach_absolute_time()); -#elif defined(__linux__) +#elif defined(__linux__) || defined(__FreeBSD__) timespec now; clock_gettime(CLOCK_MONOTONIC, &now); return now.tv_sec * 1e9 + now.tv_nsec;