]> granicus.if.org Git - clang/commit
Add an implementation of C11's stdatomic.h
authorHal Finkel <hfinkel@anl.gov>
Fri, 3 Oct 2014 04:29:40 +0000 (04:29 +0000)
committerHal Finkel <hfinkel@anl.gov>
Fri, 3 Oct 2014 04:29:40 +0000 (04:29 +0000)
commit39f1f1f1c67c5680403fc8cc177395a2011328fd
treefbd28c2c01d422abd8aa3a1f71997f030b968258
parent9a0b6f5855d9ad757686e108169fbc7550495654
Add an implementation of C11's stdatomic.h

Adds a Clang-specific implementation of C11's stdatomic.h header. On systems,
such as FreeBSD, where a stdatomic.h header is already provided, we defer to
that header instead (using our __has_include_next technology). Otherwise, we
provide an implementation in terms of our __c11_atomic_* intrinsics (that were
created for this purpose).

C11 7.1.4p1 requires function declarations for atomic_thread_fence,
atomic_signal_fence, atomic_flag_test_and_set,
atomic_flag_test_and_set_explicit, and atomic_flag_clear, and requires that
they have external linkage. Accordingly, we provide these declarations, but if
a user elides the shadowing macros and uses them, then they must have a libc
(or similar) that actually provides definitions.

atomic_flag is implemented using _Bool as the underlying type. This is
consistent with the implementation provided by FreeBSD and also GCC 4.9 (at
least when __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1).

Patch by Richard Smith (rebased and slightly edited by me -- Richard said I
should drive at this point).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218957 91177308-0d34-0410-b5e6-96231b3b80d8
docs/LanguageExtensions.rst
lib/Headers/CMakeLists.txt
lib/Headers/stdatomic.h [new file with mode: 0644]
test/CodeGen/atomic-ops.c
test/Sema/atomic-ops.c