chromium/base/time/time_now_posix.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <stdint.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>

#include <optional>

#include "base/check.h"
#include "base/notreached.h"
#include "base/numerics/safe_math.h"
#include "base/time/time.h"
#include "base/time/time_override.h"
#include "build/build_config.h"

#if BUILDFLAG(IS_ANDROID) && !defined(__LP64__)
#include <time64.h>
#endif

// Ensure the Fuchsia and Mac builds do not include this module. Instead,
// non-POSIX implementation is used for sampling the system clocks.
#if BUILDFLAG(IS_FUCHSIA) || BUILDFLAG(IS_APPLE)
#error "This implementation is for POSIX platforms other than Fuchsia or Mac."
#endif

namespace {

int64_t ConvertTimespecToMicros(const struct timespec& ts) {}

// Helper function to get results from clock_gettime() and convert to a
// microsecond timebase. Minimum requirement is MONOTONIC_CLOCK to be supported
// on the system. FreeBSD 6 has CLOCK_MONOTONIC but defines
// _POSIX_MONOTONIC_CLOCK to -1.
#if (BUILDFLAG(IS_POSIX) && defined(_POSIX_MONOTONIC_CLOCK) && \
     _POSIX_MONOTONIC_CLOCK >= 0) ||                           \
    BUILDFLAG(IS_BSD) || BUILDFLAG(IS_ANDROID)
int64_t ClockNow(clockid_t clk_id) {}

std::optional<int64_t> MaybeClockNow(clockid_t clk_id) {}

#else  // _POSIX_MONOTONIC_CLOCK
#error No usable tick clock function on this platform.
#endif  // _POSIX_MONOTONIC_CLOCK

}  // namespace

namespace base {

// Time -----------------------------------------------------------------------

namespace subtle {
Time TimeNowIgnoringOverride() {}

Time TimeNowFromSystemTimeIgnoringOverride() {}
}  // namespace subtle

// TimeTicks ------------------------------------------------------------------

namespace subtle {
TimeTicks TimeTicksNowIgnoringOverride() {}

std::optional<TimeTicks> MaybeTimeTicksNowIgnoringOverride() {}
}  // namespace subtle

// static
TimeTicks::Clock TimeTicks::GetClock() {}

// static
bool TimeTicks::IsHighResolution() {}

// static
bool TimeTicks::IsConsistentAcrossProcesses() {}

// ThreadTicks ----------------------------------------------------------------

namespace subtle {
ThreadTicks ThreadTicksNowIgnoringOverride() {}
}  // namespace subtle

}  // namespace base