21 #ifndef __ardour_cycles_h__
22 #define __ardour_cycles_h__
26 #if defined(__i386__) || defined(__x86_64__)
46 #if defined(__x86_64__)
48 #define rdtscll(lo, hi) \
49 __asm__ __volatile__("rdtsc" : "=a" (lo), "=d" (hi))
61 #define rdtscll(val) \
62 __asm__ __volatile__("rdtsc" : "=A" (val))
69 return ret & 0xffffffff;
73 #elif defined(__powerpc__)
75 #define CPU_FTR_601 0x00000100
93 ".section __ftr_fixup,\"a\"\n"
99 :
"=r" (ret) :
"i" (CPU_FTR_601));
103 #elif defined(__ia64__)
107 static inline cycles_t
111 __asm__ __volatile__ (
"mov %0=ar.itc" :
"=r"(ret));
115 #elif defined(__alpha__)
131 __asm__ __volatile__ (
"rpcc %0" :
"=r"(ret));
135 #elif defined(__s390__)
142 __asm__(
"stck 0(%0)" : :
"a" (&(cycles)) :
"memory",
"cc");
146 #elif defined(__hppa__)
149 #define mfctl(reg) ({ \
151 __asm__ __volatile__( \
152 "mfctl " #reg ",%0" : \
164 #elif defined(__mips__)
178 #define __read_32bit_c0_register(source, sel) \
181 __asm__ __volatile__( \
182 "mfc0\t%0, " #source "\n\t" \
185 __asm__ __volatile__( \
187 "mfc0\t%0, " #source ", " #sel "\n\t" \
194 #define read_c0_count() __read_32bit_c0_register($9, 0)
199 return read_c0_count();
203 #elif defined(__APPLE__)
205 #include <CoreAudio/HostTime.h>
210 UInt64 time = AudioGetCurrentHostTime();
211 return AudioConvertHostTimeToNanos(time);
219 #ifndef COMPILER_MSVC
221 #warning You are compiling libardour on a platform for which ardour/cycles.h needs work
224 #include <sys/time.h>
233 gettimeofday (&tv, NULL);
static cycles_t get_cycles(void)