19#ifndef _ACF_UTILS_TIME_H_
20#define _ACF_UTILS_TIME_H_
32#define USEC2SEC(usec) ((usec) / 1000000.0)
33#define SEC2USEC(sec) ((sec) * 1000000ll)
34#define NSEC2SEC(usec) ((usec) / 1000000000.0)
35#define SEC2NSEC(sec) ((sec) * 1000000000ll)
41 LARGE_INTEGER val, freq;
42 QueryPerformanceFrequency(&freq);
43 QueryPerformanceCounter(&val);
44 return ((val.QuadPart * 1000000llu) / freq.QuadPart);
47 VERIFY0(clock_gettime(CLOCK_REALTIME, &ts));
48 return ((ts.tv_sec * 1000000llu) + (ts.tv_nsec / 1000llu));
57 return (microclock() * 1000llu);
60 VERIFY0(clock_gettime(CLOCK_MONOTONIC, &ts));
61 return (ts.tv_sec * 1000000000llu + ts.tv_nsec);
70time_t lacf_timegm(
const struct tm *tm);
85 uint64_t time_micro = ((uint64_t)time(NULL)) * 1000000llu;
88 return (time_micro + (uint64_t)st.wMilliseconds * 1000llu);
91 return (microclock());
107lacf_yday_to_mon_mday(
unsigned days,
int *tm_mon,
int *tm_mday)
109 static const unsigned month2days[12] = {
110 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
112 for (
int i = 11; i >= 0; i--) {
113 if (month2days[i] <= days) {
117 *tm_mday = days - month2days[i] + 1;