Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make os.clock use clock_gettime on FreeBSD #1364

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Ast/src/TimeTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions VM/src/lperf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static double clock_period()
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);
Expand All @@ -45,7 +45,7 @@ static double clock_timestamp()
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;
Expand Down
Loading