summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
fc0bb9f)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#define max_t(type, a, b) ((type) ((a) > (b) ? (a) : (b)))
#endif
#define max_t(type, a, b) ((type) ((a) > (b) ? (a) : (b)))
#endif
+#define NSEC_PER_SEC 1000000000ULL
#define NR_CLOCK_OFFSET_SAMPLES 10
struct offset_sample {
#define NR_CLOCK_OFFSET_SAMPLES 10
struct offset_sample {
return 0;
}
offset = (monotonic[0] + monotonic[1]) >> 1;
return 0;
}
offset = (monotonic[0] + monotonic[1]) >> 1;
- realtime = (uint64_t) rts.tv_sec * 1000000000ULL;
- realtime += rts.tv_nsec;
- if (tcf != 1000000000ULL) {
- realtime /= 1000000000ULL / tcf;
+ realtime = (uint64_t) rts.tv_sec * tcf;
+ if (tcf == NSEC_PER_SEC) {
+ realtime += rts.tv_nsec;
+ } else {
+ realtime += (uint64_t) rts.tv_nsec * tcf / NSEC_PER_SEC;
}
offset = realtime - offset;
sample->offset = offset;
}
offset = realtime - offset;
sample->offset = offset;