Changeset 320762a in mainline
- Timestamp:
- 2023-08-02T14:54:45Z (16 months ago)
- Branches:
- ticket/834-toolchain-update
- Children:
- 29941ab
- Parents:
- e1d93e3
- Files:
-
- 2 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 -
uspace/lib/c/arch/arm32/src/atomic.c
re1d93e3 r320762a 38 38 volatile unsigned *ras_page; 39 39 40 bool __atomic_compare_exchange_4(volatile unsigned *mem, unsigned *expected, unsigned desired, bool weak, int success, int failure)40 bool __atomic_compare_exchange_4(volatile void *mem, void *expected, unsigned desired, bool weak, int success, int failure) 41 41 { 42 42 (void) success; … … 44 44 (void) weak; 45 45 46 unsigned ov = * expected;46 unsigned ov = *((unsigned *)expected); 47 47 unsigned ret; 48 48 … … 66 66 [rp0] "=m" (ras_page[0]), 67 67 [rp1] "=m" (ras_page[1]), 68 [addr] "+m" (* mem)68 [addr] "+m" (*((unsigned *)mem)) 69 69 : [ov] "r" (ov), 70 70 [nv] "r" (desired) … … 78 78 return true; 79 79 80 * expected= ret;80 *((unsigned *)expected) = ret; 81 81 return false; 82 82 } 83 83 84 unsigned short __atomic_fetch_add_2(volatile unsigned short*mem, unsigned short val, int model)84 unsigned short __atomic_fetch_add_2(volatile void *mem, unsigned short val, int model) 85 85 { 86 86 (void) model; … … 106 106 [rp0] "=m" (ras_page[0]), 107 107 [rp1] "=m" (ras_page[1]), 108 [addr] "+m" (* mem)108 [addr] "+m" (*((volatile unsigned short *)mem)) 109 109 : [imm] "r" (val) 110 110 ); … … 116 116 } 117 117 118 unsigned __atomic_fetch_add_4(volatile unsigned *mem, unsigned val, int model)118 unsigned __atomic_fetch_add_4(volatile void *mem, unsigned val, int model) 119 119 { 120 120 (void) model; … … 140 140 [rp0] "=m" (ras_page[0]), 141 141 [rp1] "=m" (ras_page[1]), 142 [addr] "+m" (* mem)142 [addr] "+m" (*((volatile unsigned *)mem)) 143 143 : [imm] "r" (val) 144 144 ); … … 150 150 } 151 151 152 unsigned __atomic_fetch_sub_4(volatile unsigned *mem, unsigned val, int model)152 unsigned __atomic_fetch_sub_4(volatile void *mem, unsigned val, int model) 153 153 { 154 154 return __atomic_fetch_add_4(mem, -val, model);
Note:
See TracChangeset
for help on using the changeset viewer.