/* libhw/host_bootclock.c - implementation for POSIX hosts * * Copyright (C) 2024 Luke T. Shumaker * SPDX-License-Identifier: AGPL-3.0-or-later */ #include #include /* for clock_gettime(), CLOCK_MONOTONIC, struct timespec */ #include uint64_t bootclock_get_ns(void) { struct timespec ts; int r; r = clock_gettime(CLOCK_MONOTONIC, &ts); assert(r == 0); return (((uint64_t)ts.tv_sec) * NS_PER_S) + (uint64_t)ts.tv_nsec; }