X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=driver%2Ffirm_timing.c;h=7d6f9b7402ea1d260affdc77148faf8932184848;hb=3def71f59901789159be20bfdc806fb0fb1b6375;hp=84089a4b05ce3e1db8dc243526e475fdbc954421;hpb=6d7d61de445629e1590d3a2ba2990ef7a651368a;p=cparser diff --git a/driver/firm_timing.c b/driver/firm_timing.c index 84089a4..7d6f9b7 100644 --- a/driver/firm_timing.c +++ b/driver/firm_timing.c @@ -5,63 +5,84 @@ * * $Id$ */ -#include #include "firm_timing.h" -static const char *tv_names[] = { -#define DEFTIMEVAR(x, y, z) y, -#include "firm_timing.def" - NULL -#undef DEFTIMEVAR -}; - -static const char *tv_desc[] = { -#define DEFTIMEVAR(x, y, z) z, -#include "firm_timing.def" - NULL -#undef DEFTIMEVAR -}; - -static ir_timer_t *timers[TV_LAST]; +#include + static int timers_inited; -void timer_init(void) { - int i; +typedef struct timer_info_t { + struct timer_info_t *next; + char *description; + ir_timer_t *timer; +} timer_info_t; + +static timer_info_t *infos; +static timer_info_t *last_info; + +void timer_register(ir_timer_t *timer, const char *description) +{ + timer_info_t *info = XMALLOCZ(timer_info_t); - for (i = 0; i < TV_LAST; ++i) { - timers[i] = ir_timer_register(tv_names[i], tv_desc[i]); + info->description = xstrdup(description); + info->timer = timer; + + if (last_info != NULL) { + last_info->next = info; + } else { + infos = info; } + last_info = info; +} +void timer_init(void) +{ timers_inited = 1; } -void timer_term(FILE *f) { - int i; +void timer_term(FILE *f) +{ + timer_info_t *info; + timer_info_t *next; + + for (info = infos; info != NULL; info = next) { + ir_timer_t *timer = info->timer; + double val = (double)ir_timer_elapsed_usec(timer) / 1000.0; + const char *description = info->description; + fprintf(f, "%-45s %8.3f msec\n", description, val); - for (i = 0; i < TV_LAST; ++i) { - double val = (double)ir_timer_elapsed_usec(timers[i]) / 1000.0; - fprintf(f, "%-30s %8.3f msec\n", tv_desc[i], val); + ir_timer_free(timer); + xfree(info->description); + next = info->next; + xfree(info); } + infos = NULL; + last_info = NULL; timers_inited = 0; } -void timer_push(int timer) { +void timer_push(ir_timer_t *timer) +{ if (timers_inited) - ir_timer_push(timers[timer]); + ir_timer_push(timer); } -void timer_pop(void) { +void timer_pop(ir_timer_t *timer) +{ + (void) timer; if (timers_inited) ir_timer_pop(); } -void timer_start(int timer) { +void timer_start(ir_timer_t *timer) +{ if (timers_inited) - ir_timer_start(timers[timer]); + ir_timer_start(timer); } -void timer_stop(int timer) { +void timer_stop(ir_timer_t *timer) +{ if (timers_inited) - ir_timer_stop(timers[timer]); + ir_timer_stop(timer); }