summaryrefslogtreecommitdiffstats
path: root/contrib/libcxxrt/atomic.h
diff options
context:
space:
mode:
authortheraven <theraven@FreeBSD.org>2013-01-11 15:05:55 +0000
committertheraven <theraven@FreeBSD.org>2013-01-11 15:05:55 +0000
commitf8a3c6151f84669a265d291556c626e90b92b208 (patch)
tree714345d8e051db9af44b11c7c3f9f9ee2bef18d1 /contrib/libcxxrt/atomic.h
parent607c3680d90935ee21ad3e58fdd171d15ebb3284 (diff)
parente8f1f5bd311be550e3041d55f84c95d7b5990797 (diff)
downloadFreeBSD-src-f8a3c6151f84669a265d291556c626e90b92b208.zip
FreeBSD-src-f8a3c6151f84669a265d291556c626e90b92b208.tar.gz
Merge new version of libcxxrt. This brings in three fixes:
- Don't treat pointers to members as pointers in catch blocks (they're usually fat pointers). - Correctly catch foreign exceptions in catchalls. - Ensure that a happens-before relationship is established when setting terminate handlers in one thread and calling them in another.
Diffstat (limited to 'contrib/libcxxrt/atomic.h')
-rw-r--r--contrib/libcxxrt/atomic.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/contrib/libcxxrt/atomic.h b/contrib/libcxxrt/atomic.h
new file mode 100644
index 0000000..bcd8a47
--- /dev/null
+++ b/contrib/libcxxrt/atomic.h
@@ -0,0 +1,29 @@
+
+#ifndef __has_builtin
+#define __has_builtin(x) 0
+#endif
+#ifndef __has_feature
+#define __has_feature(x) 0
+#endif
+/**
+ * Swap macro that enforces a happens-before relationship with a corresponding
+ * ATOMIC_LOAD.
+ */
+#if __has_feature(cxx_atomic)
+#define ATOMIC_SWAP(addr, val)\
+ __atomic_exchange(addr, val, __ATOMIC_ACQ_REL)
+#elif __has_builtin(__sync_swap)
+#define ATOMIC_SWAP(addr, val)\
+ __sync_swap(addr, val)
+#else
+#define ATOMIC_SWAP(addr, val)\
+ __sync_lock_test_and_set(addr, val)
+#endif
+
+#if __has_feature(cxx_atomic)
+#define ATOMIC_LOAD(addr)\
+ __atomic_load(addr, __ATOMIC_ACQUIRE)
+#else
+#define ATOMIC_LOAD(addr)\
+ (__sync_synchronize(), *addr)
+#endif
OpenPOWER on IntegriCloud