]> www.ginac.de Git - cln.git/commitdiff
cmake: defined `short_little_endian`, `int_little_endian` macros
authorAlexey Sheplyakov <asheplyakov@altlinux.org>
Sat, 2 Jan 2021 16:34:34 +0000 (20:34 +0400)
committerAlexey Sheplyakov <asheplyakov@altlinux.org>
Sun, 3 Jan 2021 07:42:47 +0000 (11:42 +0400)
... so CL_CPU_BIG_ENDIAN_P is set in src/base/cl_sysdep.h both for
autotools and CMake builds.

Note 1.

Checking for endianness of both `short` and `int` is necessary only
for 16-bit systems (where `short` can be 8-bit). I doubt anyone is
going to run CLN on such systems in the 21st century. Nevertheless
CMake does the right thing even for such targets (i.e. it tries to
find a 16-bit integer type and figure out its endianness).

Note 2.

These days (circa 2021) the vast majority of CPU architectures are
little endian, so the problem is mostly irrelevant.

CMakeLists.txt
include/cln/intparam.h.cmake
src/CMakeLists.txt

index c89ae1c9cbb7d69ac0d09e37b280f7a307760860..ba2d356a716d491fe741eaca17652fc673324d1f 100644 (file)
@@ -135,9 +135,13 @@ set(CMAKE_REQUIRED_LIBRARIES ${_save_required_libraries})
 
 test_big_endian(cl_cv_bigendian_p)
 if(cl_cv_bigendian_p)
-       set(cln_cpu_big_endian 1)
+       set(short_big_endian 1 CACHE INTERNAL "CPU is big endian")
+       set(int_big_endian 1 CACHE INTERNAL "CPU is big endian")
+       set(long_big_endian 1 CACHE INTERNAL "CPU is big endian")
 else()
-       set(cln_cpu_big_endian 0)
+       set(short_little_endian 1 CACHE INTERNAL "CPU is little endian")
+       set(int_little_endian 1 CACHE INTERNAL "CPU is little endian")
+       set(long_little_endian 1 CACHE INTERNAL "CPU is little endian")
 endif()
 
 include(AsmUnderscore)
index 7cea90b6e64963fcd5acbfb61a95884b63b259bf..a6febae56e46c638726428f77b78406da6677405 100644 (file)
@@ -7,3 +7,9 @@
 // #endif
 #define pointer_bitsize @cl_pointer_bitsize@ 
 #define stack_grows_down
+#cmakedefine short_little_endian
+#cmakedefine int_little_endian
+#cmakedefine long_little_endian
+#cmakedefine short_big_endian
+#cmakedefine int_big_endian
+#cmakedefine long_big_endian
index 430580484d9e549682e2eb93eb3e54ebe16e737b..9602e6763805e6b894e120b0e54dbd57f812db60 100644 (file)
@@ -988,11 +988,6 @@ target_include_directories(cln
        ${CMAKE_CURRENT_BINARY_DIR}
 )
 
-target_compile_definitions(cln
-       PRIVATE
-       -DCL_CPU_BIG_ENDIAN_P=${cln_cpu_big_endian}
-)
-
 install(TARGETS cln
        EXPORT cln-exports
        LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"