Skip to content

Commit 7df0e2f

Browse files
Compile time check if LONG DOUBLE is different from DOUBLE
Hardcoded config value provided wrong value for Android i686.
1 parent a245816 commit 7df0e2f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

CMakeLists.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,6 @@ endif()
5757
# Add compile flags
5858
target_compile_options("${PROJECT_NAME}" PUBLIC ${C_ASM_COMPILE_FLAGS})
5959

60-
61-
# Determine if long double and double is the same on current platform
62-
if(${OPENLIBM_ARCH_FOLDER} STREQUAL "i387" OR ${OPENLIBM_ARCH_FOLDER} STREQUAL "amd64")
63-
set(LONG_DOUBLE_NOT_DOUBLE 1)
64-
elseif(${OPENLIBM_ARCH_FOLDER} STREQUAL "aarch64")
65-
if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Windows"))
66-
set(LONG_DOUBLE_NOT_DOUBLE 1)
67-
endif()
68-
endif()
69-
7060
# Project Source
7161
set(PROJECT_SRC "${PROJECT_SOURCE_DIR}")
7262

@@ -259,6 +249,16 @@ if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
259249
)
260250
endif()
261251

252+
# Determine if long double and double are the same size
253+
include(CheckCSourceCompiles)
254+
check_c_source_compiles("
255+
#include <float.h>
256+
#if (LDBL_MANT_DIG == DBL_MANT_DIG)
257+
#error \"long double and double are the same size\"
258+
#endif
259+
int main(void ) { return 0; }
260+
" LONG_DOUBLE_NOT_DOUBLE)
261+
262262
# Add in long double functions for x86, x64 and aarch64
263263
if(LONG_DOUBLE_NOT_DOUBLE)
264264
list(APPEND OPENLIBM_C_SOURCE

0 commit comments

Comments
 (0)