X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Fcycles.h;h=bfa42a157ed394d00fd36a0b1f1343215a255585;hb=b9a9d8d0471c28e80e350d6e49cde965f87b986b;hp=a6f34d59be5d16a77a72f09ccac99d4908de648a;hpb=532f6aad4ac79ca15d69deccd18fca90e444c437;p=ardour.git diff --git a/libs/ardour/ardour/cycles.h b/libs/ardour/ardour/cycles.h index a6f34d59be..bfa42a157e 100644 --- a/libs/ardour/ardour/cycles.h +++ b/libs/ardour/ardour/cycles.h @@ -1,7 +1,7 @@ /* Copyright (C) 2001 Paul Davis Code derived from various headers from the Linux kernel - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or @@ -16,7 +16,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __ardour_cycles_h__ @@ -38,7 +37,7 @@ * We only use the low 32 bits, and we'd simply better make sure * that we reschedule before that wraps. Scheduling at least every * four billion cycles just basically sounds like a good idea, - * regardless of how fast the machine is. + * regardless of how fast the machine is. */ typedef uint64_t cycles_t; @@ -49,10 +48,10 @@ extern cycles_t cacheflush_time; static inline cycles_t get_cycles (void) { - uint32_t long ret; + cycles_t ret; rdtscll(ret); - return ret; + return ret & 0xffffffff; } #elif defined(__powerpc__) @@ -104,7 +103,7 @@ get_cycles (void) * Standard way to access the cycle counter. * Currently only used on SMP for scheduling. * - * Only the low 32 bits are available as a continuously counting entity. + * Only the low 32 bits are available as a continuously counting entity. * But this only means we'll force a reschedule every 8 seconds or so, * which isn't an evil thing. */ @@ -123,27 +122,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__) @@ -160,19 +159,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 */ @@ -181,29 +180,19 @@ 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 */ #elif defined(__APPLE__) -#ifdef HAVE_WEAK_COREAUDIO #include -#else // Due to MacTypes.h and libgnomecanvasmm Rect conflict -typedef unsigned long long UInt64; - -extern UInt64 -AudioGetCurrentHostTime(); - -extern UInt64 -AudioConvertHostTimeToNanos(UInt64 inHostTime); -#endif 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 */ @@ -221,10 +210,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