Changes in kernel/arch/abs32le/include/atomic.h [b03a666:50fda24] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/abs32le/include/atomic.h
rb03a666 r50fda24 54 54 } 55 55 56 static inline atomic_count_tatomic_postinc(atomic_t *val)56 static inline long atomic_postinc(atomic_t *val) 57 57 { 58 58 /* On real hardware both the storing of the previous … … 60 60 atomic action. */ 61 61 62 atomic_count_tprev = val->count;62 long prev = val->count; 63 63 64 64 val->count++; … … 66 66 } 67 67 68 static inline atomic_count_tatomic_postdec(atomic_t *val)68 static inline long atomic_postdec(atomic_t *val) 69 69 { 70 70 /* On real hardware both the storing of the previous … … 72 72 atomic action. */ 73 73 74 atomic_count_tprev = val->count;74 long prev = val->count; 75 75 76 76 val->count--; … … 81 81 #define atomic_predec(val) (atomic_postdec(val) - 1) 82 82 83 static inline atomic_count_t test_and_set(atomic_t *val) 84 { 85 atomic_count_t prev = val->count; 86 val->count = 1; 87 return prev; 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; 88 93 } 89 94 95 /** ia32 specific fast spinlock */ 90 96 static inline void atomic_lock_arch(atomic_t *val) 91 97 { 92 do { 93 while (val->count); 94 } while (test_and_set(val)); 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(); 95 118 } 96 119
Note:
See TracChangeset
for help on using the changeset viewer.