Changeset 04803bf in mainline for uspace/lib/c/arch/amd64/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/amd64/include/atomic.h (moved) (moved from uspace/lib/libc/arch/amd64/include/atomic.h ) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/arch/amd64/include/atomic.h
rb50b5af2 r04803bf 38 38 #define LIBC_amd64_ATOMIC_H_ 39 39 40 static inline void atomic_inc(atomic_t *val) { 41 asm volatile ("lock incq %0\n" : "+m" (val->count)); 40 #define LIBC_ARCH_ATOMIC_H_ 41 42 #include <atomicdflt.h> 43 44 static inline void atomic_inc(atomic_t *val) 45 { 46 asm volatile ( 47 "lock incq %[count]\n" 48 : [count] "+m" (val->count) 49 ); 42 50 } 43 51 44 static inline void atomic_dec(atomic_t *val) { 45 asm volatile ("lock decq %0\n" : "+m" (val->count)); 52 static inline void atomic_dec(atomic_t *val) 53 { 54 asm volatile ( 55 "lock decq %[count]\n" 56 : [count] "+m" (val->count) 57 ); 46 58 } 47 59 48 static inline long atomic_postinc(atomic_t *val)60 static inline atomic_count_t atomic_postinc(atomic_t *val) 49 61 { 50 long r; 51 52 asm volatile ( 53 "movq $1, %0\n" 54 "lock xaddq %0, %1\n" 55 : "=r" (r), "+m" (val->count) 56 ); 57 58 return r; 59 } 60 61 static inline long atomic_postdec(atomic_t *val) 62 { 63 long r; 62 atomic_count_t r = 1; 64 63 65 64 asm volatile ( 66 " movq $-1, %0\n"67 "lock xaddq %0, %1\n"68 : "=r" (r), "+m" (val->count)65 "lock xaddq %[r], %[count]\n" 66 : [count] "+m" (val->count), 67 [r] "+r" (r) 69 68 ); 70 69 … … 72 71 } 73 72 74 #define atomic_preinc(val) (atomic_postinc(val) + 1) 75 #define atomic_predec(val) (atomic_postdec(val) - 1) 73 static inline atomic_count_t atomic_postdec(atomic_t *val) 74 { 75 atomic_count_t r = -1; 76 77 asm volatile ( 78 "lock xaddq %[r], %[count]\n" 79 : [count] "+m" (val->count), 80 [r] "+r" (r) 81 ); 82 83 return r; 84 } 85 86 #define atomic_preinc(val) (atomic_postinc(val) + 1) 87 #define atomic_predec(val) (atomic_postdec(val) - 1) 76 88 77 89 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
