]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: assume `sys/socket.h`, `sys/time.h` on non-Windows (as in `curl/curl.h`)
authorViktor Szakats <commit@vsz.me>
Mon, 2 Jun 2025 15:06:08 +0000 (17:06 +0200)
committerViktor Szakats <commit@vsz.me>
Wed, 11 Jun 2025 05:07:49 +0000 (07:07 +0200)
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

CMake/unix-cache.cmake
CMake/win32-cache.cmake
CMakeLists.txt
configure.ac

index 58da04e22299c016fa1dc1e51f5d597808d05f4d..3efad438dc44373193aae769c4d6c1ad520e8b14 100644 (file)
@@ -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)
index cbc0a26a6827e8cbea1aa3256d9841ed465b92d5..3bf77bb840944360bbe183c2d8d26c134213f4ad 100644 (file)
@@ -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)
index 9e1b5d6ddc5f6c487a2b9ad97a0ac343514cfe6f..e8abce38d23316ebf8f4649e02b46534087ceedb 100644 (file)
@@ -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)
index 2902423ff3c2dc9a67281103458e23bd2b22b89c..e1758034262a5768e211357558fd6432bbe812b0 100644 (file)
@@ -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 <sys/socket.h>])
+  AC_DEFINE(HAVE_SYS_TIME_H, 1, [if you have <sys/time.h>])
+  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 \