|
|
@ -41,7 +41,7 @@ |
|
|
|
#include <time.h> |
|
|
|
#include <time.h> |
|
|
|
#include <algorithm> |
|
|
|
#include <algorithm> |
|
|
|
// Get nano time includes
|
|
|
|
// Get nano time includes
|
|
|
|
#if defined(OS_LINUX) || defined(OS_FREEBSD) |
|
|
|
#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_GNU_KFREEBSD) |
|
|
|
#elif defined(__MACH__) |
|
|
|
#elif defined(__MACH__) |
|
|
|
#include <Availability.h> |
|
|
|
#include <Availability.h> |
|
|
|
#include <mach/clock.h> |
|
|
|
#include <mach/clock.h> |
|
|
@ -249,7 +249,8 @@ class PosixEnv : public CompositeEnvWrapper { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint64_t NowNanos() override { |
|
|
|
uint64_t NowNanos() override { |
|
|
|
#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_AIX) |
|
|
|
#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_GNU_KFREEBSD) || \ |
|
|
|
|
|
|
|
defined(OS_AIX) |
|
|
|
struct timespec ts; |
|
|
|
struct timespec ts; |
|
|
|
clock_gettime(CLOCK_MONOTONIC, &ts); |
|
|
|
clock_gettime(CLOCK_MONOTONIC, &ts); |
|
|
|
return static_cast<uint64_t>(ts.tv_sec) * 1000000000 + ts.tv_nsec; |
|
|
|
return static_cast<uint64_t>(ts.tv_sec) * 1000000000 + ts.tv_nsec; |
|
|
@ -269,8 +270,8 @@ class PosixEnv : public CompositeEnvWrapper { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint64_t NowCPUNanos() override { |
|
|
|
uint64_t NowCPUNanos() override { |
|
|
|
#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_AIX) || \ |
|
|
|
#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_GNU_KFREEBSD) || \ |
|
|
|
(defined(__MACH__) && defined(__MAC_10_12)) |
|
|
|
defined(OS_AIX) || (defined(__MACH__) && defined(__MAC_10_12)) |
|
|
|
struct timespec ts; |
|
|
|
struct timespec ts; |
|
|
|
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); |
|
|
|
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); |
|
|
|
return static_cast<uint64_t>(ts.tv_sec) * 1000000000 + ts.tv_nsec; |
|
|
|
return static_cast<uint64_t>(ts.tv_sec) * 1000000000 + ts.tv_nsec; |
|
|
|