Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_WORD_AT_A_TIME_H
0003 #define _ASM_WORD_AT_A_TIME_H
0004 
0005 #include <asm/compiler.h>
0006 
0007 /*
0008  * word-at-a-time interface for Alpha.
0009  */
0010 
0011 /*
0012  * We do not use the word_at_a_time struct on Alpha, but it needs to be
0013  * implemented to humour the generic code.
0014  */
0015 struct word_at_a_time {
0016     const unsigned long unused;
0017 };
0018 
0019 #define WORD_AT_A_TIME_CONSTANTS { 0 }
0020 
0021 /* Return nonzero if val has a zero */
0022 static inline unsigned long has_zero(unsigned long val, unsigned long *bits, const struct word_at_a_time *c)
0023 {
0024     unsigned long zero_locations = __kernel_cmpbge(0, val);
0025     *bits = zero_locations;
0026     return zero_locations;
0027 }
0028 
0029 static inline unsigned long prep_zero_mask(unsigned long val, unsigned long bits, const struct word_at_a_time *c)
0030 {
0031     return bits;
0032 }
0033 
0034 #define create_zero_mask(bits) (bits)
0035 
0036 static inline unsigned long find_zero(unsigned long bits)
0037 {
0038 #if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67)
0039     /* Simple if have CIX instructions */
0040     return __kernel_cttz(bits);
0041 #else
0042     unsigned long t1, t2, t3;
0043     /* Retain lowest set bit only */
0044     bits &= -bits;
0045     /* Binary search for lowest set bit */
0046     t1 = bits & 0xf0;
0047     t2 = bits & 0xcc;
0048     t3 = bits & 0xaa;
0049     if (t1) t1 = 4;
0050     if (t2) t2 = 2;
0051     if (t3) t3 = 1;
0052     return t1 + t2 + t3;
0053 #endif
0054 }
0055 
0056 #define zero_bytemask(mask) ((2ul << (find_zero(mask) * 8)) - 1)
0057 
0058 #endif /* _ASM_WORD_AT_A_TIME_H */