mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 13:00:38 +00:00
Make os.clock
use clock_gettime
on FreeBSD (#1364)
This commit is contained in:
parent
9dc299ecaf
commit
1788e237fc
2 changed files with 4 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue