]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: stop detecting `sched_yield()` on Windows
authorViktor Szakats <commit@vsz.me>
Thu, 16 Jan 2025 19:39:13 +0000 (20:39 +0100)
committerViktor Szakats <commit@vsz.me>
Fri, 17 Jan 2025 22:31:58 +0000 (23:31 +0100)
On Windows a successful `sched_yield()` detection requires mingw-w64
built with POSIX threads (not Win32 threads) and GCC (not llvm/clang).
(linking to `winpthread` via custom options may also work.)

In CMake builds, it was pre-cached as unavailable before this patch.

When detected (via autotools), it got only used for Windows XP or older
targets combined with a non-GCC, non-clang compiler that doesn't support
`__builtin_ia32_pause()`, or with the Intel C compiler. According to
`lib/easy_lock.h`.

mingw-w64 only supports GCC and clang, leaving a very narrow chance when
`shed_yield()` gets called on Windows. Even then, `sched_yield()` is
implemented in `winpthread` as `Sleep(0)`, which may or not be a useful.
It's also trivial to implement locally if it is, and such rare build
combination is also deemed useful.

Thus, this patch marks `sched_yields()` permanently unavailable on the
Windows platform also with autotools, and instead of pre-caching, skip
this feature check with CMake.

This syncs `HAVE_SCHED_YIELDS` between builds methods on Windows.

Follow-up to 9b517c8b69a1f365fdb6f54f7153561182285b6c #11973
Follow-up to 23af112f5556d6a785c17e09f2422ac931405f61 #8680

Closes #16037

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

index 0cb0a12bd3a842322a92a429e8c7a7b398abac87..fb1f2ec0047e7947dbe6dbb035106aa513d58a5a 100644 (file)
@@ -131,7 +131,6 @@ set(HAVE_SEND 1)
 set(HAVE_STROPTS_H 0)
 set(HAVE_ARC4RANDOM 0)
 set(HAVE_FNMATCH 0)
-set(HAVE_SCHED_YIELD 0)
 set(HAVE_ARPA_INET_H 0)
 set(HAVE_FCNTL_H 1)
 set(HAVE_IFADDRS_H 0)
index 16b4a57be54cd12b273ba131dc464b729ebc0c13..a7b1fe5e3d0770edd1ee099e8df3737ea6b398a8 100644 (file)
@@ -1662,7 +1662,6 @@ check_symbol_exists("basename"        "${CURL_INCLUDES};string.h" HAVE_BASENAME)
 check_symbol_exists("opendir"         "dirent.h" HAVE_OPENDIR)
 check_function_exists("poll"          HAVE_POLL)  # poll.h
 check_symbol_exists("socket"          "${CURL_INCLUDES}" HAVE_SOCKET)  # winsock2.h sys/socket.h
-check_function_exists("sched_yield"   HAVE_SCHED_YIELD)
 check_symbol_exists("socketpair"      "${CURL_INCLUDES}" HAVE_SOCKETPAIR)  # sys/socket.h
 check_symbol_exists("recv"            "${CURL_INCLUDES}" HAVE_RECV)  # proto/bsdsocket.h sys/types.h sys/socket.h
 check_symbol_exists("send"            "${CURL_INCLUDES}" HAVE_SEND)  # proto/bsdsocket.h sys/types.h sys/socket.h
@@ -1710,6 +1709,7 @@ check_function_exists("setmode"         HAVE_SETMODE)
 check_function_exists("setrlimit"       HAVE_SETRLIMIT)
 
 if(NOT WIN32)
+  check_function_exists("sched_yield"   HAVE_SCHED_YIELD)
   check_symbol_exists("strcasecmp"      "string.h" HAVE_STRCASECMP)
   check_symbol_exists("stricmp"         "string.h" HAVE_STRICMP)
   check_symbol_exists("strcmpi"         "string.h" HAVE_STRCMPI)
index 072f6f6dbb578926fc42c921ed3df9da682fdaff..3c1e64d534b2e630ef680e7b3e4f6203050d9612 100644 (file)
@@ -4069,7 +4069,6 @@ AC_CHECK_FUNCS([\
   mach_absolute_time \
   pipe \
   poll \
-  sched_yield \
   sendmsg \
   sendmmsg \
   setlocale \
@@ -4081,6 +4080,7 @@ AC_CHECK_FUNCS([\
 ])
 
 if test "$curl_cv_native_windows" != 'yes'; then
+  AC_CHECK_FUNCS([sched_yield])
   CURL_CHECK_FUNC_STRCASECMP
   CURL_CHECK_FUNC_STRCMPI
   CURL_CHECK_FUNC_STRICMP