From: "Cristian Rodríguez" <crrodriguez@opensuse.org>
To: linux-ext4@vger.kernel.org
Cc: "Cristian Rodríguez" <crrodriguez@opensuse.org>
Subject: [PATCH] lib/ext2fs: Use __builtin_popcount when available Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org>
Date: Sun, 6 Jan 2013 12:04:43 -0300 [thread overview]
Message-ID: <1357484683-3021-1-git-send-email-crrodriguez@opensuse.org> (raw)
---
lib/ext2fs/bitops.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/ext2fs/bitops.c b/lib/ext2fs/bitops.c
index 7c3f215..0668469 100644
--- a/lib/ext2fs/bitops.c
+++ b/lib/ext2fs/bitops.c
@@ -125,11 +125,15 @@ static unsigned int popcount8(unsigned int w)
static unsigned int popcount32(unsigned int w)
{
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+ return __builtin_popcount(w);
+#else
unsigned int res = w - ((w >> 1) & 0x55555555);
res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
res = (res + (res >> 4)) & 0x0F0F0F0F;
res = res + (res >> 8);
return (res + (res >> 16)) & 0x000000FF;
+#endif
}
unsigned int ext2fs_bitcount(const void *addr, unsigned int nbytes)
--
1.8.1
next reply other threads:[~2013-01-06 15:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-06 15:04 Cristian Rodríguez [this message]
2013-01-06 22:20 ` [PATCH] lib/ext2fs: Use __builtin_popcount when available Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org> Theodore Ts'o
2013-01-07 0:53 ` Cristian Rodríguez
2013-01-07 1:31 ` Theodore Ts'o
2013-01-07 1:46 ` Cristian Rodríguez
2013-01-07 1:56 ` Theodore Ts'o
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=1357484683-3021-1-git-send-email-crrodriguez@opensuse.org \
--to=crrodriguez@opensuse.org \
--cc=linux-ext4@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).