]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
eventfd: allow for all CPUs
authorViktor Szakats <commit@vsz.me>
Sat, 8 Feb 2025 01:34:48 +0000 (02:34 +0100)
committerViktor Szakats <commit@vsz.me>
Fri, 21 Feb 2025 11:07:24 +0000 (12:07 +0100)
After fixing support for x32, unlock eventfd support for all CPUs.
Before this patch, it was explicitly limited to 64-bit ones.

You can disable eventfs manually on systems where it's auto-detected:
- cmake: `-DHAVE_EVENTFD=0`
- configure: `export ac_cv_func_eventfd=0`

Ref: c2aa504ab9148b5c284b090c5043d9f0c3fbd903 #16239
Closes #16277

lib/asyn-thread.c
lib/multi.c
lib/socketpair.c
lib/socketpair.h

index a529665de507d3ef43d78ab0d48e36df74ad8224..a0ca8b3e9d37c17ffc6f1a8a3f3dd989d05185c4 100644 (file)
@@ -170,7 +170,7 @@ void destroy_thread_sync_data(struct thread_sync_data *tsd)
    * close one end of the socket pair (may be done in resolver thread);
    * the other end (for reading) is always closed in the parent thread.
    */
-#ifndef USE_EVENTFD
+#ifndef HAVE_EVENTFD
   if(tsd->sock_pair[1] != CURL_SOCKET_BAD) {
     wakeup_close(tsd->sock_pair[1]);
   }
@@ -293,7 +293,7 @@ CURL_STDCALL getaddrinfo_thread(void *arg)
   else {
 #ifndef CURL_DISABLE_SOCKETPAIR
     if(tsd->sock_pair[1] != CURL_SOCKET_BAD) {
-#ifdef USE_EVENTFD
+#ifdef HAVE_EVENTFD
       const uint64_t buf[1] = { 1 };
 #else
       const char buf[1] = { 1 };
index c232f69544a0c848029b837054819b76ea8c3413..be52d54f544ea7c8602f9d4b60ee346d952d64f5 100644 (file)
@@ -1552,7 +1552,7 @@ CURLMcode curl_multi_wakeup(CURLM *m)
      and before cleanup */
   if(multi->wakeup_pair[1] != CURL_SOCKET_BAD) {
     while(1) {
-#ifdef USE_EVENTFD
+#ifdef HAVE_EVENTFD
       /* eventfd has a stringent rule of requiring the 8-byte buffer when
          calling write(2) on it */
       const uint64_t buf[1] = { 1 };
@@ -2873,7 +2873,7 @@ CURLMcode curl_multi_cleanup(CURLM *m)
 #else
 #ifdef ENABLE_WAKEUP
     wakeup_close(multi->wakeup_pair[0]);
-#ifndef USE_EVENTFD
+#ifndef HAVE_EVENTFD
     wakeup_close(multi->wakeup_pair[1]);
 #endif
 #endif
index c4f558ea6b889bbcf7ddd9c799e4ebe1e8813ea2..6ae541b4550697cf8f94ff06dd0aba37cd66cba3 100644 (file)
@@ -27,7 +27,7 @@
 #include "urldata.h"
 #include "rand.h"
 
-#if defined(USE_EVENTFD)
+#ifdef HAVE_EVENTFD
 #ifdef HAVE_SYS_EVENTFD_H
 #include <sys/eventfd.h>
 #endif
index ed69c5af826aa7192f7e05720b9c67c087a29030..da0d08b767c9fbe16029d83b70c6a0a7d502f9e3 100644 (file)
 
 #include "curl_setup.h"
 
-#if defined(HAVE_EVENTFD) && \
-    (defined(__x86_64__) || \
-     defined(__aarch64__) || \
-     defined(__ia64__) || \
-     defined(__ppc64__) || \
-     defined(__mips64) || \
-     defined(__sparc64__) || \
-     defined(__riscv_64e) || \
-     defined(__s390x__))
-
-/* Use eventfd only with 64-bit CPU architectures because eventfd has a
- * stringent rule of requiring the 8-byte buffer when calling read(2) and
- * write(2) on it. In some rare cases, the C standard library implementation
- * on a 32-bit system might choose to define uint64_t as a 32-bit type for
- * various reasons (memory limitations, compatibility with older code),
- * which makes eventfd broken.
- */
-#define USE_EVENTFD 1
+#ifdef HAVE_EVENTFD
 
 #define wakeup_write  write
 #define wakeup_read   read
@@ -63,7 +46,7 @@ int Curl_eventfd(curl_socket_t socks[2], bool nonblocking);
 #include <curl/curl.h>
 int Curl_pipe(curl_socket_t socks[2], bool nonblocking);
 
-#else /* !USE_EVENTFD && !HAVE_PIPE */
+#else /* !HAVE_EVENTFD && !HAVE_PIPE */
 
 #define wakeup_write     swrite
 #define wakeup_read      sread
@@ -86,7 +69,7 @@ int Curl_pipe(curl_socket_t socks[2], bool nonblocking);
 #define wakeup_create(p,nb)\
 Curl_socketpair(SOCKETPAIR_FAMILY, SOCKETPAIR_TYPE, 0, p, nb)
 
-#endif /* USE_EVENTFD */
+#endif /* HAVE_EVENTFD */
 
 #ifndef CURL_DISABLE_SOCKETPAIR
 #include <curl/curl.h>