]> Pileus Git - ~andy/linux/blob - arch/arm64/include/asm/word-at-a-time.h
arm64: use generic strnlen_user and strncpy_from_user functions
[~andy/linux] / arch / arm64 / include / asm / word-at-a-time.h
1 /*
2  * Copyright (C) 2013 ARM Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  */
16 #ifndef __ASM_WORD_AT_A_TIME_H
17 #define __ASM_WORD_AT_A_TIME_H
18
19 #ifndef __AARCH64EB__
20
21 #include <linux/kernel.h>
22
23 struct word_at_a_time {
24         const unsigned long one_bits, high_bits;
25 };
26
27 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
28
29 static inline unsigned long has_zero(unsigned long a, unsigned long *bits,
30                                      const struct word_at_a_time *c)
31 {
32         unsigned long mask = ((a - c->one_bits) & ~a) & c->high_bits;
33         *bits = mask;
34         return mask;
35 }
36
37 #define prep_zero_mask(a, bits, c) (bits)
38
39 static inline unsigned long create_zero_mask(unsigned long bits)
40 {
41         bits = (bits - 1) & ~bits;
42         return bits >> 7;
43 }
44
45 static inline unsigned long find_zero(unsigned long mask)
46 {
47         return fls64(mask) >> 3;
48 }
49
50 #else   /* __AARCH64EB__ */
51 #include <asm-generic/word-at-a-time.h>
52 #endif
53
54 #endif /* __ASM_WORD_AT_A_TIME_H */