1 # atomic builtins are required for threading support.
3 INCLUDE(CheckCXXSourceCompiles)
5 check_function_exists(__atomic_fetch_add_4 HAVE___ATOMIC_FETCH_ADD_4)
6 if( NOT HAVE___ATOMIC_FETCH_ADD_4 )
7 check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC)
8 set(HAVE_LIBATOMIC False)
10 list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
14 CHECK_CXX_SOURCE_COMPILES("
16 #include <Intrin.h> /* Workaround for PR19898. */
21 volatile LONG val = 1;
23 InterlockedCompareExchange(&val, 0, 1);
24 InterlockedIncrement(&val);
25 InterlockedDecrement(&val);
27 volatile unsigned long val = 1;
29 __sync_val_compare_and_swap(&val, 1, 0);
30 __sync_add_and_fetch(&val, 1);
31 __sync_sub_and_fetch(&val, 1);
37 if( NOT LLVM_HAS_ATOMICS )
38 message(STATUS "Warning: LLVM will be built thread-unsafe because atomic builtins are missing")