WIP FPC-III support
[linux/fpc-iii.git] / arch / riscv / include / asm / word-at-a-time.h
blob7c086ac6ecd4a82e11b9cd7cbd8d6944fb68ae1f
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2012 Regents of the University of California
5 * Derived from arch/x86/include/asm/word-at-a-time.h
6 */
8 #ifndef _ASM_RISCV_WORD_AT_A_TIME_H
9 #define _ASM_RISCV_WORD_AT_A_TIME_H
12 #include <linux/kernel.h>
14 struct word_at_a_time {
15 const unsigned long one_bits, high_bits;
18 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
20 static inline unsigned long has_zero(unsigned long val,
21 unsigned long *bits, const struct word_at_a_time *c)
23 unsigned long mask = ((val - c->one_bits) & ~val) & c->high_bits;
24 *bits = mask;
25 return mask;
28 static inline unsigned long prep_zero_mask(unsigned long val,
29 unsigned long bits, const struct word_at_a_time *c)
31 return bits;
34 static inline unsigned long create_zero_mask(unsigned long bits)
36 bits = (bits - 1) & ~bits;
37 return bits >> 7;
40 static inline unsigned long find_zero(unsigned long mask)
42 return fls64(mask) >> 3;
45 /* The mask we created is directly usable as a bytemask */
46 #define zero_bytemask(mask) (mask)
48 #endif /* _ASM_RISCV_WORD_AT_A_TIME_H */