Changeset 04803bf in mainline for uspace/lib/c/arch/sparc64/include/atomic.h
- Timestamp:
- 2011-03-21T22:00:17Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 143932e3
- Parents:
- b50b5af2 (diff), 7308e84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 moved
-
uspace/lib/c/arch/sparc64/include/atomic.h (moved) (moved from uspace/lib/libc/arch/sparc64/include/atomic.h ) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/arch/sparc64/include/atomic.h
rb50b5af2 r04803bf 36 36 #define LIBC_sparc64_ATOMIC_H_ 37 37 38 #define LIBC_ARCH_ATOMIC_H_ 39 40 #include <atomicdflt.h> 38 41 #include <sys/types.h> 39 42 … … 43 46 * 44 47 * @param val Atomic variable. 45 * @param i Signed value to be added.48 * @param i Signed value to be added. 46 49 * 47 50 * @return Value of the atomic variable as it existed before addition. 51 * 48 52 */ 49 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) 50 54 { 51 uint64_t a, b; 52 55 atomic_count_t a; 56 atomic_count_t b; 57 53 58 do { 54 volatile uintptr_t x = (uint64_t) &val->count;55 56 a = *(( uint64_t *) x);59 volatile uintptr_t ptr = (uintptr_t) &val->count; 60 61 a = *((atomic_count_t *) ptr); 57 62 b = a + i; 58 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 ); 59 70 } while (a != b); 60 71 61 72 return a; 62 73 } 63 74 64 static inline longatomic_preinc(atomic_t *val)75 static inline atomic_count_t atomic_preinc(atomic_t *val) 65 76 { 66 77 return atomic_add(val, 1) + 1; 67 78 } 68 79 69 static inline longatomic_postinc(atomic_t *val)80 static inline atomic_count_t atomic_postinc(atomic_t *val) 70 81 { 71 82 return atomic_add(val, 1); 72 83 } 73 84 74 static inline longatomic_predec(atomic_t *val)85 static inline atomic_count_t atomic_predec(atomic_t *val) 75 86 { 76 87 return atomic_add(val, -1) - 1; 77 88 } 78 89 79 static inline longatomic_postdec(atomic_t *val)90 static inline atomic_count_t atomic_postdec(atomic_t *val) 80 91 { 81 92 return atomic_add(val, -1);
Note:
See TracChangeset
for help on using the changeset viewer.
