Changes in uspace/lib/c/arch/arm32/src/atomic.c [56210a7:3ffb69b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/arch/arm32/src/atomic.c
r56210a7 r3ffb69b 34 34 35 35 #include <stdbool.h> 36 #include "ras_page.h"37 36 38 37 volatile unsigned *ras_page; 39 38 40 bool __atomic_compare_exchange_4(volatile void *mem0, void *expected0, 41 unsigned desired, bool weak, int success, int failure) 39 bool __atomic_compare_exchange_4(volatile unsigned *mem, unsigned *expected, unsigned desired, bool weak, int success, int failure) 42 40 { 43 volatile unsigned *mem = mem0;44 unsigned *expected = expected0;45 46 41 (void) success; 47 42 (void) failure; … … 86 81 } 87 82 88 unsigned char __atomic_exchange_1(volatile void *mem0, unsigned char val, 89 int model) 83 unsigned short __atomic_fetch_add_2(volatile unsigned short *mem, unsigned short val, int model) 90 84 { 91 volatile unsigned char *mem = mem0;92 93 (void) model;94 95 unsigned ret;96 97 /*98 * The following instructions between labels 1 and 2 constitute a99 * Restartable Atomic Seqeunce. Should the sequence be non-atomic,100 * the kernel will restart it.101 */102 asm volatile (103 "1:\n"104 " adr %[ret], 1b\n"105 " str %[ret], %[rp0]\n"106 " adr %[ret], 2f\n"107 " str %[ret], %[rp1]\n"108 " ldrb %[ret], %[addr]\n"109 " strb %[imm], %[addr]\n"110 "2:\n"111 : [ret] "=&r" (ret),112 [rp0] "=m" (ras_page[0]),113 [rp1] "=m" (ras_page[1]),114 [addr] "+m" (*mem)115 : [imm] "r" (val)116 );117 118 ras_page[0] = 0;119 ras_page[1] = 0xffffffff;120 121 return ret;122 }123 124 unsigned short __atomic_exchange_2(volatile void *mem0, unsigned short val,125 int model)126 {127 volatile unsigned short *mem = mem0;128 129 (void) model;130 131 unsigned ret;132 133 /*134 * The following instructions between labels 1 and 2 constitute a135 * Restartable Atomic Seqeunce. Should the sequence be non-atomic,136 * the kernel will restart it.137 */138 asm volatile (139 "1:\n"140 " adr %[ret], 1b\n"141 " str %[ret], %[rp0]\n"142 " adr %[ret], 2f\n"143 " str %[ret], %[rp1]\n"144 " ldrh %[ret], %[addr]\n"145 " strh %[imm], %[addr]\n"146 "2:\n"147 : [ret] "=&r" (ret),148 [rp0] "=m" (ras_page[0]),149 [rp1] "=m" (ras_page[1]),150 [addr] "+m" (*mem)151 : [imm] "r" (val)152 );153 154 ras_page[0] = 0;155 ras_page[1] = 0xffffffff;156 157 return ret;158 }159 160 unsigned __atomic_exchange_4(volatile void *mem0, unsigned val, int model)161 {162 volatile unsigned *mem = mem0;163 164 (void) model;165 166 unsigned ret;167 168 /*169 * The following instructions between labels 1 and 2 constitute a170 * Restartable Atomic Seqeunce. Should the sequence be non-atomic,171 * the kernel will restart it.172 */173 asm volatile (174 "1:\n"175 " adr %[ret], 1b\n"176 " str %[ret], %[rp0]\n"177 " adr %[ret], 2f\n"178 " str %[ret], %[rp1]\n"179 " ldr %[ret], %[addr]\n"180 " str %[imm], %[addr]\n"181 "2:\n"182 : [ret] "=&r" (ret),183 [rp0] "=m" (ras_page[0]),184 [rp1] "=m" (ras_page[1]),185 [addr] "+m" (*mem)186 : [imm] "r" (val)187 );188 189 ras_page[0] = 0;190 ras_page[1] = 0xffffffff;191 192 return ret;193 }194 195 unsigned short __atomic_fetch_add_2(volatile void *mem0, unsigned short val,196 int model)197 {198 volatile unsigned short *mem = mem0;199 200 85 (void) model; 201 86 … … 230 115 } 231 116 232 unsigned __atomic_fetch_add_4(volatile void *mem0, unsigned val, int model)117 unsigned __atomic_fetch_add_4(volatile unsigned *mem, unsigned val, int model) 233 118 { 234 volatile unsigned *mem = mem0;235 236 119 (void) model; 237 120 … … 266 149 } 267 150 268 unsigned __atomic_fetch_sub_4(volatile void *mem, unsigned val, int model)151 unsigned __atomic_fetch_sub_4(volatile unsigned *mem, unsigned val, int model) 269 152 { 270 153 return __atomic_fetch_add_4(mem, -val, model); 271 }272 273 bool __atomic_test_and_set(volatile void *ptr, int memorder)274 {275 volatile unsigned char *b = ptr;276 277 unsigned char orig = __atomic_exchange_n(b, (unsigned char) true, memorder);278 return orig != 0;279 154 } 280 155
Note:
See TracChangeset
for help on using the changeset viewer.