mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +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