> After some debugging I found out that up_alarm_tick_cancel in
> sched/sched/sched_timerexpiration.c reads an incorrect ticks value from
> clock_time2ticks macro. It received 0 seconds, 0x77358ns as a parameter,
> which - rounded up - should yield 1 tick with USEC_PER_TICK set to 1000.
> Instead, it was returning 29 ticks. I tried to make a simple standalone
> reimplementation of clock_time2ticks and NSEC2TICK from
> include/nuttx/clock.h to see what exactly is going on and it worked
> well, returned correct result of 1. I then tried to compare the
> generated assembly and found out the difference: while the
> reimplementation was calculating (nsec + 999999) / 1000000, NuttX was
> counting (nsec + 16959) / 16960. The former is 0xf423f and 0xf4240 in
> hex, the latter is 0x423f and 0x4240 which led me to the idea that the
> compiler truncates something to 16bit - that something turned to be
> NSEC_PER_TICK.

do you mean a compiler bug?

otherwise, if your implementation of clock_time2ticks and NSEC2TICK
works better,
why don't you fix the nuttx version of them?

Reply via email to