mirror of
https://git.planet-casio.com/Lephenixnoir/libprof.git
synced 2024-12-26 11:33:41 +01:00
harden macros
This commit is contained in:
parent
6d82009532
commit
5b669e5529
1 changed files with 8 additions and 8 deletions
16
libprof.h
16
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); \
|
||||
})
|
||||
|
||||
//---
|
||||
|
|
Loading…
Reference in a new issue