mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-03 01:12:53 +00:00
Add atomic multiply and divide operations, built on top of CompareAndSwap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74004 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
343beeb386
commit
e0fa0b42b2
@ -27,6 +27,8 @@ namespace llvm {
|
||||
cas_flag AtomicIncrement(volatile cas_flag* ptr);
|
||||
cas_flag AtomicDecrement(volatile cas_flag* ptr);
|
||||
cas_flag AtomicAdd(volatile cas_flag* ptr, cas_flag val);
|
||||
cas_flag AtomicMul(volatile cas_flag* ptr, cas_flag val);
|
||||
cas_flag AtomicDiv(volatile cas_flag* ptr, cas_flag val);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,4 +91,22 @@ sys::cas_flag sys::AtomicAdd(volatile sys::cas_flag* ptr, sys::cas_flag val) {
|
||||
#endif
|
||||
}
|
||||
|
||||
sys::cas_flag sys::AtomicMul(volatile sys::cas_flag* ptr, sys::cas_flag val) {
|
||||
sys::cas_flag original, result;
|
||||
do {
|
||||
original = *ptr;
|
||||
result = original * val;
|
||||
} while (sys::CompareAndSwap(ptr, result, original) != original);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
sys::cas_flag sys::AtomicDiv(volatile sys::cas_flag* ptr, sys::cas_flag val) {
|
||||
sys::cas_flag original, result;
|
||||
do {
|
||||
original = *ptr;
|
||||
result = original / val;
|
||||
} while (sys::CompareAndSwap(ptr, result, original) != original);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user