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 <alexey.edelev@qt.io>
This commit is contained in:
Thiago Macieira 2023-08-01 11:16:57 -07:00
parent 9c70e11711
commit a93f02e3ad
5 changed files with 10 additions and 32 deletions

View File

@ -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 | |

View File

@ -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]

View File

@ -172,24 +172,6 @@ int main(void)
}"
)
# eventfd
qt_config_compile_test(eventfd
LABEL "eventfd"
CODE
"#include <sys/eventfd.h>
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

View File

@ -19,8 +19,11 @@
#include <stdio.h>
#include <stdlib.h>
#if QT_CONFIG(eventfd)
#if __has_include(<sys/eventfd.h>)
# include <sys/eventfd.h>
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

View File

@ -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)