1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
5 * Copyright (C) 2017 Red Hat Inc.
23 // we're using double to represent time, but we could change it by
24 // changing the following declarations (and by making sure a min
27 static const Time TimeZero = 0.0;
28 static const Time TimeMax = std::numeric_limits<Time>::max();
29 static const double NaN = nan("");
32 inline Time get_time() {
33 #if defined(__linux__)
35 auto result = clock_gettime(CLOCK_REALTIME, &now);
36 (void) result; // reference result in case assert is compiled out
38 return now.tv_sec + (now.tv_nsec / 1.0e9);
41 auto result = gettimeofday(&now, NULL);
42 (void) result; // reference result in case assert is compiled out
44 return now.tv_sec + (now.tv_usec / 1.0e6);
48 std::string format_time(const Time& time, uint modulo = 1000);
52 } // namespace dmclock
53 } // namespace crimson