From: "Andreas Färber" <afaerber@suse.de>
To: Alexey Kardashevskiy <aik@ozlabs.ru>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
qemu-ppc@nongnu.org, Alexander Graf <agraf@suse.de>
Subject: Re: [Qemu-devel] [PATCH v3 5/6] bitops: add BITNR macro
Date: Mon, 11 Nov 2013 12:57:29 +0100 [thread overview]
Message-ID: <5280C629.9010704@suse.de> (raw)
In-Reply-To: <1384155875-26999-6-git-send-email-aik@ozlabs.ru>
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.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
> include/qemu/bitops.h | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> 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))
>
> +#define __BITNR(m, n) ((m) == ((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
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
next prev parent reply other threads:[~2013-11-11 11:57 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-11 7:44 [Qemu-devel] [PATCH v3 0/6] spapr: add "compat" machine option Alexey Kardashevskiy
2013-11-11 7:44 ` [Qemu-devel] [PATCH v3 1/6] cpu: add suboptions support Alexey Kardashevskiy
2013-11-30 10:10 ` Alexey Kardashevskiy
2013-11-30 11:00 ` Paolo Bonzini
2013-11-30 13:08 ` Alexey Kardashevskiy
2013-11-11 7:44 ` [Qemu-devel] [PATCH v3 2/6] target-ppc: make use of new -cpu suboptions handling Alexey Kardashevskiy
2013-11-11 7:44 ` [Qemu-devel] [PATCH v3 3/6] target-ppc: add "compat" CPU option Alexey Kardashevskiy
2013-11-11 7:44 ` [Qemu-devel] [PATCH v3 4/6] qemu-option: support +foo/-foo command line agruments Alexey Kardashevskiy
2013-11-11 12:41 ` Andreas Färber
2013-11-11 12:52 ` Jan Kiszka
2013-11-11 13:23 ` Andreas Färber
2013-11-11 14:25 ` Igor Mammedov
2013-11-11 23:49 ` Alexey Kardashevskiy
2013-11-12 9:58 ` Igor Mammedov
2013-11-12 12:39 ` Alexey Kardashevskiy
2013-11-12 12:45 ` Andreas Färber
2013-11-13 1:51 ` Alexey Kardashevskiy
2013-11-13 9:29 ` Paolo Bonzini
2013-11-12 13:11 ` Igor Mammedov
2013-11-13 2:07 ` Alexey Kardashevskiy
2013-11-13 10:38 ` Igor Mammedov
2013-11-13 9:20 ` Paolo Bonzini
2013-11-11 7:44 ` [Qemu-devel] [PATCH v3 5/6] bitops: add BITNR macro Alexey Kardashevskiy
2013-11-11 11:57 ` Andreas Färber [this message]
2013-11-11 12:09 ` Alexey Kardashevskiy
2013-11-13 2:40 ` Alexey Kardashevskiy
2013-11-13 12:04 ` Paolo Bonzini
2013-11-14 5:51 ` Alexey Kardashevskiy
2013-11-14 8:54 ` Paolo Bonzini
2013-11-11 7:44 ` [Qemu-devel] [PATCH v3 6/6] target-ppc: demonstrate new "vsx" property Alexey Kardashevskiy
2013-11-11 13:31 ` Andreas Färber
2013-11-14 5:20 ` Alexey Kardashevskiy
2013-11-14 16:04 ` Andreas Färber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5280C629.9010704@suse.de \
--to=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.