Commit e3e07779 authored by Landry Breuil's avatar Landry Breuil
Browse files

Bug 1824084: use linux codepaths for BSDs in uptime-related functions r=padenot

should unbreak telemetry for BSDs and Solaris.

In NowExcludingSuspendMs() use CLOCK_UPTIME instead of CLOCK_MONOTONIC on
OpenBSD as this one excludes time spent suspended.

Differential Revision: https://phabricator.services.mozilla.com/D173625
parent 452c46dc
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ Maybe<uint64_t> NowIncludingSuspendMs() {
  return Some(interrupt_time / kHNSperMS);
}

#elif defined(XP_LINUX)  // including Android
#elif defined(XP_UNIX)  // including BSDs and Android
#  include <time.h>

// Number of nanoseconds in a millisecond.
@@ -88,7 +88,11 @@ uint64_t TimespecToMilliseconds(struct timespec aTs) {
Maybe<uint64_t> NowExcludingSuspendMs() {
  struct timespec ts = {0};

#  ifdef XP_OPENBSD
  if (clock_gettime(CLOCK_UPTIME, &ts)) {
#  else
  if (clock_gettime(CLOCK_MONOTONIC, &ts)) {
#  endif
    return Nothing();
  }
  return Some(TimespecToMilliseconds(ts));