Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/util/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@
#define NS_PER_SECOND (1000000000)
#define NS_PER_MS (1000000)

#if defined(TIME_UTC)
#define _UNIXTIME_GET(tp) timespec_get(tp, TIME_UTC)
#elif defined(CLOCK_REALTIME)
#define _UNIXTIME_GET(tp) clock_gettime(CLOCK_REALTIME, tp)
#else
#error cannot find function to get unix time
#endif

#define NOW() ({\
struct timespec ts;\
timespec_get(&ts, TIME_UTC);\
_UNIXTIME_GET(&ts);\
((ts.tv_sec * NS_PER_SECOND) + ts.tv_nsec);})

#endif