diff options
author | H. Peter Anvin <hpa@zytor.com> | 2016-06-08 15:38:38 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2016-06-08 15:41:20 -0400 |
commit | 117780eef7740729e803bdcc0d5f2f48137ea8e3 (patch) | |
tree | 63bd519e1d8b115d332fcb6e63ee4f94ee235161 /arch/x86/boot/bitops.h | |
parent | 2823d4da5d8a0c222747b24eceb65f5b30717d02 (diff) |
x86, asm: use bool for bitops and other assembly outputs
The gcc people have confirmed that using "bool" when combined with
inline assembly always is treated as a byte-sized operand that can be
assumed to be 0 or 1, which is exactly what the SET instruction
emits. Change the output types and intermediate variables of as many
operations as practical to "bool".
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Link: http://lkml.kernel.org/r/1465414726-197858-3-git-send-email-hpa@linux.intel.com
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Borislav Petkov <bp@suse.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Diffstat (limited to 'arch/x86/boot/bitops.h')
-rw-r--r-- | arch/x86/boot/bitops.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h index 878e4b9940d9..0d41d68131cc 100644 --- a/arch/x86/boot/bitops.h +++ b/arch/x86/boot/bitops.h | |||
@@ -16,14 +16,16 @@ | |||
16 | #define BOOT_BITOPS_H | 16 | #define BOOT_BITOPS_H |
17 | #define _LINUX_BITOPS_H /* Inhibit inclusion of <linux/bitops.h> */ | 17 | #define _LINUX_BITOPS_H /* Inhibit inclusion of <linux/bitops.h> */ |
18 | 18 | ||
19 | static inline int constant_test_bit(int nr, const void *addr) | 19 | #include <linux/types.h> |
20 | |||
21 | static inline bool constant_test_bit(int nr, const void *addr) | ||
20 | { | 22 | { |
21 | const u32 *p = (const u32 *)addr; | 23 | const u32 *p = (const u32 *)addr; |
22 | return ((1UL << (nr & 31)) & (p[nr >> 5])) != 0; | 24 | return ((1UL << (nr & 31)) & (p[nr >> 5])) != 0; |
23 | } | 25 | } |
24 | static inline int variable_test_bit(int nr, const void *addr) | 26 | static inline bool variable_test_bit(int nr, const void *addr) |
25 | { | 27 | { |
26 | u8 v; | 28 | bool v; |
27 | const u32 *p = (const u32 *)addr; | 29 | const u32 *p = (const u32 *)addr; |
28 | 30 | ||
29 | asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr)); | 31 | asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr)); |