From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41876) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vfq7g-0008Rw-2I for qemu-devel@nongnu.org; Mon, 11 Nov 2013 06:57:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vfq7Z-0007Xg-SY for qemu-devel@nongnu.org; Mon, 11 Nov 2013 06:57:39 -0500 Message-ID: <5280C629.9010704@suse.de> Date: Mon, 11 Nov 2013 12:57:29 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1384155875-26999-1-git-send-email-aik@ozlabs.ru> <1384155875-26999-6-git-send-email-aik@ozlabs.ru> In-Reply-To: <1384155875-26999-6-git-send-email-aik@ozlabs.ru> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 5/6] bitops: add BITNR macro List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy , qemu-devel@nongnu.org Cc: Paolo Bonzini , qemu-ppc@nongnu.org, Alexander Graf Am 11.11.2013 08:44, schrieb Alexey Kardashevskiy: > This adds a macro to calculate the highest bit set. Isn't that already available as ffs / clz GCC builtin with wrapper in qemu/bitops.h? What's the difference to your macro? CC'ing Paolo. Andreas > If used on constant > values, no code will be generated. >=20 > Signed-off-by: Alexey Kardashevskiy > --- > include/qemu/bitops.h | 12 ++++++++++++ > 1 file changed, 12 insertions(+) >=20 > diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h > index 304c90c..98ba42a 100644 > --- a/include/qemu/bitops.h > +++ b/include/qemu/bitops.h > @@ -23,6 +23,18 @@ > #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) > #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long= )) > =20 > +#define __BITNR(m, n) ((m) =3D=3D ((m) & (1<<(n)))) ? (n) : > +#define BITNR(m) \ > + __BITNR((m), 31) __BITNR((m), 30) __BITNR((m), 29) __BITNR((m), 28= ) \ > + __BITNR((m), 27) __BITNR((m), 26) __BITNR((m), 25) __BITNR((m), 24= ) \ > + __BITNR((m), 23) __BITNR((m), 22) __BITNR((m), 21) __BITNR((m), 20= ) \ > + __BITNR((m), 19) __BITNR((m), 18) __BITNR((m), 17) __BITNR((m), 16= ) \ > + __BITNR((m), 15) __BITNR((m), 14) __BITNR((m), 13) __BITNR((m), 12= ) \ > + __BITNR((m), 11) __BITNR((m), 10) __BITNR((m), 9) __BITNR((m), 8= ) \ > + __BITNR((m), 7) __BITNR((m), 6) __BITNR((m), 5) __BITNR((m), 4= ) \ > + __BITNR((m), 3) __BITNR((m), 2) __BITNR((m), 1) __BITNR((m), 0= ) \ > + -1 > + > /** > * set_bit - Set a bit in memory > * @nr: the bit to set >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg