From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LR2fd-0006gD-4U for qemu-devel@nongnu.org; Sun, 25 Jan 2009 05:56:53 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LR2fa-0006dx-E1 for qemu-devel@nongnu.org; Sun, 25 Jan 2009 05:56:51 -0500 Received: from [199.232.76.173] (port=54042 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LR2fa-0006ds-9j for qemu-devel@nongnu.org; Sun, 25 Jan 2009 05:56:50 -0500 Received: from savannah.gnu.org ([199.232.41.3]:42853 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LR2fZ-0006E3-GE for qemu-devel@nongnu.org; Sun, 25 Jan 2009 05:56:49 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LR2fY-0001da-VD for qemu-devel@nongnu.org; Sun, 25 Jan 2009 10:56:49 +0000 Received: from malc by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LR2fY-0001dV-NL for qemu-devel@nongnu.org; Sun, 25 Jan 2009 10:56:48 +0000 MIME-Version: 1.0 Errors-To: malc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: malc Message-Id: Date: Sun, 25 Jan 2009 10:56:48 +0000 Subject: [Qemu-devel] [6435] Massage PPC version of cpu_get_real_ticks a little Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 =================================================================== --- trunk/cpu-all.h 2009-01-24 20:19:18 UTC (rev 6434) +++ trunk/cpu-all.h 2009-01-25 10:56:48 UTC (rev 6435) @@ -996,30 +996,30 @@ #if defined(_ARCH_PPC) -static inline uint32_t get_tbl(void) -{ - uint32_t tbl; - asm volatile("mftb %0" : "=r" (tbl)); - return tbl; -} - -static inline uint32_t get_tbu(void) -{ - uint32_t tbl; - asm volatile("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__)