patched version of timer_compare