20 #ifdef HAVE_SYS_TIME_H
30 const int64_t s = (int64_t)start->tv_sec;
31 const int64_t e = (int64_t)end->tv_sec;
36 if (s > 0 && e < INT64_MIN + s) {
40 }
else if (s < 0 && e > INT64_MAX + s) {
57 log_warn(
LD_GENERAL,
"comparing times on microsecond detail with bad "
58 "start tv_usec: %"PRId64
" microseconds",
59 (int64_t)start->tv_usec);
64 log_warn(
LD_GENERAL,
"comparing times on microsecond detail with bad "
65 "end tv_usec: %"PRId64
" microseconds",
66 (int64_t)end->tv_usec);
76 if (secdiff > (int64_t)(LONG_MAX/1000000 - 1) ||
77 secdiff < (int64_t)(LONG_MIN/1000000 + 1)) {
78 log_warn(
LD_GENERAL,
"comparing times on microsecond detail too far "
79 "apart: %"PRId64
" seconds", (secdiff));
85 udiff = secdiff*1000000 + ((int64_t)end->tv_usec - (int64_t)start->tv_usec);
89 if (udiff > (int64_t)LONG_MAX || udiff < (int64_t)LONG_MIN) {
106 log_warn(
LD_GENERAL,
"comparing times on millisecond detail with bad "
107 "start tv_usec: %"PRId64
" microseconds",
108 (int64_t)start->tv_usec);
113 log_warn(
LD_GENERAL,
"comparing times on millisecond detail with bad "
114 "end tv_usec: %"PRId64
" microseconds",
115 (int64_t)end->tv_usec);
128 if (secdiff > (int64_t)(LONG_MAX/1000 - 2) ||
129 secdiff < (int64_t)(LONG_MIN/1000 + 1)) {
130 log_warn(
LD_GENERAL,
"comparing times on millisecond detail too far "
131 "apart: %"PRId64
" seconds", (int64_t)secdiff);
136 mdiff = secdiff*1000 +
143 ((int64_t)end->tv_usec - (int64_t)start->tv_usec + 500 + 1000000) / 1000
148 if (mdiff > (int64_t)LONG_MAX || mdiff < (int64_t)LONG_MIN) {
162 int64_t conv = ((int64_t)tv->tv_sec)*1000L;
164 conv += ((int64_t)tv->tv_usec+500)/1000L;
Utility macros to handle different features and behavior in different compilers.
Definitions for timing-related constants.
static int64_t tv_secdiff_impl(const struct timeval *start, const struct timeval *end)
time_t time_diff(const time_t t1, const time_t t2)
int64_t tv_to_msec(const struct timeval *tv)
long tv_udiff(const struct timeval *start, const struct timeval *end)
long tv_mdiff(const struct timeval *start, const struct timeval *end)