clocksync: Simplify 32bit clock upconversion code
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
62bf52bfcf
commit
c5bd813d8b
|
@ -66,10 +66,8 @@ class ClockSync:
|
|||
self.queries_pending = 0
|
||||
# Extend clock to 64bit
|
||||
last_clock = self.last_clock
|
||||
clock = (last_clock & ~0xffffffff) | params['clock']
|
||||
if clock < last_clock:
|
||||
clock += 0x100000000
|
||||
self.last_clock = clock
|
||||
clock_delta = (params['clock'] - last_clock) & 0xffffffff
|
||||
self.last_clock = clock = last_clock + clock_delta
|
||||
# Check if this is the best round-trip-time seen so far
|
||||
sent_time = params['#sent_time']
|
||||
if not sent_time:
|
||||
|
@ -138,10 +136,9 @@ class ClockSync:
|
|||
# misc commands
|
||||
def clock32_to_clock64(self, clock32):
|
||||
last_clock = self.last_clock
|
||||
clock_diff = (last_clock - clock32) & 0xffffffff
|
||||
if clock_diff & 0x80000000:
|
||||
return last_clock + 0x100000000 - clock_diff
|
||||
return last_clock - clock_diff
|
||||
clock_diff = (clock32 - last_clock) & 0xffffffff
|
||||
clock_diff -= (clock_diff & 0x80000000) << 1
|
||||
return last_clock + clock_diff
|
||||
def is_active(self):
|
||||
return self.queries_pending <= 4
|
||||
def dump_debug(self):
|
||||
|
|
Loading…
Reference in New Issue