blob: 6c4da66bfadea3a3e5d84af58d53377c93b4dc6c [file] [log] [blame]
Xerxes Ranby6215c622009-07-17 19:22:41 +00001# atomic builtins are required for threading support.
2
3INCLUDE(CheckCXXSourceCompiles)
Oscar Fuentes87e98072009-12-05 23:19:33 +00004
5#ifdef _MSC_VER
6#include <windows.h>
7#endif
Xerxes Ranby6215c622009-07-17 19:22:41 +00008
9CHECK_CXX_SOURCE_COMPILES("
10int main() {
Oscar Fuentes87e98072009-12-05 23:19:33 +000011#ifdef _MSC_VER
12 volatile LONG val = 1;
13 MemoryBarrier();
14 InterlockedCompareExchange(&val, 0, 1);
15 InterlockedIncrement(&val);
16 InterlockedDecrement(&val);
17#else
Xerxes Ranby6215c622009-07-17 19:22:41 +000018 volatile unsigned long val = 1;
19 __sync_synchronize();
20 __sync_val_compare_and_swap(&val, 1, 0);
21 __sync_add_and_fetch(&val, 1);
22 __sync_sub_and_fetch(&val, 1);
Oscar Fuentes87e98072009-12-05 23:19:33 +000023#endif
Xerxes Ranby6215c622009-07-17 19:22:41 +000024 return 0;
25 }
26" LLVM_MULTITHREADED)
27
28if( NOT LLVM_MULTITHREADED )
29 message(STATUS "Warning: LLVM will be built thread-unsafe because atomic builtins are missing")
30endif()