Timer processing fix.
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
#define MAX_USEC64 1000000ULL
|
||||
#define MAX_USEC 1000000.0
|
||||
|
||||
#define TIMER_PROCESS 8
|
||||
#define TIMER_ENABLE 4
|
||||
#define TIMER_SPLIT 2
|
||||
#define TIMER_ENABLED 1
|
||||
|
||||
@@ -211,12 +213,16 @@ timer_process_inline(void)
|
||||
timer_head->prev = NULL;
|
||||
|
||||
timer->next = timer->prev = NULL;
|
||||
timer->flags |= TIMER_PROCESS;
|
||||
|
||||
if (timer->flags & TIMER_SPLIT)
|
||||
timer_advance_ex(timer, 0); /* We're splitting a > 1 s period into multiple <= 1 s periods. */
|
||||
else if (timer->callback != NULL) /* Make sure it's no NULL, so that we can have a NULL callback when no operation is needed. */
|
||||
timer->callback(timer->priv);
|
||||
|
||||
if (timer->flags |= TIMER_ENABLE)
|
||||
timer->flags = (timer_flags & ~TIMER_ENABLE) | TIMER_ENABLED;
|
||||
else
|
||||
timer->flags &= ~TIMER_ENABLED;
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,9 @@ timer_enable(pc_timer_t *timer)
|
||||
if (timer->next || timer->prev)
|
||||
fatal("timer_enable - timer->next\n");
|
||||
|
||||
if (timer->flags & TIMER_PROCESS)
|
||||
timer->flags = (timer->flags & ~TIMER_PROCESS) | TIMER_ENABLE;
|
||||
else
|
||||
timer->flags |= TIMER_ENABLED;
|
||||
|
||||
/*List currently empty - add to head*/
|
||||
@@ -118,12 +121,16 @@ timer_process(void)
|
||||
timer_head->prev = NULL;
|
||||
|
||||
timer->next = timer->prev = NULL;
|
||||
timer->flags |= TIMER_PROCESS;
|
||||
|
||||
if (timer->flags & TIMER_SPLIT)
|
||||
timer_advance_ex(timer, 0); /* We're splitting a > 1 s period into multiple <= 1 s periods. */
|
||||
else if (timer->callback != NULL) /* Make sure it's no NULL, so that we can have a NULL callback when no operation is needed. */
|
||||
timer->callback(timer->priv);
|
||||
|
||||
if (timer->flags |= TIMER_ENABLE)
|
||||
timer->flags = (timer_flags & ~TIMER_ENABLE) | TIMER_ENABLED;
|
||||
else
|
||||
timer->flags &= ~TIMER_ENABLED;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user