summaryrefslogtreecommitdiff
path: root/lib/ultralib/src/debug/threadprofile.c
blob: e3837732e185ecddf0b816312cca0f985aee8fc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "osint_debug.h"

#include "macros.h"

s32 __osThprofFlag = 0;
void (*__osThprofFunc)(OSThread*) = NULL;

u32 __osThprofLastTimer;
u32 __osThprofCount;
__OSThreadprofile_s thprof[THPROF_IDMAX] ALIGNED(0x10);
u64 __osThprofHeap[THPROF_STACKSIZE] ALIGNED(0x10);
void* __osThprofStack;

void osThreadProfileCallback(OSThread* osthread) {
    register u32 now_time = osGetCount();
    __OSThreadprofile_s* thprof = osthread->thprof;

    thprof->time += now_time - __osThprofLastTimer;
    thprof->count++;
    __osThprofCount++;
    __osThprofLastTimer = now_time;
}