Changes in kernel/arch/arm32/include/atomic.h [7a0359b:e762b43] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/include/atomic.h
r7a0359b re762b43 37 37 #define KERN_arm32_ATOMIC_H_ 38 38 39 #include <arch/asm.h>40 #include <trace.h>41 42 39 /** Atomic addition. 43 40 * … … 48 45 * 49 46 */ 50 NO_TRACE static inline atomic_count_t atomic_add(atomic_t *val, 51 atomic_count_t i) 47 static inline long atomic_add(atomic_t *val, int i) 52 48 { 53 /* 54 * This implementation is for UP pre-ARMv6 systems where we do not have 55 * the LDREX and STREX instructions. 56 */ 57 ipl_t ipl = interrupts_disable(); 58 val->count += i; 59 atomic_count_t ret = val->count; 60 interrupts_restore(ipl); 49 int ret; 50 volatile long *mem = &(val->count); 51 52 asm volatile ( 53 "1:\n" 54 "ldr r2, [%[mem]]\n" 55 "add r3, r2, %[i]\n" 56 "str r3, %[ret]\n" 57 "swp r3, r3, [%[mem]]\n" 58 "cmp r3, r2\n" 59 "bne 1b\n" 60 : [ret] "=m" (ret) 61 : [mem] "r" (mem), [i] "r" (i) 62 : "r3", "r2" 63 ); 61 64 62 65 return ret; … … 66 69 * 67 70 * @param val Variable to be incremented. 68 *69 71 */ 70 NO_TRACEstatic inline void atomic_inc(atomic_t *val)72 static inline void atomic_inc(atomic_t *val) 71 73 { 72 74 atomic_add(val, 1); … … 76 78 * 77 79 * @param val Variable to be decremented. 78 *79 80 */ 80 NO_TRACEstatic inline void atomic_dec(atomic_t *val) {81 static inline void atomic_dec(atomic_t *val) { 81 82 atomic_add(val, -1); 82 83 } … … 86 87 * @param val Variable to be incremented. 87 88 * @return Value after incrementation. 88 *89 89 */ 90 NO_TRACE static inline atomic_count_tatomic_preinc(atomic_t *val)90 static inline long atomic_preinc(atomic_t *val) 91 91 { 92 92 return atomic_add(val, 1); … … 97 97 * @param val Variable to be decremented. 98 98 * @return Value after decrementation. 99 *100 99 */ 101 NO_TRACE static inline atomic_count_tatomic_predec(atomic_t *val)100 static inline long atomic_predec(atomic_t *val) 102 101 { 103 102 return atomic_add(val, -1); … … 108 107 * @param val Variable to be incremented. 109 108 * @return Value before incrementation. 110 *111 109 */ 112 NO_TRACE static inline atomic_count_tatomic_postinc(atomic_t *val)110 static inline long atomic_postinc(atomic_t *val) 113 111 { 114 112 return atomic_add(val, 1) - 1; … … 119 117 * @param val Variable to be decremented. 120 118 * @return Value before decrementation. 121 *122 119 */ 123 NO_TRACE static inline atomic_count_tatomic_postdec(atomic_t *val)120 static inline long atomic_postdec(atomic_t *val) 124 121 { 125 122 return atomic_add(val, -1) + 1;
Note:
See TracChangeset
for help on using the changeset viewer.