]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: set HAVE_GETADDRINFO_THREADSAFE on Windows
authorViktor Szakats <commit@vsz.me>
Fri, 14 Oct 2022 18:19:09 +0000 (18:19 +0000)
committerViktor Szakats <commit@vsz.me>
Fri, 14 Oct 2022 18:19:09 +0000 (18:19 +0000)
autotools enables this configuration option unconditionally for Windows
[^1]. Do the same in CMake.

The above will make this work for all reasonably recent environments.
The logic present in `lib/config-win32.h` [^2] has the following
exceptions which we did not cover in this CMake update:

- Builds targeting Windows 2000 and earlier
- MS Visual C++ 5.0 (1997) and earlier

Also make sure to disable this feature when `HAVE_GETADDRINFO` isn't
set, to avoid a broken build. We might want to handle that in the C
sources in a future commit.

[^1]: https://github.com/curl/curl/blob/68fa9bf3f5d7b4fcbb57619f70cb4aabb79a51f6/m4/curl-functions.m4#L2067-L2070

[^2]: https://github.com/curl/curl/blob/68fa9bf3f5d7b4fcbb57619f70cb4aabb79a51f6/lib/config-win32.h#L511-L528

Closes #9727

CMake/Platforms/WindowsCache.cmake
CMakeLists.txt
lib/curl_config.h.cmake

index a9930f0b2a758e6be2c3f89d1a2dcedd57bd2d7d..dc46753685bc61dccff9cda98e1c863b5679f21f 100644 (file)
@@ -70,6 +70,7 @@ if(NOT UNIX)
     set(HAVE_UTIME 1)
     set(HAVE_RAND_EGD 0)
     set(HAVE_GMTIME_R 0)
+    set(HAVE_GETADDRINFO_THREADSAFE 1)
     set(HAVE_GETHOSTBYNAME_R 0)
     set(HAVE_SIGNAL 1)
 
index e1704e34ac9fcdd036f75d082530de9b68b94d93..0ee96db6bbb1b0777d5ff1bc07a43461ead53b07 100644 (file)
@@ -1045,6 +1045,9 @@ check_symbol_exists(_strtoi64      "${CURL_INCLUDES}" HAVE__STRTOI64)
 check_symbol_exists(strerror_r     "${CURL_INCLUDES}" HAVE_STRERROR_R)
 check_symbol_exists(siginterrupt   "${CURL_INCLUDES}" HAVE_SIGINTERRUPT)
 check_symbol_exists(getaddrinfo    "${CURL_INCLUDES}" HAVE_GETADDRINFO)
+if(NOT HAVE_GETADDRINFO)
+  set(HAVE_GETADDRINFO_THREADSAFE OFF)
+endif()
 check_symbol_exists(freeaddrinfo   "${CURL_INCLUDES}" HAVE_FREEADDRINFO)
 check_symbol_exists(pipe           "${CURL_INCLUDES}" HAVE_PIPE)
 check_symbol_exists(ftruncate      "${CURL_INCLUDES}" HAVE_FTRUNCATE)
index 5ac20dff0bc05f57175f630a8d71a80abf1d9afc..3ba14923cd2a71760f0fc8e573b38db76b79fd0a 100644 (file)
 /* Define to 1 if you have a working getaddrinfo function. */
 #cmakedefine HAVE_GETADDRINFO 1
 
+/* Define to 1 if the getaddrinfo function is threadsafe. */
+#cmakedefine HAVE_GETADDRINFO_THREADSAFE 1
+
 /* Define to 1 if you have the `geteuid' function. */
 #cmakedefine HAVE_GETEUID 1