Changeset fb52db8 in mainline for kernel/arch/abs32le/include/atomic.h
- Timestamp:
- 2010-02-16T16:41:32Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dfecf88
- Parents:
- 5ee2384
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/abs32le/include/atomic.h
r5ee2384 rfb52db8 81 81 #define atomic_predec(val) (atomic_postdec(val) - 1) 82 82 83 static inline uint32_t test_and_set(atomic_t *val) { 84 uint32_t v; 85 86 asm volatile ( 87 "movl $1, %[v]\n" 88 "xchgl %[v], %[count]\n" 89 : [v] "=r" (v), [count] "+m" (val->count) 90 ); 91 92 return v; 83 static inline uint32_t test_and_set(atomic_t *val) 84 { 85 uint32_t prev = val->count; 86 val->count = 1; 87 return prev; 93 88 } 94 89 95 /** ia32 specific fast spinlock */96 90 static inline void atomic_lock_arch(atomic_t *val) 97 91 { 98 uint32_t tmp; 99 100 preemption_disable(); 101 asm volatile ( 102 "0:\n" 103 "pause\n" /* Pentium 4's HT love this instruction */ 104 "mov %[count], %[tmp]\n" 105 "testl %[tmp], %[tmp]\n" 106 "jnz 0b\n" /* lightweight looping on locked spinlock */ 107 108 "incl %[tmp]\n" /* now use the atomic operation */ 109 "xchgl %[count], %[tmp]\n" 110 "testl %[tmp], %[tmp]\n" 111 "jnz 0b\n" 112 : [count] "+m" (val->count), [tmp] "=&r" (tmp) 113 ); 114 /* 115 * Prevent critical section code from bleeding out this way up. 116 */ 117 CS_ENTER_BARRIER(); 92 do { 93 while (val->count); 94 } while (test_and_set(val)); 118 95 } 119 96
Note:
See TracChangeset
for help on using the changeset viewer.