From 4b42956cd1b4ee5c739d9bd73662d21c6b13cae8 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sat, 15 Aug 2026 12:56:23 +0200 Subject: [PATCH] build: drop detecting `gettimeofday()` on Windows To remove a build difference between mingw-w64 and MSVC builds (where mingw-w64 has it, while MSVC does not). Also to simplify and save the cost of detection/verification in CI. `gettimeofday()` was used in `curl_threads.c` in codepath practically unreachable in Windows builds, and in `tool_writeout.c` that falls back to `time()` for targets without it. Ref: #22593 Closes #22594 --- CMake/win32-cache.cmake | 2 -- CMakeLists.txt | 2 +- configure.ac | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CMake/win32-cache.cmake b/CMake/win32-cache.cmake index a1f0d909f2..6d0cb076e8 100644 --- a/CMake/win32-cache.cmake +++ b/CMake/win32-cache.cmake @@ -28,7 +28,6 @@ endif() if(MINGW) set(HAVE_BASENAME 1) set(HAVE_BOOL_T 1) # = HAVE_STDBOOL_H - set(HAVE_GETTIMEOFDAY 1) set(HAVE_LIBGEN_H 1) set(HAVE_STDBOOL_H 1) set(HAVE_STDDEF_H 1) # detected by CMake internally in check_type_size() @@ -38,7 +37,6 @@ if(MINGW) set(HAVE_UNISTD_H 1) set(HAVE_UTIME_H 1) # wrapper to sys/utime.h else() - set(HAVE_GETTIMEOFDAY 0) set(HAVE_LIBGEN_H 0) set(HAVE_STRINGS_H 0) set(HAVE_SYS_PARAM_H 0) diff --git a/CMakeLists.txt b/CMakeLists.txt index be5e0e09ea..be551fd8e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1647,7 +1647,6 @@ check_symbol_exists("fcntl" "fcntl.h" HAVE_FCNTL) check_function_exists("getppid" HAVE_GETPPID) check_function_exists("utimes" HAVE_UTIMES) -check_function_exists("gettimeofday" HAVE_GETTIMEOFDAY) # sys/time.h check_symbol_exists("closesocket" "${CURL_INCLUDES}" HAVE_CLOSESOCKET) # winsock2.h check_symbol_exists("sigsetjmp" "setjmp.h" HAVE_SIGSETJMP) check_function_exists("getpass_r" HAVE_GETPASS_R) @@ -1688,6 +1687,7 @@ endif() if(NOT WIN32) check_include_file("dirent.h" HAVE_DIRENT_H) + check_function_exists("gettimeofday" HAVE_GETTIMEOFDAY) # sys/time.h check_function_exists("if_nametoindex" HAVE_IF_NAMETOINDEX) # net/if.h check_function_exists("realpath" HAVE_REALPATH) check_function_exists("sched_yield" HAVE_SCHED_YIELD) diff --git a/configure.ac b/configure.ac index 25b9e44961..f130bc558b 100644 --- a/configure.ac +++ b/configure.ac @@ -4226,7 +4226,6 @@ AC_CHECK_FUNCS([\ getpwuid \ getpwuid_r \ getrlimit \ - gettimeofday \ mach_absolute_time \ pipe \ poll \ @@ -4249,6 +4248,7 @@ fi if test "$curl_cv_native_windows" != "yes"; then AC_CHECK_FUNCS([\ + gettimeofday \ if_nametoindex \ realpath \ sched_yield \