Changes in kernel/arch/sparc64/include/atomic.h [228666c:986c24c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/include/atomic.h
r228666c r986c24c 27 27 */ 28 28 29 /** @addtogroup sparc64 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 45 45 * 46 46 * @param val Atomic variable. 47 * @param i 47 * @param i Signed value to be added. 48 48 * 49 49 * @return Value of the atomic variable as it existed before addition. 50 *51 50 */ 52 static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i)51 static inline long atomic_add(atomic_t *val, int i) 53 52 { 54 atomic_count_t a; 55 atomic_count_t b; 56 53 uint64_t a, b; 54 57 55 do { 58 volatile uintptr_t ptr = (uintptr_t) &val->count;59 60 a = *(( atomic_count_t *) ptr);56 volatile uintptr_t x = (uint64_t) &val->count; 57 58 a = *((uint64_t *) x); 61 59 b = a + i; 62 63 asm volatile ( 64 "casx %0, %2, %1\n" 65 : "+m" (*((atomic_count_t *) ptr)), 66 "+r" (b) 67 : "r" (a) 68 ); 60 asm volatile ("casx %0, %2, %1\n" : "+m" (*((uint64_t *)x)), 61 "+r" (b) : "r" (a)); 69 62 } while (a != b); 70 63 71 64 return a; 72 65 } 73 66 74 static inline atomic_count_tatomic_preinc(atomic_t *val)67 static inline long atomic_preinc(atomic_t *val) 75 68 { 76 69 return atomic_add(val, 1) + 1; 77 70 } 78 71 79 static inline atomic_count_tatomic_postinc(atomic_t *val)72 static inline long atomic_postinc(atomic_t *val) 80 73 { 81 74 return atomic_add(val, 1); 82 75 } 83 76 84 static inline atomic_count_tatomic_predec(atomic_t *val)77 static inline long atomic_predec(atomic_t *val) 85 78 { 86 79 return atomic_add(val, -1) - 1; 87 80 } 88 81 89 static inline atomic_count_tatomic_postdec(atomic_t *val)82 static inline long atomic_postdec(atomic_t *val) 90 83 { 91 84 return atomic_add(val, -1); … … 102 95 } 103 96 104 static inline atomic_count_ttest_and_set(atomic_t *val)97 static inline long test_and_set(atomic_t *val) 105 98 { 106 atomic_count_t v = 1; 107 volatile uintptr_t ptr = (uintptr_t) &val->count; 108 109 asm volatile ( 110 "casx %0, %2, %1\n" 111 : "+m" (*((atomic_count_t *) ptr)), 112 "+r" (v) 113 : "r" (0) 114 ); 115 99 uint64_t v = 1; 100 volatile uintptr_t x = (uint64_t) &val->count; 101 102 asm volatile ("casx %0, %2, %1\n" : "+m" (*((uint64_t *) x)), 103 "+r" (v) : "r" (0)); 104 116 105 return v; 117 106 } … … 119 108 static inline void atomic_lock_arch(atomic_t *val) 120 109 { 121 atomic_count_t tmp1 = 1;122 atomic_count_t tmp2 = 0;123 124 volatile uintptr_t ptr = (uintptr_t) &val->count;125 110 uint64_t tmp1 = 1; 111 uint64_t tmp2 = 0; 112 113 volatile uintptr_t x = (uint64_t) &val->count; 114 126 115 preemption_disable(); 127 116 128 117 asm volatile ( 129 "0:\n" 130 "casx %0, %3, %1\n" 131 "brz %1, 2f\n" 132 "nop\n" 133 "1:\n" 134 "ldx %0, %2\n" 135 "brz %2, 0b\n" 136 "nop\n" 137 "ba %%xcc, 1b\n" 138 "nop\n" 139 "2:\n" 140 : "+m" (*((atomic_count_t *) ptr)), 141 "+r" (tmp1), 142 "+r" (tmp2) 143 : "r" (0) 118 "0:\n" 119 "casx %0, %3, %1\n" 120 "brz %1, 2f\n" 121 "nop\n" 122 "1:\n" 123 "ldx %0, %2\n" 124 "brz %2, 0b\n" 125 "nop\n" 126 "ba %%xcc, 1b\n" 127 "nop\n" 128 "2:\n" 129 : "+m" (*((uint64_t *) x)), "+r" (tmp1), "+r" (tmp2) : "r" (0) 144 130 ); 145 131
Note:
See TracChangeset
for help on using the changeset viewer.