Skip to content

Commit 11ec50c

Browse files
wildea01torvalds
authored andcommitted
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>
1 parent a5c21dc commit 11ec50c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎include/asm-generic/word-at-a-time.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,12 @@ static inline bool has_zero(unsigned long val, unsigned long *data, const struct
4949
return (val + c->high_bits) & ~rhs;
5050
}
5151

52+
#ifndef zero_bytemask
53+
#ifdef CONFIG_64BIT
54+
#define zero_bytemask(mask) (~0ul << fls64(mask))
55+
#else
56+
#define zero_bytemask(mask) (~0ul << fls(mask))
57+
#endif /* CONFIG_64BIT */
58+
#endif /* zero_bytemask */
59+
5260
#endif /* _ASM_WORD_AT_A_TIME_H */

0 commit comments

Comments
 (0)