mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 08:06:17 +04:00
Add impl of atomic_fetch_*
This commit is contained in:
parent
0680023e35
commit
95ab9caba1
@ -46,4 +46,16 @@ char __atomic_compare_exchange_4(int* dst, int* expected, int desired) {
|
||||
return sc_ret == 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…
Reference in New Issue
Block a user