Xerxes Ranby | 6215c62 | 2009-07-17 19:22:41 +0000 | [diff] [blame] | 1 | # atomic builtins are required for threading support. |
| 2 | |
| 3 | INCLUDE(CheckCXXSourceCompiles) |
Oscar Fuentes | 87e9807 | 2009-12-05 23:19:33 +0000 | [diff] [blame^] | 4 | |
| 5 | #ifdef _MSC_VER |
| 6 | #include <windows.h> |
| 7 | #endif |
Xerxes Ranby | 6215c62 | 2009-07-17 19:22:41 +0000 | [diff] [blame] | 8 | |
| 9 | CHECK_CXX_SOURCE_COMPILES(" |
| 10 | int main() { |
Oscar Fuentes | 87e9807 | 2009-12-05 23:19:33 +0000 | [diff] [blame^] | 11 | #ifdef _MSC_VER |
| 12 | volatile LONG val = 1; |
| 13 | MemoryBarrier(); |
| 14 | InterlockedCompareExchange(&val, 0, 1); |
| 15 | InterlockedIncrement(&val); |
| 16 | InterlockedDecrement(&val); |
| 17 | #else |
Xerxes Ranby | 6215c62 | 2009-07-17 19:22:41 +0000 | [diff] [blame] | 18 | 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 Fuentes | 87e9807 | 2009-12-05 23:19:33 +0000 | [diff] [blame^] | 23 | #endif |
Xerxes Ranby | 6215c62 | 2009-07-17 19:22:41 +0000 | [diff] [blame] | 24 | return 0; |
| 25 | } |
| 26 | " LLVM_MULTITHREADED) |
| 27 | |
| 28 | if( NOT LLVM_MULTITHREADED ) |
| 29 | message(STATUS "Warning: LLVM will be built thread-unsafe because atomic builtins are missing") |
| 30 | endif() |