mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-22 10:29:35 +00:00
Add an atomic add operation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73964 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3b8d135879
commit
5a9c0eeaf2
@ -26,6 +26,7 @@ namespace llvm {
|
||||
cas_flag old_value);
|
||||
cas_flag AtomicIncrement(volatile cas_flag* ptr);
|
||||
cas_flag AtomicDecrement(volatile cas_flag* ptr);
|
||||
cas_flag AtomicAdd(volatile cas_flag* ptr, cas_flag val);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,4 +78,17 @@ sys::cas_flag sys::AtomicDecrement(volatile sys::cas_flag* ptr) {
|
||||
#endif
|
||||
}
|
||||
|
||||
sys::cas_flag sys::AtomicAdd(volatile sys::cas_flag* ptr, sys::cas_flag val) {
|
||||
#if LLVM_MULTITHREADED==0
|
||||
*ptr += val;
|
||||
return *ptr;
|
||||
#elif defined(__GNUC__)
|
||||
return __sync_add_and_fetch(ptr, val);
|
||||
#elif defined(_MSC_VER)
|
||||
return InterlockedAdd(ptr, val);
|
||||
#else
|
||||
# error No atomic add implementation for your platform!
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user