[compiler-rt] r248328 - [builtins] Fixing atomic builtins to be compiled out if stdatomic.h isn't available.

H.J. Lu via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 08:36:02 PDT 2015


On Tue, Sep 22, 2015 at 2:50 PM, Chris Bieneman via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: cbieneman
> Date: Tue Sep 22 16:50:43 2015
> New Revision: 248328
>
> URL: http://llvm.org/viewvc/llvm-project?rev=248328&view=rev
> Log:
> [builtins] Fixing atomic builtins to be compiled out if stdatomic.h isn't available.
>
> This should fix the bots broken by r248322.
>
> Reviewed by bogner over my shoulder.
>
> Modified:
>     compiler-rt/trunk/lib/builtins/atomic_flag_clear.c
>     compiler-rt/trunk/lib/builtins/atomic_flag_clear_explicit.c
>     compiler-rt/trunk/lib/builtins/atomic_flag_test_and_set.c
>     compiler-rt/trunk/lib/builtins/atomic_flag_test_and_set_explicit.c
>     compiler-rt/trunk/lib/builtins/atomic_signal_fence.c
>     compiler-rt/trunk/lib/builtins/atomic_thread_fence.c
>
> Modified: compiler-rt/trunk/lib/builtins/atomic_flag_clear.c
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/atomic_flag_clear.c?rev=248328&r1=248327&r2=248328&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/atomic_flag_clear.c (original)
> +++ compiler-rt/trunk/lib/builtins/atomic_flag_clear.c Tue Sep 22 16:50:43 2015
> @@ -12,8 +12,12 @@
>   *===------------------------------------------------------------------------===
>   */
>
> +#if __has_include(<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);
>  }
> +
> +#endif
>
> Modified: compiler-rt/trunk/lib/builtins/atomic_flag_clear_explicit.c
> URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/atomic_flag_clear_explicit.c?rev=248328&r1=248327&r2=248328&view=diff
> ==============================================================================
> --- compiler-rt/trunk/lib/builtins/atomic_flag_clear_explicit.c (original)
> +++ compiler-rt/trunk/lib/builtins/atomic_flag_clear_explicit.c Tue Sep 22 16:50:43 2015
> @@ -12,9 +12,13 @@
>   *===------------------------------------------------------------------------===
>   */
>
> +#if __has_include(<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);
>  }
> +
> +#endif
>

This breaks build on Linux with GCC 5.  GCC 5 supports
__has_include. But its <stdatomic.h> is different from the
one in Clang.  You can't depend on Clang specific stdatomic.h
here.

-- 
H.J.


More information about the llvm-commits mailing list