From: Peng-Yu Chen Date: Thu, 20 May 2021 10:11:42 +0000 (+0100) Subject: cmake: detect CURL_SA_FAMILY_T X-Git-Tag: curl-7_77_0~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07d20f5dfa45fe0c3e7ef56b89028887e3c4dc47;p=thirdparty%2Fcurl.git cmake: detect CURL_SA_FAMILY_T Fixes #7049 Closes #7065 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ffb72fafa..fcbf9ed2b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1062,6 +1062,16 @@ if(HAVE_FSETXATTR) endforeach() endif() +set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h") +check_type_size("sa_family_t" SIZEOF_SA_FAMILY_T) +set(HAVE_SA_FAMILY_T ${HAVE_SIZEOF_SA_FAMILY_T}) +set(CMAKE_EXTRA_INCLUDE_FILES "") + +set(CMAKE_EXTRA_INCLUDE_FILES "ws2def.h") +check_type_size("ADDRESS_FAMILY" SIZEOF_ADDRESS_FAMILY) +set(HAVE_ADDRESS_FAMILY ${HAVE_SIZEOF_ADDRESS_FAMILY}) +set(CMAKE_EXTRA_INCLUDE_FILES "") + # sigaction and sigsetjmp are special. Use special mechanism for # detecting those, but only if previous attempt failed. if(HAVE_SIGNAL_H) diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake index 6da7489cda..96a19afc51 100644 --- a/lib/curl_config.h.cmake +++ b/lib/curl_config.h.cmake @@ -313,6 +313,12 @@ /* Define to 1 if you have a IPv6 capable working inet_pton function. */ #cmakedefine HAVE_INET_PTON 1 +/* Define to 1 if symbol `sa_family_t' exists */ +#cmakedefine HAVE_SA_FAMILY_T 1 + +/* Define to 1 if symbol `ADDRESS_FAMILY' exists */ +#cmakedefine HAVE_ADDRESS_FAMILY 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_INTTYPES_H 1 diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 5f4e4244a4..b6ef532448 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -777,9 +777,16 @@ endings either CRLF or LF so 't' is appropriate. # endif #endif /* DONT_USE_RECV_BEFORE_SEND_WORKAROUND */ -/* for systems that don't detect this in configure, use a sensible default */ +/* for systems that don't detect this in configure */ #ifndef CURL_SA_FAMILY_T -#define CURL_SA_FAMILY_T unsigned short +# if defined(HAVE_SA_FAMILY_T) +# define CURL_SA_FAMILY_T sa_family_t +# elif defined(HAVE_ADDRESS_FAMILY) +# define CURL_SA_FAMILY_T ADDRESS_FAMILY +# else +/* use a sensible default */ +# define CURL_SA_FAMILY_T unsigned short +# endif #endif /* Some convenience macros to get the larger/smaller value out of two given.