1#include "absl/time/clock.h" 2 3#include <sys/time.h> 4#include <ctime> 5#include <cstdint> 6 7#include "absl/base/internal/raw_logging.h" 8 9namespace absl { 10ABSL_NAMESPACE_BEGIN 11namespace time_internal { 12 13static int64_t GetCurrentTimeNanosFromSystem() { 14 const int64_t kNanosPerSecond = 1000 * 1000 * 1000; 15 struct timespec ts; 16 ABSL_RAW_CHECK(clock_gettime(CLOCK_REALTIME, &ts) == 0, 17 "Failed to read real-time clock."); 18 return (int64_t{ts.tv_sec} * kNanosPerSecond + 19 int64_t{ts.tv_nsec}); 20} 21 22} // namespace time_internal 23ABSL_NAMESPACE_END 24} // namespace absl 25