[Olsr-dev] Broken TIME_DUE macro

Henning Rogge (spam-protected)
Tue Nov 17 21:11:34 CET 2009


Am Dienstag 17 November 2009 12:21:58 schrieb Jernej Kos:
> Hi,
> 
> while writing a plugin for olsrd (version 0.5.6-r5) I noticed that the
> TIME_DUE macro defined in src/defs.h doesn't actually work properly. The
> macro is as follows:
> 
> #define TIME_DUE(s1)   ((int)((s1) * olsr_cnf->system_tick_divider) -
> now_times)
> 
> But this is incorrect as s1 is a timestamp and is already in system
> ticks. So the order of operations is wrong, one would need to first
> subtract now_times and then multiply by system_tick_divider to get the
> actual miliseconds like this:
> 
> #define TIME_DUE(s1) ((int)((s1 - now_times) *
> olsr_cnf->system_tick_divider))
The old code is correct I think.

olsr_cnf->system_tick_divider is the number of milliseconds per clock tick... 
not the clock_ticks per millisecond. See src/main.c line 272.

The current stable (0.5.6-R7) has backported timer code from the development 
branch that don't use clockticks at all. It use gettimeofday().

But thank you for telling us your oppinion. Better to get a bug report where 
we were lucky than no bug report over a problem. :)

Henning Rogge
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.olsr.org/pipermail/olsr-dev/attachments/20091117/9e530585/attachment.sig>


More information about the Olsr-dev mailing list