Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Will Deacon and committed by
Linus Torvalds
11ec50ca a5c21dce

+8
+8
include/asm-generic/word-at-a-time.h
··· 49 49 return (val + c->high_bits) & ~rhs; 50 50 } 51 51 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 + 52 60 #endif /* _ASM_WORD_AT_A_TIME_H */