diff --git a/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h b/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h index bf6f203b5f..ab284a3735 100644 --- a/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h +++ b/CoreFoundation/Base.subproj/CoreFoundation_Prefix.h @@ -189,7 +189,7 @@ static dispatch_queue_t __ ## PREFIX ## Queue(void) { \ #define CF_RETAIN_BALANCED_ELSEWHERE(obj, identified_location) do { } while (0) #endif -#if (TARGET_OS_LINUX && !TARGET_OS_ANDROID && !TARGET_OS_CYGWIN) || TARGET_OS_WIN32 +#if (TARGET_OS_LINUX && !TARGET_OS_ANDROID && !TARGET_OS_CYGWIN && !ALREADY_HAVE_STRL_FUNCS) || TARGET_OS_WIN32 CF_INLINE size_t strlcpy(char * dst, const char * src, size_t maxlen) { const size_t srclen = strlen(src); diff --git a/CoreFoundation/CMakeLists.txt b/CoreFoundation/CMakeLists.txt index beb48d6c86..b78df61724 100644 --- a/CoreFoundation/CMakeLists.txt +++ b/CoreFoundation/CMakeLists.txt @@ -80,6 +80,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL Android) add_compile_definitions($<$:HAVE_SCHED_GETAFFINITY>) endif() endif() + check_symbol_exists(strlcpy "string.h" HAVE_NEW_GLIBC) + if(HAVE_NEW_GLIBC) + add_compile_definitions($<$:ALREADY_HAVE_STRL_FUNCS>) + endif() endif() elseif(CMAKE_SYSTEM_NAME STREQUAL Windows) # NOTE(compnerd) we only support building with the dynamic CRT as using the