28#ifdef HAVE_SYS_TYPES_H
32#ifndef HAVE_GETTIMEOFDAY
47#define EPOCH_BIAS UINT64_C(116444736000000000)
48#define UNITS_PER_SEC UINT64_C(10000000)
49#define USEC_PER_SEC UINT64_C(1000000)
50#define UNITS_PER_USEC UINT64_C(10)
56 GetSystemTimeAsFileTime(&ft.ft_ft);
57 if (ft.ft_64 < EPOCH_BIAS) {
59 raw_assert_unreached_msg(
"System time is before 1970; failing.");
62 ft.ft_64 -= EPOCH_BIAS;
63 timeval->tv_sec = (unsigned) (ft.ft_64 / UNITS_PER_SEC);
65#elif defined(HAVE_GETTIMEOFDAY)
66 if (gettimeofday(
timeval, NULL)) {
70 raw_assert_unreached_msg(
"gettimeofday failed");
73#elif defined(HAVE_FTIME)
77 timeval->tv_usec = tb.millitm * 1000;
79#error "No way to get time."
#define MOCK_IMPL(rv, funcname, arglist)
void tor_gettimeofday(struct timeval *timeval)
Header for tor_gettimeofday.c.
Integer definitions used throughout Tor.