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