forked from notaz/picodrive
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpprof.h
67 lines (56 loc) · 1.36 KB
/
pprof.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef __PPROF_H__
#define __PPROF_H__
enum pprof_points {
pp_main,
pp_frame,
pp_draw,
pp_sound,
pp_m68k,
pp_z80,
pp_msh2,
pp_ssh2,
pp_dummy,
pp_total_points
};
struct pp_counters
{
unsigned long long counter[pp_total_points];
};
extern struct pp_counters *pp_counters;
#ifdef __i386__
static __attribute__((always_inline)) inline unsigned int pprof_get_one(void)
{
unsigned long long ret;
__asm__ __volatile__ ("rdtsc" : "=A" (ret));
return (unsigned int)ret;
}
#define unglitch_timer(x)
#elif defined(__GP2X__)
// XXX: MMSP2 only, timer sometimes seems to return lower vals?
extern volatile unsigned long *gp2x_memregl;
#define pprof_get_one() (unsigned int)gp2x_memregl[0x0a00 >> 2]
#define unglitch_timer(di) \
if ((signed int)(di) < 0) di = 0
#else
#error no timer
#endif
#define pprof_start(point) { \
unsigned int pp_start_##point = pprof_get_one()
#define pprof_end(point) \
{ \
unsigned int di = pprof_get_one() - pp_start_##point; \
unglitch_timer(di); \
pp_counters->counter[pp_##point] += di; \
} \
}
// subtract for recursive stuff
#define pprof_end_sub(point) \
{ \
unsigned int di = pprof_get_one() - pp_start_##point; \
unglitch_timer(di); \
pp_counters->counter[pp_##point] -= di; \
} \
}
extern void pprof_init(void);
extern void pprof_finish(void);
#endif // __PPROF_H__