summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/builtins/atomic_flag_test_and_set_explicit.c
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2015-05-08 05:39:05 +0000
committerJustin Bogner <mail@justinbogner.com>2015-05-08 05:39:05 +0000
commitfa7525935bd91a4a537d3a7527ec999531536c22 (patch)
tree2ba1fbfb3d83f644b64042ac3419534cc5dd2c6d /compiler-rt/lib/builtins/atomic_flag_test_and_set_explicit.c
parent1cf6c28a9c0c507a224889263a20df42fd791cb9 (diff)
downloadbcm5719-llvm-fa7525935bd91a4a537d3a7527ec999531536c22.tar.gz
bcm5719-llvm-fa7525935bd91a4a537d3a7527ec999531536c22.zip
builtins: Implement the functions from stdatomic.h
Talking to John and Doug, we concluded that these functions from stdatomic really do belong here in compiler-rt rather than in libc, since the compiler owns stdatomic.h and these need to refer to clang-specific builtins. Nonetheless, I've only added these on darwin for now - other platforms should probably do the same unless their libc does implement these functions. llvm-svn: 236805
Diffstat (limited to 'compiler-rt/lib/builtins/atomic_flag_test_and_set_explicit.c')
-rw-r--r--compiler-rt/lib/builtins/atomic_flag_test_and_set_explicit.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/compiler-rt/lib/builtins/atomic_flag_test_and_set_explicit.c b/compiler-rt/lib/builtins/atomic_flag_test_and_set_explicit.c
new file mode 100644
index 00000000000..eaa5be08df4
--- /dev/null
+++ b/compiler-rt/lib/builtins/atomic_flag_test_and_set_explicit.c
@@ -0,0 +1,20 @@
+/*===-- atomic_flag_test_and_set_explicit.c ---------------------------------===
+ *
+ * The LLVM Compiler Infrastructure
+ *
+ * This file is dual licensed under the MIT and the University of Illinois Open
+ * Source Licenses. See LICENSE.TXT for details.
+ *
+ *===------------------------------------------------------------------------===
+ *
+ * This file implements atomic_flag_test_and_set_explicit from C11's stdatomic.h
+ *
+ *===------------------------------------------------------------------------===
+ */
+
+#include <stdatomic.h>
+#undef atomic_flag_test_and_set_explicit
+_Bool atomic_flag_test_and_set_explicit(volatile atomic_flag *object,
+ memory_order order) {
+ return __c11_atomic_exchange(&(object)->_Value, 1, order);
+}
OpenPOWER on IntegriCloud