Linux 4.18.10
[linux/fpc-iii.git] / arch / alpha / include / asm / word-at-a-time.h
blob4035265f1ad9fcff91ea002a913080516d6c9ab3
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_WORD_AT_A_TIME_H
3 #define _ASM_WORD_AT_A_TIME_H
5 #include <asm/compiler.h>
7 /*
8 * word-at-a-time interface for Alpha.
9 */
12 * We do not use the word_at_a_time struct on Alpha, but it needs to be
13 * implemented to humour the generic code.
15 struct word_at_a_time {
16 const unsigned long unused;
19 #define WORD_AT_A_TIME_CONSTANTS { 0 }
21 /* Return nonzero if val has a zero */
22 static inline unsigned long has_zero(unsigned long val, unsigned long *bits, const struct word_at_a_time *c)
24 unsigned long zero_locations = __kernel_cmpbge(0, val);
25 *bits = zero_locations;
26 return zero_locations;
29 static inline unsigned long prep_zero_mask(unsigned long val, unsigned long bits, const struct word_at_a_time *c)
31 return bits;
34 #define create_zero_mask(bits) (bits)
36 static inline unsigned long find_zero(unsigned long bits)
38 #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67)
39 /* Simple if have CIX instructions */
40 return __kernel_cttz(bits);
41 #else
42 unsigned long t1, t2, t3;
43 /* Retain lowest set bit only */
44 bits &= -bits;
45 /* Binary search for lowest set bit */
46 t1 = bits & 0xf0;
47 t2 = bits & 0xcc;
48 t3 = bits & 0xaa;
49 if (t1) t1 = 4;
50 if (t2) t2 = 2;
51 if (t3) t3 = 1;
52 return t1 + t2 + t3;
53 #endif
56 #define zero_bytemask(mask) ((2ul << (find_zero(mask) * 8)) - 1)
58 #endif /* _ASM_WORD_AT_A_TIME_H */