Changes in uspace/lib/libc/arch/sparc64/include/atomic.h [e15e0e8:228666c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/arch/sparc64/include/atomic.h
re15e0e8 r228666c 46 46 * 47 47 * @param val Atomic variable. 48 * @param i Signed value to be added.48 * @param i Signed value to be added. 49 49 * 50 50 * @return Value of the atomic variable as it existed before addition. 51 * 51 52 */ 52 static inline long atomic_add(atomic_t *val, int i)53 static inline atomic_count_t atomic_add(atomic_t *val, atomic_count_t i) 53 54 { 54 uint64_t a, b; 55 55 atomic_count_t a; 56 atomic_count_t b; 57 56 58 do { 57 volatile uintptr_t x = (uint64_t) &val->count;58 59 a = *(( uint64_t *) x);59 volatile uintptr_t ptr = (uintptr_t) &val->count; 60 61 a = *((atomic_count_t *) ptr); 60 62 b = a + i; 61 asm volatile ("casx %0, %2, %1\n" : "+m" (*((uint64_t *)x)), "+r" (b) : "r" (a)); 63 64 asm volatile ( 65 "casx %0, %2, %1\n" 66 : "+m" (*((atomic_count_t *) ptr)), 67 "+r" (b) 68 : "r" (a) 69 ); 62 70 } while (a != b); 63 71 64 72 return a; 65 73 } 66 74 67 static inline longatomic_preinc(atomic_t *val)75 static inline atomic_count_t atomic_preinc(atomic_t *val) 68 76 { 69 77 return atomic_add(val, 1) + 1; 70 78 } 71 79 72 static inline longatomic_postinc(atomic_t *val)80 static inline atomic_count_t atomic_postinc(atomic_t *val) 73 81 { 74 82 return atomic_add(val, 1); 75 83 } 76 84 77 static inline longatomic_predec(atomic_t *val)85 static inline atomic_count_t atomic_predec(atomic_t *val) 78 86 { 79 87 return atomic_add(val, -1) - 1; 80 88 } 81 89 82 static inline longatomic_postdec(atomic_t *val)90 static inline atomic_count_t atomic_postdec(atomic_t *val) 83 91 { 84 92 return atomic_add(val, -1);
Note:
See TracChangeset
for help on using the changeset viewer.