Commit aff58d83 authored by Adam Wujek's avatar Adam Wujek 💬

[BUG: 1627] proto-ext-whiterabbit: fix pps for links longer than ~13km

For links longer than ~13km, a value (uint32_t) returned from a function
__div64_32 shifted by 16 bits overflowed, introducing PPS offset.

Bug introduced in the commit:
35eef679 time: introduce a new unified data structure
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 5856bd77
......@@ -80,7 +80,7 @@ static void picos_to_ts(int64_t picos, struct pp_time *ts)
phase = __div64_32(&nsec, 1000);
sec = nsec;
ts->scaled_nsecs = __div64_32(&sec, PP_NSEC_PER_SEC) << 16;
ts->scaled_nsecs = ((int64_t)__div64_32(&sec, PP_NSEC_PER_SEC)) << 16;
ts->scaled_nsecs += (phase << 16) / 1000;
ts->scaled_nsecs *= sign;
ts->secs = sec * sign;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment