common code: Add function request information, if timer is running

This commit is contained in:
Andreas Eversberg 2016-04-16 16:43:42 +02:00
parent 21865b6f0f
commit 05402283df
2 changed files with 11 additions and 0 deletions

View File

@ -89,6 +89,16 @@ void timer_stop(struct timer *timer)
timer->timeout = 0;
}
int timer_running(struct timer *timer)
{
if (!timer->linked) {
fprintf(stderr, "Timer is not initialized, aborting!\n");
abort();
}
return (timer->timeout != 0);
}
void process_timer(void)
{
struct timer *timer = timer_head;

View File

@ -13,5 +13,6 @@ void timer_init(struct timer *timer, void (*fn)(struct timer *timer), void *priv
void timer_exit(struct timer *timer);
void timer_start(struct timer *timer, double duration);
void timer_stop(struct timer *timer);
int timer_running(struct timer *timer);
void process_timer(void);