From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L0JMc-0000I2-No for qemu-devel@nongnu.org; Wed, 12 Nov 2008 12:18:46 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L0JMc-0000Hq-7K for qemu-devel@nongnu.org; Wed, 12 Nov 2008 12:18:46 -0500 Received: from [199.232.76.173] (port=41792 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0JMc-0000Hn-4I for qemu-devel@nongnu.org; Wed, 12 Nov 2008 12:18:46 -0500 Received: from savannah.gnu.org ([199.232.41.3]:45753 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 1L0JMc-0002pZ-0w for qemu-devel@nongnu.org; Wed, 12 Nov 2008 12:18:46 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1L0JMZ-0001wu-Vj for qemu-devel@nongnu.org; Wed, 12 Nov 2008 17:18:44 +0000 Received: from balrog by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1L0JMY-0001wk-M6 for qemu-devel@nongnu.org; Wed, 12 Nov 2008 17:18:43 +0000 MIME-Version: 1.0 Errors-To: balrog Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Andrzej Zaborowski Message-Id: Date: Wed, 12 Nov 2008 17:18:42 +0000 Subject: [Qemu-devel] [5708] Include for ffs(). 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: 5708 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5708 Author: balrog Date: 2008-11-12 17:18:41 +0000 (Wed, 12 Nov 2008) Log Message: ----------- Include for ffs(). ffs() is in although bsd compatible systems have it in already. ffs() is used in omap1.c, omap2.c, omap_i2c.c, bt-sdp.c. These uses can be replaced with clz32() but ffs is more available. Problem was spotted by malc. Make host-utils.h formatting more consistent. Modified Paths: -------------- trunk/host-utils.h trunk/qemu-common.h Modified: trunk/host-utils.h =================================================================== --- trunk/host-utils.h 2008-11-12 16:50:36 UTC (rev 5707) +++ trunk/host-utils.h 2008-11-12 17:18:41 UTC (rev 5708) @@ -116,7 +116,7 @@ return clz64(~val); } -static always_inline int ctz32 (uint32_t val) +static always_inline int ctz32(uint32_t val) { #if QEMU_GNUC_PREREQ(3, 4) if (val) @@ -128,39 +128,39 @@ cnt = 0; if (!(val & 0x0000FFFFUL)) { - cnt += 16; + cnt += 16; val >>= 16; - } + } if (!(val & 0x000000FFUL)) { - cnt += 8; + cnt += 8; val >>= 8; - } + } if (!(val & 0x0000000FUL)) { - cnt += 4; + cnt += 4; val >>= 4; - } + } if (!(val & 0x00000003UL)) { - cnt += 2; + cnt += 2; val >>= 2; - } + } if (!(val & 0x00000001UL)) { - cnt++; + cnt++; val >>= 1; - } + } if (!(val & 0x00000001UL)) { - cnt++; - } + cnt++; + } - return cnt; + return cnt; #endif - } - -static always_inline int cto32 (uint32_t val) - { +} + +static always_inline int cto32(uint32_t val) +{ return ctz32(~val); } -static always_inline int ctz64 (uint64_t val) +static always_inline int ctz64(uint64_t val) { #if QEMU_GNUC_PREREQ(3, 4) if (val) @@ -180,12 +180,12 @@ #endif } -static always_inline int cto64 (uint64_t val) +static always_inline int cto64(uint64_t val) { return ctz64(~val); } -static always_inline int ctpop8 (uint8_t val) +static always_inline int ctpop8(uint8_t val) { val = (val & 0x55) + ((val >> 1) & 0x55); val = (val & 0x33) + ((val >> 2) & 0x33); @@ -194,7 +194,7 @@ return val; } -static always_inline int ctpop16 (uint16_t val) +static always_inline int ctpop16(uint16_t val) { val = (val & 0x5555) + ((val >> 1) & 0x5555); val = (val & 0x3333) + ((val >> 2) & 0x3333); @@ -204,7 +204,7 @@ return val; } -static always_inline int ctpop32 (uint32_t val) +static always_inline int ctpop32(uint32_t val) { #if QEMU_GNUC_PREREQ(3, 4) return __builtin_popcount(val); @@ -219,7 +219,7 @@ #endif } -static always_inline int ctpop64 (uint64_t val) +static always_inline int ctpop64(uint64_t val) { #if QEMU_GNUC_PREREQ(3, 4) return __builtin_popcountll(val); Modified: trunk/qemu-common.h =================================================================== --- trunk/qemu-common.h 2008-11-12 16:50:36 UTC (rev 5707) +++ trunk/qemu-common.h 2008-11-12 17:18:41 UTC (rev 5708) @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include