Commit | Line | Data |
---|---|---|
1629372c PM |
1 | #ifndef _ASM_WORD_AT_A_TIME_H |
2 | #define _ASM_WORD_AT_A_TIME_H | |
3 | ||
4 | /* | |
5 | * Word-at-a-time interfaces for PowerPC. | |
6 | */ | |
7 | ||
8 | #include <linux/kernel.h> | |
9 | #include <asm/asm-compat.h> | |
10 | ||
11 | struct word_at_a_time { | |
12 | const unsigned long high_bits, low_bits; | |
13 | }; | |
14 | ||
15 | #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0xfe) + 1, REPEAT_BYTE(0x7f) } | |
16 | ||
17 | /* Bit set in the bytes that have a zero */ | |
18 | static inline long prep_zero_mask(unsigned long val, unsigned long rhs, const struct word_at_a_time *c) | |
19 | { | |
20 | unsigned long mask = (val & c->low_bits) + c->low_bits; | |
21 | return ~(mask | rhs); | |
22 | } | |
23 | ||
24 | #define create_zero_mask(mask) (mask) | |
25 | ||
26 | static inline long find_zero(unsigned long mask) | |
27 | { | |
28 | long leading_zero_bits; | |
29 | ||
30 | asm (PPC_CNTLZL "%0,%1" : "=r" (leading_zero_bits) : "r" (mask)); | |
31 | return leading_zero_bits >> 3; | |
32 | } | |
33 | ||
34 | static inline bool has_zero(unsigned long val, unsigned long *data, const struct word_at_a_time *c) | |
35 | { | |
36 | unsigned long rhs = val | c->low_bits; | |
37 | *data = rhs; | |
38 | return (val + c->high_bits) & ~rhs; | |
39 | } | |
40 | ||
41 | #endif /* _ASM_WORD_AT_A_TIME_H */ |