vfs: Make __vfs_write() static
[linux/fpc-iii.git] / arch / x86 / include / asm / arch_hweight.h
blobfc0693569f7aae7baebcf8c6606ce66c09af701e
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_HWEIGHT_H
3 #define _ASM_X86_HWEIGHT_H
5 #include <asm/cpufeatures.h>
7 #ifdef CONFIG_64BIT
8 #define REG_IN "D"
9 #define REG_OUT "a"
10 #else
11 #define REG_IN "a"
12 #define REG_OUT "a"
13 #endif
15 #define __HAVE_ARCH_SW_HWEIGHT
17 static __always_inline unsigned int __arch_hweight32(unsigned int w)
19 unsigned int res;
21 asm (ALTERNATIVE("call __sw_hweight32", "popcntl %1, %0", X86_FEATURE_POPCNT)
22 : "="REG_OUT (res)
23 : REG_IN (w));
25 return res;
28 static inline unsigned int __arch_hweight16(unsigned int w)
30 return __arch_hweight32(w & 0xffff);
33 static inline unsigned int __arch_hweight8(unsigned int w)
35 return __arch_hweight32(w & 0xff);
38 #ifdef CONFIG_X86_32
39 static inline unsigned long __arch_hweight64(__u64 w)
41 return __arch_hweight32((u32)w) +
42 __arch_hweight32((u32)(w >> 32));
44 #else
45 static __always_inline unsigned long __arch_hweight64(__u64 w)
47 unsigned long res;
49 asm (ALTERNATIVE("call __sw_hweight64", "popcntq %1, %0", X86_FEATURE_POPCNT)
50 : "="REG_OUT (res)
51 : REG_IN (w));
53 return res;
55 #endif /* CONFIG_X86_32 */
57 #endif