Skip to content

Commit

Permalink
Clocks: use CLOCK_[BOOTTIME,MONOTONIC_RAW] for Clocks::monotonic
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 729311e1a7a36a9245ecdb5921b81c4834ec1dc6
  • Loading branch information
arseny30 committed Aug 14, 2020
1 parent 129e673 commit 9c40e37
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions tdutils/td/utils/port/Clocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,14 @@ double Clocks::monotonic() {
}
}
#endif
#ifdef CLOCK_UPTIME_RAW
#ifdef CLOCK_MONOTONIC_RAW
{
static bool skip = []() {
struct timespec spec;
return clock_gettime(CLOCK_UPTIME_RAW, &spec) != 0;
return clock_gettime(CLOCK_MONOTONIC_RAW, &spec) != 0;
}();
struct timespec spec;
if (!skip && clock_gettime(CLOCK_UPTIME_RAW, &spec) == 0) {
return static_cast<double>(spec.tv_nsec) * 1e-9 + static_cast<double>(spec.tv_sec);
}
}
#endif
#ifdef CLOCK_UPTIME
{
static bool skip = []() {
struct timespec spec;
return clock_gettime(CLOCK_UPTIME, &spec) != 0;
}();
struct timespec spec;
if (!skip && clock_gettime(CLOCK_UPTIME, &spec) == 0) {
if (!skip && clock_gettime(CLOCK_MONOTONIC_RAW, &spec) == 0) {
return static_cast<double>(spec.tv_nsec) * 1e-9 + static_cast<double>(spec.tv_sec);
}
}
Expand Down

0 comments on commit 9c40e37

Please sign in to comment.