the various ConstantExpr::get*Ty methods existed to work with issues around
[llvm/stm8.git] / cmake / modules / CheckAtomic.cmake
blobf40ff4dfbd3123e4ab3fc29de1ddc3595eed1e43
1 # atomic builtins are required for threading support.
3 INCLUDE(CheckCXXSourceCompiles)
5 CHECK_CXX_SOURCE_COMPILES("
6 #ifdef _MSC_VER
7 #include <windows.h>
8 #endif
9 int main() {
10 #ifdef _MSC_VER
11         volatile LONG val = 1;
12         MemoryBarrier();
13         InterlockedCompareExchange(&val, 0, 1);
14         InterlockedIncrement(&val);
15         InterlockedDecrement(&val);
16 #else
17         volatile unsigned long val = 1;
18         __sync_synchronize();
19         __sync_val_compare_and_swap(&val, 1, 0);
20         __sync_add_and_fetch(&val, 1);
21         __sync_sub_and_fetch(&val, 1);
22 #endif
23         return 0;
24       }
25 " LLVM_MULTITHREADED)
27 if( NOT LLVM_MULTITHREADED )
28   message(STATUS "Warning: LLVM will be built thread-unsafe because atomic builtins are missing")
29 endif()