From: Viktor Szakats Date: Mon, 2 Jun 2025 15:06:08 +0000 (+0200) Subject: build: assume `sys/socket.h`, `sys/time.h` on non-Windows (as in `curl/curl.h`) X-Git-Tag: curl-8_15_0~297 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56d5982312f8360b020738cbfeefe7990991550e;p=thirdparty%2Fcurl.git build: assume `sys/socket.h`, `sys/time.h` on non-Windows (as in `curl/curl.h`) Public `curl/curl.h` includes these headers for non-Windows platforms without further conditions. This makes it safe to assume these headers do exist, allowing to save two feature checks for non-Windows targets. `sys/time.h` is also assumed on Windows with mingw-w64, for declaring `gettimeofday()`. Closes #17522 --- diff --git a/CMake/unix-cache.cmake b/CMake/unix-cache.cmake index 58da04e222..3efad438dc 100644 --- a/CMake/unix-cache.cmake +++ b/CMake/unix-cache.cmake @@ -280,7 +280,6 @@ set(HAVE_SYS_PARAM_H 1) set(HAVE_SYS_POLL_H 1) set(HAVE_SYS_RESOURCE_H 1) set(HAVE_SYS_SELECT_H 1) -set(HAVE_SYS_SOCKET_H 1) if(CYGWIN OR CMAKE_SYSTEM_NAME STREQUAL "Linux") set(HAVE_SYS_SOCKIO_H 0) diff --git a/CMake/win32-cache.cmake b/CMake/win32-cache.cmake index cbc0a26a68..3bf77bb840 100644 --- a/CMake/win32-cache.cmake +++ b/CMake/win32-cache.cmake @@ -39,7 +39,6 @@ if(MINGW) set(HAVE_STDINT_H 1) # detected by CMake internally in check_type_size() set(HAVE_STRINGS_H 1) # wrapper to string.h set(HAVE_SYS_PARAM_H 1) - set(HAVE_SYS_TIME_H 1) set(HAVE_UNISTD_H 1) set(HAVE_UTIME_H 1) # wrapper to sys/utime.h else() @@ -50,7 +49,6 @@ else() set(HAVE_OPENDIR 0) set(HAVE_STRINGS_H 0) set(HAVE_SYS_PARAM_H 0) - set(HAVE_SYS_TIME_H 0) set(HAVE_UTIME_H 0) if(MSVC) set(HAVE_UNISTD_H 0) @@ -170,7 +168,6 @@ set(HAVE_SYS_IOCTL_H 0) set(HAVE_SYS_POLL_H 0) set(HAVE_SYS_RESOURCE_H 0) set(HAVE_SYS_SELECT_H 0) -set(HAVE_SYS_SOCKET_H 0) set(HAVE_SYS_SOCKIO_H 0) set(HAVE_SYS_STAT_H 1) set(HAVE_SYS_TYPES_H 1) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e1b5d6ddc..e8abce38d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1663,6 +1663,18 @@ if(WIN32) set(HAVE_IF_NAMETOINDEX 0) endif() unset(HAVE_IF_NAMETOINDEX CACHE) + + set(HAVE_SYS_TIME_H ${MINGW}) +else() + set(HAVE_SYS_SOCKET_H 1) + set(HAVE_SYS_TIME_H 1) +endif() + +if(HAVE_SYS_SOCKET_H) + list(APPEND CURL_INCLUDES "sys/socket.h") +endif() +if(HAVE_SYS_TIME_H) + list(APPEND CURL_INCLUDES "sys/time.h") endif() # Detect headers @@ -1677,10 +1689,8 @@ check_include_file("sys/param.h" HAVE_SYS_PARAM_H) check_include_file("sys/poll.h" HAVE_SYS_POLL_H) check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H) check_include_file_concat_curl("sys/select.h" HAVE_SYS_SELECT_H) -check_include_file_concat_curl("sys/socket.h" HAVE_SYS_SOCKET_H) check_include_file("sys/sockio.h" HAVE_SYS_SOCKIO_H) check_include_file("sys/stat.h" HAVE_SYS_STAT_H) -check_include_file_concat_curl("sys/time.h" HAVE_SYS_TIME_H) check_include_file_concat_curl("sys/types.h" HAVE_SYS_TYPES_H) check_include_file("sys/un.h" HAVE_SYS_UN_H) check_include_file_concat_curl("sys/utime.h" HAVE_SYS_UTIME_H) # sys/types.h (AmigaOS) diff --git a/configure.ac b/configure.ac index 2902423ff3..e175803426 100644 --- a/configure.ac +++ b/configure.ac @@ -3959,13 +3959,18 @@ case "$OPT_FISH_FPATH" in esac AM_CONDITIONAL(USE_FISH_COMPLETION, test x"$FISH_FUNCTIONS_DIR" != x) +if test "$curl_cv_native_windows" != 'yes'; then + AC_DEFINE(HAVE_SYS_SOCKET_H, 1, [if you have ]) + AC_DEFINE(HAVE_SYS_TIME_H, 1, [if you have ]) + HAVE_SYS_SOCKET_H=1 + HAVE_SYS_TIME_H=1 +fi + dnl Now check for the very most basic headers. Then we can use these dnl ones as default-headers when checking for the rest! AC_CHECK_HEADERS( sys/types.h \ - sys/time.h \ sys/select.h \ - sys/socket.h \ sys/ioctl.h \ unistd.h \ arpa/inet.h \