diff --git a/libprof.h b/libprof.h index 02905a9..49f654e 100644 --- a/libprof.h +++ b/libprof.h @@ -58,7 +58,7 @@ extern uint32_t volatile *prof_tcnt; function was already executing then the deepest instance in the stack is used instead of creating a new counter. */ #define prof_enter(prof) { \ - if(!prof.rec++) prof.elapsed += *prof_tcnt; \ + if(!(prof).rec++) (prof).elapsed += *prof_tcnt; \ } /* prof_leave(): Stop counting time for a function @@ -67,15 +67,15 @@ extern uint32_t volatile *prof_tcnt; are not as exactly as many prof_leave()'s as prof_enter()'s then the resulting time measure will not be relevant at all. */ #define prof_leave(prof) { \ - if(!--prof.rec) prof.elapsed -= *prof_tcnt; \ + if(!--(prof).rec) (prof).elapsed -= *prof_tcnt; \ } /* Variant of prof_enter()/prof_leave() for non-recursive contexts */ #define prof_enter_norec(prof) { \ - prof.elapsed += *prof_tcnt; \ + (prof).elapsed += *prof_tcnt; \ } #define prof_leave_norec(prof) { \ - prof.elapsed -= *prof_tcnt; \ + (prof).elapsed -= *prof_tcnt; \ } /* prof_exec(): Measure a single block of code @@ -87,11 +87,11 @@ extern uint32_t volatile *prof_tcnt; exec_code(); }); */ #define prof_exec(code) ({ \ - prof_t prof = prof_make(); \ - prof_enter(prof); \ + prof_t _prof = prof_make(); \ + prof_enter(_prof); \ code; \ - prof_leave(prof); \ - prof_time(prof); \ + prof_leave(_prof); \ + prof_time(_prof); \ }) //---