summaryrefslogtreecommitdiffstats
path: root/include/asm-generic
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2013-12-12 18:40:22 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2013-12-12 19:39:01 +0100
commit11ec50caedb56e3a87715edeff6a1852e6ae5416 (patch)
treea94b6a3d2456800197d67effa2677d426d00d31d /include/asm-generic
parentdcache: allow word-at-a-time name hashing with big-endian CPUs (diff)
downloadlinux-11ec50caedb56e3a87715edeff6a1852e6ae5416.tar.xz
linux-11ec50caedb56e3a87715edeff6a1852e6ae5416.zip
word-at-a-time: provide generic big-endian zero_bytemask implementation
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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/asm-generic')
-rw-r--r--include/asm-generic/word-at-a-time.h8
1 files changed, 8 insertions, 0 deletions
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 */