From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HTqjm-0002dn-QO for qemu-devel@nongnu.org; Tue, 20 Mar 2007 22:39:42 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HTqjk-0002db-Qb for qemu-devel@nongnu.org; Tue, 20 Mar 2007 22:39:41 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HTqjk-0002dY-Kg for qemu-devel@nongnu.org; Tue, 20 Mar 2007 21:39:40 -0500 Received: from pf.freedaemonhosting.com ([66.210.104.252] helo=FreeDaemonHosting.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1HTqi7-00082W-3o for qemu-devel@nongnu.org; Tue, 20 Mar 2007 22:37:59 -0400 Received: from blue.fries.net (blue.hse.fries.net [IPv6:2001:240:58a::1c]) by FreeDaemonHosting.com (8.13.8/8.13.3) with ESMTP id l2L2bYtb021739 for ; Tue, 20 Mar 2007 21:37:34 -0500 (CDT) Received: from blue.fries.net (localhost.fries.net [IPv6:::1]) by blue.fries.net (8.14.0/8.13.6) with ESMTP id l2L2bSRm013896 for ; Tue, 20 Mar 2007 21:37:28 -0500 (CDT) Received: (from todd@localhost) by blue.fries.net (8.14.0/8.13.6/Submit) id l2L2bSDo001157 for qemu-devel@nongnu.org; Tue, 20 Mar 2007 21:37:28 -0500 (CDT) Date: Tue, 20 Mar 2007 21:37:28 -0500 From: "Todd T. Fries" Message-ID: <20070321023726.GA11696@fries.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] Patch: cpu-all.h for better cycle counter Reply-To: todd@fries.net, 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 This is relative to the 20070319 snapshot. --- cpu-all.h.orig Fri Mar 16 18:58:11 2007 +++ cpu-all.h Tue Mar 20 21:14:10 2007 @@ -1012,13 +1012,22 @@ static inline int64_t cpu_get_real_ticks #endif } #else -/* The host CPU doesn't have an easily accessible cycle counter. - Just return a monotonically increasing vlue. This will be totally wrong, - but hopefully better than nothing. */ +# warning non-optimized CPU +#include +#include + static inline int64_t cpu_get_real_ticks (void) { - static int64_t ticks = 0; - return ticks++; + struct timeval tv; + static int64_t i = 0; + int64_t j; + + gettimeofday(&tv, NULL); + do { + j = (tv.tv_sec * (uint64_t) 1000000) + tv.tv_usec; + } while (i == j); + i = j; + return j; } #endif -- Todd Fries .. todd@fries.net _____________________________________________ | \ 1.636.410.0632 (voice) | Free Daemon Consulting, LLC \ 1.405.227.9094 (voice) | http://FreeDaemonConsulting.com \ 1.866.792.3418 (FAX) | "..in support of free software solutions." \ 250797 (FWD) | \ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 37E7 D3EB 74D0 8D66 A68D B866 0326 204E 3F42 004A http://todd.fries.net/pgp.txt