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 {
10namespace time_internal {
11
12static int64_t GetCurrentTimeNanosFromSystem() {
13 const int64_t kNanosPerSecond = 1000 * 1000 * 1000;
14 struct timespec ts;
15 ABSL_RAW_CHECK(clock_gettime(CLOCK_REALTIME, &ts) == 0,
16 "Failed to read real-time clock.");
17 return (int64_t{ts.tv_sec} * kNanosPerSecond +
18 int64_t{ts.tv_nsec});
19}
20
21} // namespace time_internal
22} // namespace absl
23