Skip to content

Commit

Permalink
replace with c++ atomic check
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Dec 18, 2023
1 parent 3cd8808 commit 73013d9
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions cmake/re-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include(CheckIncludeFile)
include(CheckFunctionExists)
include(CheckSymbolExists)
include(CheckTypeSize)
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)

option(USE_MBEDTLS "Enable MbedTLS" OFF)

Expand Down Expand Up @@ -266,21 +266,20 @@ endif()
# Testing Atomic
#

if(NOT WIN32)
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=c11)
endif()
enable_language(CXX)

set(ATOMIC_TEST_CODE "
#include <stdatomic.h>
#include <stdint.h>
int main() {
atomic_int_least64_t x;
atomic_store(&x, 1);
x--;
return atomic_load(&x);
}")

check_c_source_compiles("${ATOMIC_TEST_CODE}" atomic_test)
#include <atomic>
#include <cstdint>
std::atomic<uint8_t> n8 (0); // riscv64
std::atomic<uint64_t> n64 (0); // armel, mipsel, powerpc
int main() {
++n8;
++n64;
return 0;
}")

check_cxx_source_compiles("${ATOMIC_TEST_CODE}" atomic_test)

if(NOT atomic_test)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} atomic)
Expand Down

0 comments on commit 73013d9

Please sign in to comment.