44 #if defined( MBG_TGT_NETBSD ) 45 #if defined( MBG_TGT_KERNEL ) 46 #include <machine/cpu.h> 47 #include <machine/cpu_counter.h> 51 #if defined( MBG_TGT_FREEBSD ) 52 #if defined( MBG_TGT_KERNEL ) 53 #if defined( MBG_ARCH_X86 ) 55 #include <machine/clock.h> 60 #if defined( MBG_TGT_LINUX ) 61 #if defined( MBG_ARCH_IA64 ) && defined( MBG_TGT_KERNEL ) 62 #include <asm/ia64regs.h> 87 #if defined( MBG_TGT_WIN32 ) 95 #elif defined( MBG_TGT_POSIX ) 111 #define _mbg_swab_mbg_pc_cycles( _p ) \ 114 #define _mbg_swab_mbg_pc_cycles_frequency( _p ) \ 119 #if ( defined( MBG_TGT_LINUX ) || defined( MBG_TGT_BSD ) ) && defined( MBG_ARCH_X86 ) 121 static __mbg_inline
unsigned long long int mbg_rdtscll(
void )
167 __asm__ __volatile__(
"rdtsc" :
"=a" (tsc_val.u32.lo),
"=d" (tsc_val.u32.hi) );
180 #if !defined( OMIT_PC_CYCLES_SUPPORT ) 182 #if defined( MBG_TGT_WIN32 ) 184 #if defined( MBG_TGT_KERNEL ) // kernel space 185 *p = (
MBG_PC_CYCLES) KeQueryPerformanceCounter( NULL ).QuadPart;
189 QueryPerformanceCounter( (LARGE_INTEGER *) p );
192 #define MBG_PC_CYCLES_SUPPORTED 1 194 #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_X86 ) 197 #define MBG_PC_CYCLES_SUPPORTED 1 199 #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_IA64 ) && defined( MBG_TGT_KERNEL ) 201 unsigned long result = ia64_getreg( _IA64_REG_AR_ITC );
204 #ifdef CONFIG_ITANIUM 205 while (unlikely((__s32) result == -1))
207 result = ia64_getreg(_IA64_REG_AR_ITC);
214 #define MBG_PC_CYCLES_SUPPORTED 1 216 #elif defined( MBG_TGT_LINUX ) && defined( MBG_TGT_KERNEL ) 219 #define MBG_PC_CYCLES_SUPPORTED 1 221 #elif defined( MBG_TGT_FREEBSD ) && defined( MBG_ARCH_X86 ) 225 #define MBG_PC_CYCLES_SUPPORTED 1 227 #elif defined( MBG_TGT_NETBSD ) && defined( MBG_TGT_KERNEL ) 231 #define MBG_PC_CYCLES_SUPPORTED 1 238 #if !defined( MBG_PC_CYCLES_SUPPORTED ) 241 #define MBG_PC_CYCLES_SUPPORTED 0 252 #if defined( MBG_TGT_WIN32 ) 255 #if defined( MBG_TGT_KERNEL ) // kernel space 256 KeQueryPerformanceCounter( &li );
258 QueryPerformanceFrequency( &li );
263 #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_X86 ) && defined( MBG_TGT_KERNEL ) 265 *p = ( cpu_khz * 1000 );
267 #elif defined( MBG_TGT_LINUX ) && defined( MBG_ARCH_IA64 ) 277 #elif defined( MBG_TGT_FREEBSD ) && defined( MBG_ARCH_X86 ) && defined( MBG_TGT_KERNEL ) 281 #elif defined( MBG_TGT_NETBSD ) && defined( MBG_TGT_KERNEL ) 283 *p = cpu_frequency( curcpu() );
static __mbg_inline void mbg_get_pc_cycles(MBG_PC_CYCLES *p)
uint64_t MBG_PC_CYCLES_FREQUENCY
static __mbg_inline MBG_PC_CYCLES mbg_delta_pc_cycles(const MBG_PC_CYCLES *p1, const MBG_PC_CYCLES *p2)
unsigned __int64 uint64_t
int64_t MBG_PC_CYCLES
Generic types to hold PC cycle counter values.
static __mbg_inline void mbg_get_pc_cycles_frequency(MBG_PC_CYCLES_FREQUENCY *p)