diff options
author | 2024-10-17 15:52:06 -0400 | |
---|---|---|
committer | 2025-02-20 17:43:36 +0000 | |
commit | 399d85137365bb6ba394359cfe1a9625cad8eec4 (patch) | |
tree | 98eb3cfb2d140f714b71841332d3f77b8ff1e305 /extras | |
parent | 67067e18c862bafeed1921e13381af89885bde79 (diff) |
libmemif: Fixed strlcpy symbol detection.
Type: fix
libmemif can't be compiled with the modern glibc (since 2.38)
and musl as they include strlcpy for _GNU_SOURCE by default now.
The change introduced:
- proper symbol detection for both strlcpy and memfd_create;
- bumped CMake version requirements due to soon-to-be failed
compilation for very old version;
- fixed Unity compilation on the modern compilers (it has warnings,
but compiled with `-Werror`).
Change-Id: I48f9c410aa5405174dc6b65e9c9001e8b11ba276
Signed-off-by: Alexander Slesarev <aslesare@cisco.com>
Diffstat (limited to 'extras')
-rw-r--r-- | extras/libmemif/CMakeLists.txt | 14 | ||||
-rw-r--r-- | extras/libmemif/src/CMakeLists.txt | 6 | ||||
-rw-r--r-- | extras/libmemif/src/memif_private.h | 4 | ||||
-rw-r--r-- | extras/libmemif/test/suite_main/CMakeLists.txt | 2 | ||||
-rw-r--r-- | extras/libmemif/test/suite_socket/CMakeLists.txt | 2 |
5 files changed, 14 insertions, 14 deletions
diff --git a/extras/libmemif/CMakeLists.txt b/extras/libmemif/CMakeLists.txt index 1526abdce3a..f2e1008c628 100644 --- a/extras/libmemif/CMakeLists.txt +++ b/extras/libmemif/CMakeLists.txt @@ -17,7 +17,7 @@ project(memif) set(CMAKE_C_STANDARD 11) include(CheckCCompilerFlag) -include(CheckFunctionExists) +include(CheckSymbolExists) find_package(Git REQUIRED) include(ExternalProject) @@ -26,7 +26,9 @@ set(UNITY unity_project) ExternalProject_Add( unity_project GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity.git - GIT_TAG cf949f45ca6d172a177b00da21310607b97bc7a7 + # TODO: bump to the stable version as soon as it's available, + # current 2.6.0 couldn't be compiled with the modern compilers + GIT_TAG 73237c5d224169c7b4d2ec8321f9ac92e8071708 PREFIX ${PROJECT_BINARY_DIR}/external/${UNITY} INSTALL_COMMAND cmake --install . --prefix ${PROJECT_BINARY_DIR} @@ -72,11 +74,17 @@ endif() message(STATUS "System Architecture: ${CMAKE_SYSTEM_PROCESSOR}") message(STATUS "Libmemif Cacheline Size: ${LIBMEMIF_CACHELINE_SIZE}") -check_function_exists(memfd_create HAVE_MEMFD_CREATE) +list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE") +check_symbol_exists(memfd_create "sys/mman.h" HAVE_MEMFD_CREATE) if(${HAVE_MEMFD_CREATE}) add_definitions(-DHAVE_MEMFD_CREATE) endif() +check_symbol_exists(strlcpy "string.h" HAVE_STRLCPY) +if(${HAVE_STRLCPY}) + add_definitions(-DHAVE_STRLCPY) +endif() + include_directories(src) add_subdirectory(src) diff --git a/extras/libmemif/src/CMakeLists.txt b/extras/libmemif/src/CMakeLists.txt index 8b3223d0990..0fbcf4b7361 100644 --- a/extras/libmemif/src/CMakeLists.txt +++ b/extras/libmemif/src/CMakeLists.txt @@ -36,12 +36,6 @@ add_library(memif SHARED ${MEMIF_SOURCES}) target_link_libraries(memif ${CMAKE_THREAD_LIBS_INIT}) target_compile_definitions(memif PUBLIC MEMIF_CACHELINE_SIZE=${LIBMEMIF_CACHELINE_SIZE}) -find_library(LIB_BSD bsd) -if(LIB_BSD) - add_compile_definitions(HAS_LIB_BSD) - target_link_libraries(memif ${LIB_BSD}) -endif() - foreach(file ${MEMIF_HEADERS}) get_filename_component(dir ${file} DIRECTORY) install( diff --git a/extras/libmemif/src/memif_private.h b/extras/libmemif/src/memif_private.h index 71a4bc879f4..4ab82894292 100644 --- a/extras/libmemif/src/memif_private.h +++ b/extras/libmemif/src/memif_private.h @@ -67,7 +67,7 @@ _Static_assert (strlen (MEMIF_DEFAULT_APP_NAME) <= MEMIF_NAME_LEN, #define DBG(...) #endif /* MEMIF_DBG */ -#ifndef HAS_LIB_BSD +#ifndef HAVE_STRLCPY static inline size_t strlcpy (char *dest, const char *src, size_t len) { @@ -90,8 +90,6 @@ strlcpy (char *dest, const char *src, size_t len) return (s - src - 1); } -#else -#include <bsd/string.h> #endif typedef enum diff --git a/extras/libmemif/test/suite_main/CMakeLists.txt b/extras/libmemif/test/suite_main/CMakeLists.txt index 7a2940098e0..7505b5f9d7f 100644 --- a/extras/libmemif/test/suite_main/CMakeLists.txt +++ b/extras/libmemif/test/suite_main/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.5) set (This MemifMainTest) diff --git a/extras/libmemif/test/suite_socket/CMakeLists.txt b/extras/libmemif/test/suite_socket/CMakeLists.txt index 5ac66a06cfa..3c33095c1de 100644 --- a/extras/libmemif/test/suite_socket/CMakeLists.txt +++ b/extras/libmemif/test/suite_socket/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.5) set (This MemifSocketTest) |