From 49a5dfd006b3d8d207888f5e63e5b538a83a3c32 Mon Sep 17 00:00:00 2001 From: Marc Bennewitz Date: Thu, 27 Aug 2026 10:15:04 +0200 Subject: [PATCH] Fix Io\Poll\Context::wait() epoll_pwait2 detection on i386 (docker) Detect epoll_pwait2 by checking for ENOSYS/ENOTSUP errno before defining HAVE_EPOLL_PWAIT2 --- build/php.m4 | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/build/php.m4 b/build/php.m4 index d8bf0221e83e..c653349f9e42 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -1400,11 +1400,43 @@ AC_DEFUN([PHP_POLL_MECHANISMS], AC_DEFINE([HAVE_EPOLL], [1], [Define if epoll is available]) poll_mechanisms="$poll_mechanisms epoll" - AC_CHECK_FUNCS([epoll_pwait2], [], - [AC_CHECK_DECL([epoll_pwait2], - [AC_DEFINE([HAVE_EPOLL_PWAIT2], [1])], - [], - [#include ])]) + AC_CACHE_CHECK([whether epoll_pwait2 works], [php_cv_have_working_epoll_pwait2], + [AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include + +int main(void) +{ + int epfd = epoll_create1(EPOLL_CLOEXEC); + struct epoll_event ev; + struct timespec timeout = {0, 0}; + + if (epfd < 0) { + return 1; + } + + if (epoll_pwait2(epfd, &ev, 1, &timeout, (void*)0) < 0) { +#ifdef ENOSYS + if (errno == ENOSYS) { + return 1; + } +#endif +#ifdef ENOTSUP + if (errno == ENOTSUP) { + return 1; + } +#endif + } + + return 0; +} +]])], + [php_cv_have_working_epoll_pwait2=yes], + [php_cv_have_working_epoll_pwait2=no], + [php_cv_have_working_epoll_pwait2=no])]) + AS_VAR_IF([php_cv_have_working_epoll_pwait2], [yes], + [AC_DEFINE([HAVE_EPOLL_PWAIT2], [1], + [Define if epoll_pwait2 is available])]) ]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([