20 extern struct pp_counters *pp_counters;
21 extern int *refcounts;
24 typedef unsigned long long pp_type;
26 static __attribute__((always_inline)) inline unsigned int pprof_get_one(void)
28 unsigned long long ret;
29 __asm__ __volatile__ ("rdtsc" : "=A" (ret));
30 return (unsigned int)ret;
32 #define unglitch_timer(x)
34 #elif defined(__GP2X__)
35 typedef unsigned long pp_type;
38 // XXX: MMSP2 only, timer sometimes seems to return lower vals?
39 extern volatile unsigned long *gp2x_memregl;
40 #define pprof_get_one() (unsigned int)gp2x_memregl[0x0a00 >> 2]
41 #define unglitch_timer(di) \
42 if ((signed int)(di) < 0) di = 0
44 extern unsigned int (*gp2x_get_ticks_us)(void);
45 #define pprof_get_one() gp2x_get_ticks_us()
46 #define unglitch_timer(di) \
47 if ((signed int)(di) < 0) di = 0
56 pp_type counter[pp_total_points];
59 #define pprof_start(point) { \
60 unsigned int pp_start_##point = pprof_get_one(); refcounts[pp_##point]++
62 #define pprof_end(point) \
64 unsigned int di = pprof_get_one() - pp_start_##point; \
66 if (!--refcounts[pp_##point]) pp_counters->counter[pp_##point] += di; \
70 // subtract for recursive stuff
71 #define pprof_end_sub(point) \
73 unsigned int di = pprof_get_one() - pp_start_##point; \
75 if (--refcounts[pp_##point]) pp_counters->counter[pp_##point] -= di; \
79 extern void pprof_init(void);
80 extern void pprof_finish(void);