Changeset 320762a in mainline for kernel/arch/arm32/src/atomic.c
- Timestamp:
- 2023-08-02T14:54:45Z (16 months ago)
- Branches:
- ticket/834-toolchain-update
- Children:
- 29941ab
- Parents:
- e1d93e3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/atomic.c
re1d93e3 r320762a 38 38 #include <arch/asm.h> 39 39 40 unsigned __atomic_fetch_add_4(volatile unsigned *mem, unsigned val, int model)40 unsigned __atomic_fetch_add_4(volatile void *mem, unsigned val, int model) 41 41 { 42 42 /* … … 45 45 */ 46 46 ipl_t ipl = interrupts_disable(); 47 unsigned ret = * mem;48 * mem+= val;47 unsigned ret = *((volatile unsigned *)mem); 48 *((volatile unsigned *)mem) += val; 49 49 interrupts_restore(ipl); 50 50 return ret; 51 51 } 52 52 53 unsigned __atomic_fetch_sub_4(volatile unsigned *mem, unsigned val, int model)53 unsigned __atomic_fetch_sub_4(volatile void *mem, unsigned val, int model) 54 54 { 55 55 ipl_t ipl = interrupts_disable(); 56 unsigned ret = * mem;57 * mem-= val;56 unsigned ret = *((volatile unsigned *)mem); 57 *((volatile unsigned *)mem) -= val; 58 58 interrupts_restore(ipl); 59 59 return ret; … … 67 67 * returns the previous value of \a *ptr. 68 68 */ 69 void *__sync_val_compare_and_swap_4(void **ptr, void *expected, void *new_val)69 unsigned __sync_val_compare_and_swap_4(volatile void *ptr, unsigned expected, unsigned new_val) 70 70 { 71 71 /* … … 78 78 irq_spinlock_lock(&cas_lock, true); 79 79 80 void *cur_val = *ptr;80 unsigned cur_val = *((volatile unsigned *)ptr); 81 81 82 82 if (cur_val == expected) { 83 * ptr= new_val;83 *((volatile unsigned *)ptr) = new_val; 84 84 } 85 85 … … 96 96 /* Naive implementations of the newer intrinsics. */ 97 97 98 _Bool __atomic_compare_exchange_4(vo id **mem, void **expected, void *desired, _Bool weak, int success, int failure)98 _Bool __atomic_compare_exchange_4(volatile void *mem, void *expected, unsigned desired, _Bool weak, int success, int failure) 99 99 { 100 100 (void) weak; … … 102 102 (void) failure; 103 103 104 void *old = *expected;105 void *new = __sync_val_compare_and_swap_4(mem, old, desired);104 unsigned old = *((unsigned *)expected); 105 unsigned new = __sync_val_compare_and_swap_4(mem, old, desired); 106 106 if (old == new) { 107 107 return 1; 108 108 } else { 109 * expected= new;109 *((unsigned *)expected) = new; 110 110 return 0; 111 111 } 112 112 } 113 113 114 void *__atomic_exchange_4(void **mem, void *val, int model)114 unsigned __atomic_exchange_4(volatile void *mem, unsigned val, int model) 115 115 { 116 116 (void) model; 117 117 118 118 irq_spinlock_lock(&cas_lock, true); 119 void *old = *mem;120 * mem= val;119 unsigned old = *((unsigned *)mem); 120 *((unsigned *)mem) = val; 121 121 irq_spinlock_unlock(&cas_lock, true); 122 122
Note:
See TracChangeset
for help on using the changeset viewer.