1#ifndef NDNPH_PORT_UNIXTIME_SYSTIME_HPP
2#define NDNPH_PORT_UNIXTIME_SYSTIME_HPP
4#include "../../core/common.hpp"
9namespace port_unixtime_systime {
20 static uint64_t
now() {
22 ::gettimeofday(&tv,
nullptr);
23 return static_cast<uint64_t
>(tv.tv_sec) * 1000000 +
static_cast<uint64_t
>(tv.tv_usec);
28 return t >= 540109800000000;
35 static void set(uint64_t t) {
36#ifdef NDNPH_PORT_UNIXTIME_SYSTIME_CANSET
38 .tv_sec =
static_cast<decltype(tv.tv_sec)
>(t / 1000000),
39 .tv_usec =
static_cast<decltype(tv.tv_usec)
>(t % 1000000),
41 ::settimeofday(&tv,
nullptr);
35 static void set(uint64_t t) {
…}
9namespace port_unixtime_systime {
…}
50#ifdef NDNPH_PORT_UNIXTIME_SYSTIME
52using UnixTime = port_unixtime_systime::UnixTime;
Clock implemented with gettimeofday() .
Definition systime.hpp:12
static bool valid(uint64_t t)
Determine whether t is likely a valid current Unix timestamp.
Definition systime.hpp:27
static void set(uint64_t t)
Attempt to set current Unix timestamp, if allowed on current system.
Definition systime.hpp:35
static uint64_t now()
Retrieve current Unix timestamp in microseconds.
Definition systime.hpp:20