aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include/asm/word-at-a-time.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/include/asm/word-at-a-time.h')
-rw-r--r--arch/powerpc/include/asm/word-at-a-time.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/word-at-a-time.h b/arch/powerpc/include/asm/word-at-a-time.h
new file mode 100644
index 000000000000..d0b6d4ac6dda
--- /dev/null
+++ b/arch/powerpc/include/asm/word-at-a-time.h
@@ -0,0 +1,41 @@
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
11struct 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 */
18static 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
26static 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
34static 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 */