diff options
| author | Justin Bogner <mail@justinbogner.com> | 2015-05-08 05:39:05 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2015-05-08 05:39:05 +0000 |
| commit | fa7525935bd91a4a537d3a7527ec999531536c22 (patch) | |
| tree | 2ba1fbfb3d83f644b64042ac3419534cc5dd2c6d /compiler-rt/lib/builtins | |
| parent | 1cf6c28a9c0c507a224889263a20df42fd791cb9 (diff) | |
| download | bcm5719-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')
| -rw-r--r-- | compiler-rt/lib/builtins/atomic_flag_clear.c | 19 | ||||
| -rw-r--r-- | compiler-rt/lib/builtins/atomic_flag_clear_explicit.c | 20 | ||||
| -rw-r--r-- | compiler-rt/lib/builtins/atomic_flag_test_and_set.c | 19 | ||||
| -rw-r--r-- | compiler-rt/lib/builtins/atomic_flag_test_and_set_explicit.c | 20 | ||||
| -rw-r--r-- | compiler-rt/lib/builtins/atomic_signal_fence.c | 19 | ||||
| -rw-r--r-- | compiler-rt/lib/builtins/atomic_thread_fence.c | 19 |
6 files changed, 116 insertions, 0 deletions
diff --git a/compiler-rt/lib/builtins/atomic_flag_clear.c b/compiler-rt/lib/builtins/atomic_flag_clear.c new file mode 100644 index 00000000000..15984cd5267 --- /dev/null +++ b/compiler-rt/lib/builtins/atomic_flag_clear.c @@ -0,0 +1,19 @@ +/*===-- atomic_flag_clear.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_clear from C11's stdatomic.h. + * + *===------------------------------------------------------------------------=== + */ + +#include <stdatomic.h> +#undef atomic_flag_clear +void atomic_flag_clear(volatile atomic_flag *object) { + return __c11_atomic_store(&(object)->_Value, 0, __ATOMIC_SEQ_CST); +} diff --git a/compiler-rt/lib/builtins/atomic_flag_clear_explicit.c b/compiler-rt/lib/builtins/atomic_flag_clear_explicit.c new file mode 100644 index 00000000000..0f7859c2cd8 --- /dev/null +++ b/compiler-rt/lib/builtins/atomic_flag_clear_explicit.c @@ -0,0 +1,20 @@ +/*===-- atomic_flag_clear_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_clear_explicit from C11's stdatomic.h. + * + *===------------------------------------------------------------------------=== + */ + +#include <stdatomic.h> +#undef atomic_flag_clear_explicit +void atomic_flag_clear_explicit(volatile atomic_flag *object, + memory_order order) { + return __c11_atomic_store(&(object)->_Value, 0, order); +} diff --git a/compiler-rt/lib/builtins/atomic_flag_test_and_set.c b/compiler-rt/lib/builtins/atomic_flag_test_and_set.c new file mode 100644 index 00000000000..07209fc02d5 --- /dev/null +++ b/compiler-rt/lib/builtins/atomic_flag_test_and_set.c @@ -0,0 +1,19 @@ +/*===-- atomic_flag_test_and_set.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 from C11's stdatomic.h. + * + *===------------------------------------------------------------------------=== + */ + +#include <stdatomic.h> +#undef atomic_flag_test_and_set +_Bool atomic_flag_test_and_set(volatile atomic_flag *object) { + return __c11_atomic_exchange(&(object)->_Value, 1, __ATOMIC_SEQ_CST); +} 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); +} diff --git a/compiler-rt/lib/builtins/atomic_signal_fence.c b/compiler-rt/lib/builtins/atomic_signal_fence.c new file mode 100644 index 00000000000..ad292d2f1c7 --- /dev/null +++ b/compiler-rt/lib/builtins/atomic_signal_fence.c @@ -0,0 +1,19 @@ +/*===-- atomic_signal_fence.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_signal_fence from C11's stdatomic.h. + * + *===------------------------------------------------------------------------=== + */ + +#include <stdatomic.h> +#undef atomic_signal_fence +void atomic_signal_fence(memory_order order) { + __c11_atomic_signal_fence(order); +} diff --git a/compiler-rt/lib/builtins/atomic_thread_fence.c b/compiler-rt/lib/builtins/atomic_thread_fence.c new file mode 100644 index 00000000000..71f698c9de7 --- /dev/null +++ b/compiler-rt/lib/builtins/atomic_thread_fence.c @@ -0,0 +1,19 @@ +/*===-- atomic_thread_fence.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_thread_fence from C11's stdatomic.h. + * + *===------------------------------------------------------------------------=== + */ + +#include <stdatomic.h> +#undef atomic_thread_fence +void atomic_thread_fence(memory_order order) { + __c11_atomic_thread_fence(order); +} |

