5 #include "include/log.h"
6 #include "include/list.h"
7 #include "include/timer.h"
8 #include "include/ucix.h"
10 /* when using this file, alarm() is used */
12 struct list_head timers;
15 struct list_head list;
21 void timer_add(timercb_t timercb, int timeout)
24 timer = malloc(sizeof(struct timer));
27 log_printf("unable to get timer buffer\n");
31 timer->timeout = timeout;
32 timer->timercb = timercb;
33 INIT_LIST_HEAD(&timer->list);
34 list_add(&timer->list, &timers);
37 void timer_proc(int signo)
40 list_for_each(p, &timers)
42 struct timer *q = container_of(p, struct timer, list);
44 if(!(q->count%q->timeout))
55 INIT_LIST_HEAD(&timers);
56 s.sa_handler = timer_proc;
58 sigaction(SIGALRM, &s, NULL);