Simplify how CLOCK_BOOTTIME is checked on Android

This commit is contained in:
Chris Thrasher 2023-10-17 14:16:39 -05:00
parent c11391ae31
commit 80d277cca3
No known key found for this signature in database
GPG Key ID: 56FB686C9DFC8E2C

View File

@ -29,17 +29,17 @@
#include <ctime>
#ifndef CLOCK_BOOTTIME
#error "CLOCK_BOOTTIME is essential for SuspendAwareClock to work"
#endif
namespace sf
{
SuspendAwareClock::time_point SuspendAwareClock::now() noexcept
{
::timespec ts{};
#ifdef CLOCK_BOOTTIME
clock_gettime(CLOCK_BOOTTIME, &ts);
#else
#error "CLOCK_BOOTTIME is essential for SuspendAwareClock to work"
#endif // CLOCK_BOOTTIME
return time_point(std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec));
}