From: Will Deacon <will.deacon@arm.com>
To: linux-kernel@vger.kernel.org
Cc: torvalds@linux-foundation.org, viro@zeniv.linux.org.uk,
Will Deacon <will.deacon@arm.com>
Subject: [PATCH v2 2/2] word-at-a-time: provide generic big-endian zero_bytemask implementation
Date: Thu, 12 Dec 2013 17:40:22 +0000 [thread overview]
Message-ID: <1386870022-31525-2-git-send-email-will.deacon@arm.com> (raw)
In-Reply-To: <1386870022-31525-1-git-send-email-will.deacon@arm.com>
Whilst architectures may be able to do better than this (which they can,
by simply defining their own macro), this is a generic stab at a
zero_bytemask implementation for the asm-generic, big-endian
word-at-a-time implementation.
On arm64, a clz instruction is used to implement the fls efficiently.
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
include/asm-generic/word-at-a-time.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/asm-generic/word-at-a-time.h b/include/asm-generic/word-at-a-time.h
index 3f21f1b72e45..d3909effd725 100644
--- a/include/asm-generic/word-at-a-time.h
+++ b/include/asm-generic/word-at-a-time.h
@@ -49,4 +49,12 @@ static inline bool has_zero(unsigned long val, unsigned long *data, const struct
return (val + c->high_bits) & ~rhs;
}
+#ifndef zero_bytemask
+#ifdef CONFIG_64BIT
+#define zero_bytemask(mask) (~0ul << fls64(mask))
+#else
+#define zero_bytemask(mask) (~0ul << fls(mask))
+#endif /* CONFIG_64BIT */
+#endif /* zero_bytemask */
+
#endif /* _ASM_WORD_AT_A_TIME_H */
--
1.8.2.2
next prev parent reply other threads:[~2013-12-12 17:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-12 17:40 [PATCH v2 1/2] dcache: allow word-at-a-time name hashing with big-endian CPUs Will Deacon
2013-12-12 17:40 ` Will Deacon [this message]
2013-12-12 18:38 ` Linus Torvalds
2013-12-12 23:47 ` Benjamin Herrenschmidt
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=1386870022-31525-2-git-send-email-will.deacon@arm.com \
--to=will.deacon@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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