7 struct timeval epoch_time;
8 struct timespec monotonic_time;
10 gettimeofday(&epoch_time, NULL);
11 clock_gettime(CLOCK_MONOTONIC, &monotonic_time);
13 const int64_t uptime_ms =
14 monotonic_time.tv_sec * 1000 +
static_cast<int64_t
>(
15 std::round(monotonic_time.tv_nsec / 1000000.0));
16 const int64_t epoch_ms =
17 epoch_time.tv_sec * 1000 +
static_cast<int64_t
>(
18 std::round(epoch_time.tv_usec / 1000.0));
20 return static_cast<time_t
>((epoch_ms - uptime_ms) / 1000);
28 r = ioctl(fd, request, arg);
30 }
while (-1 == r && EINTR == errno);
45 }
catch (std::out_of_range
const &) {
47 unsigned char clipped_val = val < 0 ? 0 : static_cast<unsigned char>(val);
48 return val > 255 ? 255 : clipped_val;
54 struct timeval epoch_time;
55 struct timespec monotonic_time;
56 gettimeofday(&epoch_time, NULL);
57 clock_gettime(CLOCK_MONOTONIC, &monotonic_time);
58 const int64_t uptime_ms =
59 monotonic_time.tv_sec * 1000 +
static_cast<int64_t
>(
60 std::round(monotonic_time.tv_nsec / 1000000.0));
61 const int64_t epoch_ms =
62 epoch_time.tv_sec * 1000 +
static_cast<int64_t
>(
63 std::round(epoch_time.tv_usec / 1000.0));
64 return static_cast<time_t
>((epoch_ms - uptime_ms) / 1000);
time_t get_epoch_time_shift()
Get epoch time shift.
unsigned char CLIPVALUE(const int &val)
static const std::vector< unsigned char > uchar_clipping_table
static const int clipping_table_offset
time_t get_epoch_time_shift()
Get epoch time shift.
int xioctl(int fd, int request, void *arg)