7 #define INLINE __inline
8 #define PACKED __attribute__((packed))
10 #elif defined(__WATCOMC__)
11 #define INLINE __inline
19 /* fast conversion of double -> 32bit int
21 * - http://chrishecker.com/images/f/fb/Gdmfp.pdf
22 * - http://stereopsis.com/FPU.html#convert
24 static INLINE int32_t cround64(double val)
26 val += 6755399441055744.0;
27 return *(int32_t*)&val;
30 extern uint32_t perf_start_count, perf_interval_count;
33 void perf_start(void);
34 #pragma aux perf_start = \
38 "mov [perf_start_count], eax" \
39 modify[eax ebx ecx edx];
42 #pragma aux perf_end = \
46 "sub eax, [perf_start_count]" \
47 "mov [perf_interval_count], eax" \
48 modify [eax ebx ecx edx];
50 void debug_break(void);
51 #pragma aux debug_break = "int 3";
55 #define perf_start() asm volatile ( \
56 "xor %%eax, %%eax\n" \
60 : "=m"(perf_start_count) \
61 :: "%eax", "%ebx", "%ecx", "%edx")
63 #define perf_end() asm volatile ( \
64 "xor %%eax, %%eax\n" \
69 : "=m"(perf_interval_count) \
70 : "m"(perf_start_count) \
71 : "%eax", "%ebx", "%ecx", "%edx")
73 #define debug_break() \
74 asm volatile ("int $3")
78 #define perf_start() \
84 mov [perf_start_count], eax \
94 sub eax, [perf_start_count] \
95 mov [perf_interval_count], eax \
99 #define debug_break() \