3 * Library of functions to read the Pentium TSC register.
4 * (C) 2009-2012 Jonathan Campbell.
5 * Hackipedia DOS library.
7 * This code is licensed under the LGPL.
8 * <insert LGPL legal text here>
12 #ifndef __HW_CPU_RDTSC_H
13 #define __HW_CPU_RDTSC_H
17 typedef uint64_t rdtsc_t;
19 #if TARGET_MSDOS == 32
20 static inline uint64_t cpu_rdtsc();
21 #pragma aux cpu_rdtsc = \
26 static inline void cpu_rdtsc_write(const uint64_t val);
27 #pragma aux cpu_rdtsc_write = \
34 /* This is too much code to inline insert everywhere---unless you want extra-large EXEs.
35 * It's better to conform to Watcom's register calling convention and make it a function.
36 * Note that if you look at the assembly language most of the code is shuffling the values
37 * around to convert EDX:EAX to AX:BX:CX:DX and disabling interrupts during the call. */
39 void cpu_rdtsc_write(const uint64_t val);
42 #endif /* __HW_CPU_RDTSC_H */