Abseil Common Libraries (C++) (grcp 依赖) https://abseil.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

24 lines
589 B

#include "absl/time/clock.h"
#include <sys/time.h>
#include <ctime>
#include <cstdint>
#include "absl/base/internal/raw_logging.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
namespace time_internal {
static int64_t GetCurrentTimeNanosFromSystem() {
const int64_t kNanosPerSecond = 1000 * 1000 * 1000;
struct timespec ts;
ABSL_RAW_CHECK(clock_gettime(CLOCK_REALTIME, &ts) == 0,
"Failed to read real-time clock.");
return (int64_t{ts.tv_sec} * kNanosPerSecond +
int64_t{ts.tv_nsec});
}
} // namespace time_internal
ABSL_NAMESPACE_END
} // namespace absl