23 #ifndef __ardour_cycles_h__
24 #define __ardour_cycles_h__
28 #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(__powerpc64__)
76 #include <sys/platform/ppc.h>
80 return __ppc_get_timebase();
82 #elif defined(__FreeBSD__)
87 asm volatile(
"mfspr %0, 268" :
"=r"(tbr));
92 #elif defined(__powerpc__)
94 #define CPU_FTR_601 0x00000100
107 __asm__ __volatile__(
110 ".section __ftr_fixup,\"a\"\n"
116 :
"=r" (ret) :
"i" (CPU_FTR_601));
120 #elif defined(__ia64__)
128 __asm__ __volatile__ (
"mov %0=ar.itc" :
"=r"(ret));
132 #elif defined(__alpha__)
148 __asm__ __volatile__ (
"rpcc %0" :
"=r"(ret));
152 #elif defined(__s390__)
159 __asm__(
"stck 0(%0)" : :
"a" (&(cycles)) :
"memory",
"cc");
163 #elif defined(__hppa__)
166 #define mfctl(reg) ({ \
168 __asm__ __volatile__( \
169 "mfctl " #reg ",%0" : \
181 #elif defined(__mips__)
195 #define __read_32bit_c0_register(source, sel) \
198 __asm__ __volatile__( \
199 "mfc0\t%0, " #source "\n\t" \
202 __asm__ __volatile__( \
204 "mfc0\t%0, " #source ", " #sel "\n\t" \
211 #define read_c0_count() __read_32bit_c0_register($9, 0)
216 return read_c0_count();
220 #elif defined(__APPLE__)
222 #include <CoreAudio/HostTime.h>
227 UInt64 time = AudioGetCurrentHostTime();
228 return AudioConvertHostTimeToNanos(time);
236 #ifndef COMPILER_MSVC
238 #warning You are compiling libardour on a platform for which ardour/cycles.h needs work
241 #include <sys/time.h>
248 gettimeofday (&tv, NULL);
static cycles_t get_cycles(void)