[6435] Massage PPC version of cpu_get_real_ticks a little
Revision: 6435
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6435 Author: malc Date: 2009-01-25 10:56:48 +0000 (Sun, 25 Jan 2009)
Log Message:
-----------
Massage PPC version of cpu_get_real_ticks a little
Modified Paths:
--------------
trunk/cpu-all.h
Modified: trunk/cpu-all.h
===================================================================
cpu-all.h +22 -22
@@ -996,30 +996,30 @@#if defined(_ARCH_PPC) -static inline uint32_t get_tbl (void ) -{ -uint32_t tbl; - asmvolatile ("mftb %0" :"=r" (tbl)); -return tbl; -} - -static inline uint32_t get_tbu (void ) -{ -uint32_t tbl; - asmvolatile ("mftbu %0" :"=r" (tbl)); -return tbl; -} -static inline int64_t cpu_get_real_ticks (void ) { -uint32_t l, h, h1; -/* NOTE: we test if wrapping has occurred */ -do { - h =get_tbu (); - l =get_tbl (); - h1 =get_tbu (); - }while (h != h1); -return ((int64_t )h <<32 ) | l; +int64_t retval; +#ifdef _ARCH_PPC64 +/* This reads timebase in one 64bit go and includes Cell workaround from: +http://ozlabs.org/pipermail/linuxppc-dev/2006-October/027052.html +*/ + __asm__ __volatile__ ( +"mftb %0\n\t" +"cmpwi %0,0\n\t" +"beq- $-8" + :"=r" (retval)); +#else +/* http://ozlabs.org/pipermail/linuxppc-dev/1999-October/003889.html */ +unsigned long junk; + __asm__ __volatile__ ( +"mftbu %1\n\t" +"mftb %L0\n\t" +"mftbu %0\n\t" +"cmpw %0,%1\n\t" +"bne $-16" + :"=r" (retval),"=r" (junk)); +#endif +return retval; }#elif defined(__i386__)