harden macros

This commit is contained in:
Lephenixnoir 2022-08-16 09:07:12 +02:00
parent 6d82009532
commit 5b669e5529
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
1 changed files with 8 additions and 8 deletions

View File

@ -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); \
})
//---