Add impl of atomic_fetch_*

master
WangRunji 6 years ago
parent 0680023e35
commit 95ab9caba1

@ -46,4 +46,16 @@ char __atomic_compare_exchange_4(int* dst, int* expected, int desired) {
return sc_ret == 0; return sc_ret == 0;
} }
return 0; return 0;
}
int __atomic_fetch_add_4(int* ptr, int val) {
int res;
__asm__ __volatile__("amoadd.w.rl %0, %1, (%2)" : "=r"(res) : "r"(val), "r"(ptr) : "memory");
return res;
}
int __atomic_fetch_sub_4(int* ptr, int val) {
int res;
__asm__ __volatile__("amoadd.w.rl %0, %1, (%2)" : "=r"(res) : "r"(-val), "r"(ptr) : "memory");
return res;
} }
Loading…
Cancel
Save