Skip to content

Commit

Permalink
Merge pull request #5 from k15tfu/fix-build-linux-arm
Browse files Browse the repository at this point in the history
Use CLOCK_MONOTONIC to get time in utf_converters/performance test case on Linux ARM32
  • Loading branch information
ww898 committed Aug 30, 2022
2 parents c4b01a1 + 16aa24b commit b305ab7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/utf_converters_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@

#if defined(__linux__) || defined(__APPLE__)
#include <chrono>
#include <time.h>
#include <unistd.h>

#if defined(__MACH__)
#include <mach/clock.h>
Expand Down Expand Up @@ -573,6 +575,11 @@ uint64_t get_time() throw()
"mrs %0, cntvct_el0\n\t"
: "=r" (cntvct_el0) : : );
return cntvct_el0;
#elif defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0
struct timespec tp;
if (clock_gettime(CLOCK_MONOTONIC, &tp) != 0)
std::abort();
return static_cast<uint64_t>(tp.tv_sec) * 1000000000ull + tp.tv_nsec;
#else
#error Unsupported architecture
#endif
Expand Down

0 comments on commit b305ab7

Please sign in to comment.