aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2008-10-24 10:53:33 -0400
committerH. Peter Anvin <hpa@zytor.com>2008-11-05 12:51:02 -0500
commit838e8bb71dc0c892bf8f84abd3c709d8fe3a8d3c (patch)
tree3cae439c32d1e046aba1f0cb6fa81aeed482a91c
parenta376f30a95a796cde81d6dffde0f5243c8bd8f92 (diff)
x86: Implement change_bit with immediate operand as "lock xorb"
Impact: Minor optimization. Implement change_bit with immediate bit count as "lock xorb". This is similar to "lock orb" and "lock andb" for set_bit and clear_bit functions. Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--arch/x86/include/asm/bitops.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
index 360010322711..9fa9dcdf344b 100644
--- a/arch/x86/include/asm/bitops.h
+++ b/arch/x86/include/asm/bitops.h
@@ -168,7 +168,15 @@ static inline void __change_bit(int nr, volatile unsigned long *addr)
168 */ 168 */
169static inline void change_bit(int nr, volatile unsigned long *addr) 169static inline void change_bit(int nr, volatile unsigned long *addr)
170{ 170{
171 asm volatile(LOCK_PREFIX "btc %1,%0" : ADDR : "Ir" (nr)); 171 if (IS_IMMEDIATE(nr)) {
172 asm volatile(LOCK_PREFIX "xorb %1,%0"
173 : CONST_MASK_ADDR(nr, addr)
174 : "iq" ((u8)CONST_MASK(nr)));
175 } else {
176 asm volatile(LOCK_PREFIX "btc %1,%0"
177 : BITOP_ADDR(addr)
178 : "Ir" (nr));
179 }
172} 180}
173 181
174/** 182/**