X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Fcycles.h;h=dc1095db7b60939122a07b74f9e5629b92781f98;hb=8c944c08eacf8372fc714c9c00257ec13a263ae8;hp=9f6d9b4b5c3ed1837414588a34c7e2a151c2e3b9;hpb=bb9cc45cd22af67ac275a5e73accbe14fee664d8;p=ardour.git diff --git a/libs/ardour/ardour/cycles.h b/libs/ardour/ardour/cycles.h index 9f6d9b4b5c..dc1095db7b 100644 --- a/libs/ardour/ardour/cycles.h +++ b/libs/ardour/ardour/cycles.h @@ -43,8 +43,23 @@ typedef uint64_t cycles_t; extern cycles_t cacheflush_time; -#define rdtscll(val) \ - __asm__ __volatile__("rdtsc" : "=A" (val)) +#if defined(__x86_64__) + +#define rdtscll(lo, hi) \ + __asm__ __volatile__("rdtsc" : "=a" (lo), "=d" (hi)) + +static inline cycles_t get_cycles (void) +{ + cycles_t lo, hi; + + rdtscll(lo, hi); + return lo; +} + +#else + +#define rdtscll(val) \ +__asm__ __volatile__("rdtsc" : "=A" (val)) static inline cycles_t get_cycles (void) { @@ -53,6 +68,7 @@ static inline cycles_t get_cycles (void) rdtscll(ret); return ret & 0xffffffff; } +#endif #elif defined(__powerpc__) @@ -122,27 +138,27 @@ static inline cycles_t get_cycles (void) typedef uint32_t long cycles_t; static inline cycles_t get_cycles(void) { - cycles_t cycles; - __asm__("stck 0(%0)" : : "a" (&(cycles)) : "memory", "cc"); - return cycles >> 2; + cycles_t cycles; + __asm__("stck 0(%0)" : : "a" (&(cycles)) : "memory", "cc"); + return cycles >> 2; } #elif defined(__hppa__) /* hppa/parisc */ #define mfctl(reg) ({ \ - uint32_t cr; \ - __asm__ __volatile__( \ - "mfctl " #reg ",%0" : \ - "=r" (cr) \ - ); \ - cr; \ + uint32_t cr; \ + __asm__ __volatile__( \ + "mfctl " #reg ",%0" : \ + "=r" (cr) \ + ); \ + cr; \ }) typedef uint32_t cycles_t; static inline cycles_t get_cycles (void) { - return mfctl(16); + return mfctl(16); } #elif defined(__mips__) @@ -159,19 +175,19 @@ static inline cycles_t get_cycles (void) * We know that all SMP capable CPUs have cycle counters. */ -#define __read_32bit_c0_register(source, sel) \ -({ int __res; \ - if (sel == 0) \ - __asm__ __volatile__( \ - "mfc0\t%0, " #source "\n\t" \ - : "=r" (__res)); \ - else \ - __asm__ __volatile__( \ - ".set\tmips32\n\t" \ - "mfc0\t%0, " #source ", " #sel "\n\t" \ - ".set\tmips0\n\t" \ - : "=r" (__res)); \ - __res; \ +#define __read_32bit_c0_register(source, sel) \ +({ int __res; \ + if (sel == 0) \ + __asm__ __volatile__( \ + "mfc0\t%0, " #source "\n\t" \ + : "=r" (__res)); \ + else \ + __asm__ __volatile__( \ + ".set\tmips32\n\t" \ + "mfc0\t%0, " #source ", " #sel "\n\t" \ + ".set\tmips0\n\t" \ + : "=r" (__res)); \ + __res; \ }) /* #define CP0_COUNT $9 */ @@ -180,7 +196,7 @@ static inline cycles_t get_cycles (void) typedef uint32_t cycles_t; static inline cycles_t get_cycles (void) { - return read_c0_count(); + return read_c0_count(); } /* begin mach */ @@ -191,8 +207,8 @@ static inline cycles_t get_cycles (void) typedef UInt64 cycles_t; static inline cycles_t get_cycles (void) { - UInt64 time = AudioGetCurrentHostTime(); - return AudioConvertHostTimeToNanos(time); + UInt64 time = AudioGetCurrentHostTime(); + return AudioConvertHostTimeToNanos(time); } /* end mach */ @@ -200,7 +216,10 @@ static inline cycles_t get_cycles (void) /* debian: sparc, arm, m68k */ +#ifndef COMPILER_MSVC +/* GRRR... Annoyingly, #warning aborts the compilation for MSVC !! */ #warning You are compiling libardour on a platform for which ardour/cycles.h needs work +#endif #include @@ -210,10 +229,10 @@ extern cycles_t cacheflush_time; static inline cycles_t get_cycles(void) { - struct timeval tv; - gettimeofday (&tv, NULL); + struct timeval tv; + gettimeofday (&tv, NULL); - return tv.tv_usec; + return tv.tv_usec; } #endif