1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2012 Regents of the University of California
5 * Derived from arch/x86/include/asm/word-at-a-time.h
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
;
28 static inline unsigned long prep_zero_mask(unsigned long val
,
29 unsigned long bits
, const struct word_at_a_time
*c
)
34 static inline unsigned long create_zero_mask(unsigned long bits
)
36 bits
= (bits
- 1) & ~bits
;
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 */