History

Make <asm-x86/spinlock.h> use ACCESS_ONCE()

..instead of cooking up its own uglier local version of it.

Linus Torvalds committed 18 years ago

Commit 39f004b1 parent 9c3cdc11 file · +4 −14Browse files

Unified · Split

include/asm-x86/spinlock.h+4−14
@@ -20,18 +20,8 @@ · 19 unmodified lines
2020 */
2121
2222 #ifdef CONFIG_X86_32
23−typedef char _slock_t;
24−# define LOCK_INS_DEC "decb"
25−# define LOCK_INS_XCH "xchgb"
26−# define LOCK_INS_MOV "movb"
27−# define LOCK_INS_CMP "cmpb"
2823 # define LOCK_PTR_REG "a"
2924 #else
30−typedef int _slock_t;
31−# define LOCK_INS_DEC "decl"
32−# define LOCK_INS_XCH "xchgl"
33−# define LOCK_INS_MOV "movl"
34−# define LOCK_INS_CMP "cmpl"
3525 # define LOCK_PTR_REG "D"
3626 #endif
3727
@@ -66,14 +56,14 @@ typedef int _slock_t; · 28 unmodified lines
6656 #if (NR_CPUS < 256)
6757 static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
6858 {
69− int tmp = *(volatile signed int *)(&(lock)->slock);
59+ int tmp = ACCESS_ONCE(lock->slock);
7060
7161 return (((tmp >> 8) & 0xff) != (tmp & 0xff));
7262 }
7363
7464 static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
7565 {
76− int tmp = *(volatile signed int *)(&(lock)->slock);
66+ int tmp = ACCESS_ONCE(lock->slock);
7767
7868 return (((tmp >> 8) & 0xff) - (tmp & 0xff)) > 1;
7969 }
@@ -130,14 +120,14 @@ static __always_inline void __raw_spin_unlock(raw_spinlock_t *lock) · 50 unmodified lines
130120 #else
131121 static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
132122 {
133− int tmp = *(volatile signed int *)(&(lock)->slock);
123+ int tmp = ACCESS_ONCE(lock->slock);
134124
135125 return (((tmp >> 16) & 0xffff) != (tmp & 0xffff));
136126 }
137127
138128 static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
139129 {
140− int tmp = *(volatile signed int *)(&(lock)->slock);
130+ int tmp = ACCESS_ONCE(lock->slock);
141131
142132 return (((tmp >> 16) & 0xffff) - (tmp & 0xffff)) > 1;
143133 }