aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System/Atomic.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-06-23 17:39:31 +0000
committerOwen Anderson <resistor@mac.com>2009-06-23 17:39:31 +0000
commit485a07612a57a2d4a7ddc6da6f4a12391bdaf793 (patch)
treedef143fec6c5f9440ec541ed7058cf551be413b1 /lib/System/Atomic.cpp
parent1b2ea53c7c27b3bd6c6a133e3e7d52c97607f593 (diff)
downloadexternal_llvm-485a07612a57a2d4a7ddc6da6f4a12391bdaf793.zip
external_llvm-485a07612a57a2d4a7ddc6da6f4a12391bdaf793.tar.gz
external_llvm-485a07612a57a2d4a7ddc6da6f4a12391bdaf793.tar.bz2
Add an atomic add operation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73964 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Atomic.cpp')
-rw-r--r--lib/System/Atomic.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/System/Atomic.cpp b/lib/System/Atomic.cpp
index 416f981..6e751a3 100644
--- a/lib/System/Atomic.cpp
+++ b/lib/System/Atomic.cpp
@@ -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
+}
+