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