Use 64 bit clock to prevent overflows
Large offsets between nodes may overflow the previous 48 bit clock leading to an incorrect reconstructed clock value after the correction with the 64 bit offset.
This commit is contained in:
parent
60d6bbb337
commit
755f2e84f3
8
ovni.c
8
ovni.c
@ -389,17 +389,13 @@ flush_evbuf()
|
|||||||
static void
|
static void
|
||||||
ovni_ev_set_clock(struct ovni_ev *ev)
|
ovni_ev_set_clock(struct ovni_ev *ev)
|
||||||
{
|
{
|
||||||
ev->header.clock_lo = (uint32_t) (rthread.clockvalue & 0xffffffff);
|
ev->header.clock = rthread.clockvalue;
|
||||||
ev->header.clock_hi = (uint16_t) ((rthread.clockvalue >> 32) & 0xffff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
ovni_ev_get_clock(struct ovni_ev *ev)
|
ovni_ev_get_clock(struct ovni_ev *ev)
|
||||||
{
|
{
|
||||||
uint64_t clock;
|
return ev->header.clock;
|
||||||
|
|
||||||
clock = ((uint64_t) ev->header.clock_hi) << 32 | ((uint64_t) ev->header.clock_lo);
|
|
||||||
return clock;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
3
ovni.h
3
ovni.h
@ -52,8 +52,7 @@ struct __attribute__((__packed__)) ovni_ev_header {
|
|||||||
uint8_t model;
|
uint8_t model;
|
||||||
uint8_t class;
|
uint8_t class;
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
uint32_t clock_lo;
|
uint64_t clock;
|
||||||
uint16_t clock_hi;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct __attribute__((__packed__)) ovni_ev {
|
struct __attribute__((__packed__)) ovni_ev {
|
||||||
|
Loading…
Reference in New Issue
Block a user