From a93f02e3ad6f1bd1b2469e709c84196f5a87e449 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 1 Aug 2023 11:16:57 -0700 Subject: [PATCH] CMake: remove test for eventfd, replace with __has_include This also removes the configure option and therefore makes the feature not disable-able. Saves 350 ms of CMake time. Change-Id: Ifbf974a4d10745b099b1fffd17775528767595d4 Reviewed-by: Alexey Edelev --- cmake/configure-cmake-mapping.md | 1 - config_help.txt | 1 - src/corelib/configure.cmake | 22 -------------------- src/corelib/kernel/qeventdispatcher_unix.cpp | 17 ++++++++------- src/corelib/qt_cmdline.cmake | 1 - 5 files changed, 10 insertions(+), 32 deletions(-) diff --git a/cmake/configure-cmake-mapping.md b/cmake/configure-cmake-mapping.md index 006fd40f714..75c7fd3b2cf 100644 --- a/cmake/configure-cmake-mapping.md +++ b/cmake/configure-cmake-mapping.md @@ -113,7 +113,6 @@ The following table describes the mapping of configure options to CMake argument | -doubleconversion | -DFEATURE_doubleconversion=ON | | | | -DFEATURE_system_doubleconversion=ON/OFF | | | -glib | -DFEATURE_glib=ON | | -| -eventfd | -DFEATURE_eventfd=ON | | | -inotify | -DFEATURE_inotify=ON | | | -icu | -DFEATURE_icu=ON | | | -pcre | -DFEATURE_pcre2=ON | | diff --git a/config_help.txt b/config_help.txt index 37b67e088fd..7681b5f79f8 100644 --- a/config_help.txt +++ b/config_help.txt @@ -221,7 +221,6 @@ Core options: -doubleconversion .... Select used double conversion library [system/qt/no] No implies use of sscanf_l and snprintf_l (imprecise). -glib ................ Enable Glib support [no; auto on Unix] - -eventfd ............. Enable eventfd support -inotify ............. Enable inotify support -icu ................. Enable ICU support [auto] -pcre ................ Select used libpcre2 [system/qt/no] diff --git a/src/corelib/configure.cmake b/src/corelib/configure.cmake index 446473743f6..1e05527517a 100644 --- a/src/corelib/configure.cmake +++ b/src/corelib/configure.cmake @@ -172,24 +172,6 @@ int main(void) }" ) -# eventfd -qt_config_compile_test(eventfd - LABEL "eventfd" - CODE -"#include - -int main(void) -{ - /* BEGIN TEST: */ -eventfd_t value; -int fd = eventfd(0, EFD_CLOEXEC); -eventfd_read(fd, &value); -eventfd_write(fd, value); - /* END TEST: */ - return 0; -} -") - # futimens qt_config_compile_test(futimens LABEL "futimens()" @@ -501,10 +483,6 @@ qt_feature("dladdr" PRIVATE LABEL "dladdr" CONDITION QT_FEATURE_dlopen AND TEST_dladdr ) -qt_feature("eventfd" PRIVATE - LABEL "eventfd" - CONDITION NOT WASM AND TEST_eventfd -) qt_feature("futimens" PRIVATE LABEL "futimens()" CONDITION NOT WIN32 AND TEST_futimens diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp index dc97893435a..5f271805c3e 100644 --- a/src/corelib/kernel/qeventdispatcher_unix.cpp +++ b/src/corelib/kernel/qeventdispatcher_unix.cpp @@ -19,8 +19,11 @@ #include #include -#if QT_CONFIG(eventfd) +#if __has_include() # include +static constexpr bool UsingEventfd = true; +#else +static constexpr bool UsingEventfd = false; #endif #if defined(Q_OS_VXWORKS) @@ -54,7 +57,7 @@ QThreadPipe::~QThreadPipe() if (fds[0] >= 0) close(fds[0]); - if (!QT_CONFIG(eventfd) && fds[1] >= 0) + if (!UsingEventfd && fds[1] >= 0) close(fds[1]); #if defined(Q_OS_VXWORKS) @@ -104,10 +107,10 @@ bool QThreadPipe::init() fds[1] = fds[0]; #else int ret; -# if QT_CONFIG(eventfd) +# ifdef EFD_CLOEXEC ret = fds[0] = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); # endif - if (!QT_CONFIG(eventfd)) + if (!UsingEventfd) ret = qt_safe_pipe(fds, O_NONBLOCK); if (ret == -1) { perror("QThreadPipe: Unable to create pipe"); @@ -126,7 +129,7 @@ pollfd QThreadPipe::prepare() const void QThreadPipe::wakeUp() { if ((wakeUps.fetchAndOrAcquire(1) & 1) == 0) { -#if QT_CONFIG(eventfd) +# ifdef EFD_CLOEXEC eventfd_write(fds[0], 1); return; #endif @@ -149,11 +152,11 @@ int QThreadPipe::check(const pollfd &pfd) ::read(fds[0], c, sizeof(c)); ::ioctl(fds[0], FIOFLUSH, 0); #else -# if QT_CONFIG(eventfd) +# ifdef EFD_CLOEXEC eventfd_t value; eventfd_read(fds[0], &value); # endif - if (!QT_CONFIG(eventfd)) { + if (!UsingEventfd) { while (::read(fds[0], c, sizeof(c)) > 0) {} } #endif diff --git a/src/corelib/qt_cmdline.cmake b/src/corelib/qt_cmdline.cmake index fecc43cce6d..dddb74cbafc 100644 --- a/src/corelib/qt_cmdline.cmake +++ b/src/corelib/qt_cmdline.cmake @@ -2,7 +2,6 @@ # SPDX-License-Identifier: BSD-3-Clause qt_commandline_option(doubleconversion TYPE enum VALUES no qt system) -qt_commandline_option(eventfd TYPE boolean) qt_commandline_option(glib TYPE boolean) qt_commandline_option(icu TYPE boolean) qt_commandline_option(inotify TYPE boolean)