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 | |
Oscar Fuentes | c595e6c | 2009-12-06 00:06:33 +0000 | [diff] [blame] | 5 | CHECK_CXX_SOURCE_COMPILES(" |
Oscar Fuentes | 87e9807 | 2009-12-05 23:19:33 +0000 | [diff] [blame] | 6 | #ifdef _MSC_VER |
| 7 | #include <windows.h> |
| 8 | #endif |
Xerxes Ranby | 6215c62 | 2009-07-17 19:22:41 +0000 | [diff] [blame] | 9 | int main() { |
Oscar Fuentes | 87e9807 | 2009-12-05 23:19:33 +0000 | [diff] [blame] | 10 | #ifdef _MSC_VER |
| 11 | volatile LONG val = 1; |
| 12 | MemoryBarrier(); |
| 13 | InterlockedCompareExchange(&val, 0, 1); |
| 14 | InterlockedIncrement(&val); |
| 15 | InterlockedDecrement(&val); |
| 16 | #else |
Xerxes Ranby | 6215c62 | 2009-07-17 19:22:41 +0000 | [diff] [blame] | 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); |
Oscar Fuentes | 87e9807 | 2009-12-05 23:19:33 +0000 | [diff] [blame] | 22 | #endif |
Xerxes Ranby | 6215c62 | 2009-07-17 19:22:41 +0000 | [diff] [blame] | 23 | return 0; |
| 24 | } |
Eric Christopher | 627445f | 2011-09-19 20:43:23 +0000 | [diff] [blame] | 25 | " LLVM_HAS_ATOMICS) |
Xerxes Ranby | 6215c62 | 2009-07-17 19:22:41 +0000 | [diff] [blame] | 26 | |
Eric Christopher | 627445f | 2011-09-19 20:43:23 +0000 | [diff] [blame] | 27 | if( NOT LLVM_HAS_ATOMICS ) |
Xerxes Ranby | 6215c62 | 2009-07-17 19:22:41 +0000 | [diff] [blame] | 28 | message(STATUS "Warning: LLVM will be built thread-unsafe because atomic builtins are missing") |
| 29 | endif() |