From cbe2b72ee0256156e0d5733cecaaa3dfb859bae9 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Wed, 26 Jun 2024 23:18:11 +0200 Subject: [PATCH 1/2] Wrap FPM checks in AC_CACHE_CHECK and fix CS - This simplifies over-quoted arguments to AC_COMPILE_IFELSE - Indentation and other CS fixes - php_cv_* cache variables - AC_DEFINE help texts syncs to make it more clear --- sapi/fpm/config.m4 | 185 ++++++++++++++++++++++----------------------- 1 file changed, 89 insertions(+), 96 deletions(-) diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index 99f8c837a8f54..eec6b25f07684 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -314,111 +314,104 @@ AC_DEFUN([PHP_FPM_LQ], ]) AC_DEFUN([PHP_FPM_KQUEUE], -[ - AC_MSG_CHECKING([for kqueue]) - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - #include - #include - ]], [[ - int kfd; - struct kevent k; - kfd = kqueue(); - /* 0 -> STDIN_FILENO */ - EV_SET(&k, 0, EVFILT_READ , EV_ADD | EV_CLEAR, 0, 0, NULL); - ]])], [ - AC_DEFINE([HAVE_KQUEUE], 1, [do we have kqueue?]) - AC_MSG_RESULT([yes]) - ], [ - AC_MSG_RESULT([no]) - ]) +[AC_CACHE_CHECK([for kqueue], + [php_cv_have_kqueue], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([dnl + #include + #include + #include + ], [dnl + int kfd; + struct kevent k; + kfd = kqueue(); + /* 0 -> STDIN_FILENO */ + EV_SET(&k, 0, EVFILT_READ , EV_ADD | EV_CLEAR, 0, 0, NULL); + ])], + [php_cv_have_kqueue=yes], + [php_cv_have_kqueue=no])]) +AS_VAR_IF([php_cv_have_kqueue], [yes], + [AC_DEFINE([HAVE_KQUEUE], [1], + [Define to 1 if system has a working 'kqueue' function.])]) ]) AC_DEFUN([PHP_FPM_DEVPOLL], -[ - AC_MSG_CHECKING([for /dev/poll]) - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - #include - ]], [[ - int n, dp; - struct dvpoll dvp; - dp = 0; - dvp.dp_fds = NULL; - dvp.dp_nfds = 0; - dvp.dp_timeout = 0; - n = ioctl(dp, DP_POLL, &dvp) - ]])], [ - AC_DEFINE([HAVE_DEVPOLL], 1, [do we have /dev/poll?]) - AC_MSG_RESULT([yes]) - ], [ - AC_MSG_RESULT([no]) - ]) +[AC_CACHE_CHECK([for /dev/poll], + [php_cv_have_devpoll], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([dnl + #include + #include + ], [dnl + int n, dp; + struct dvpoll dvp; + dp = 0; + dvp.dp_fds = NULL; + dvp.dp_nfds = 0; + dvp.dp_timeout = 0; + n = ioctl(dp, DP_POLL, &dvp) + ])], + [php_cv_have_devpoll=yes], + [php_cv_have_devpoll=no])]) +AS_VAR_IF([php_cv_have_devpoll], [yes], + [AC_DEFINE([HAVE_DEVPOLL], [1], + [Define to 1 if system has a working '/dev/poll'.])]) ]) AC_DEFUN([PHP_FPM_EPOLL], -[ - AC_MSG_CHECKING([for epoll]) - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #include - ]], [[ - int epollfd; - struct epoll_event e; - - epollfd = epoll_create(1); - if (epollfd < 0) { - return 1; - } - - e.events = EPOLLIN | EPOLLET; - e.data.fd = 0; - - if (epoll_ctl(epollfd, EPOLL_CTL_ADD, 0, &e) == -1) { - return 1; - } - - e.events = 0; - if (epoll_wait(epollfd, &e, 1, 1) < 0) { - return 1; - } - ]])], [ - AC_DEFINE([HAVE_EPOLL], 1, [do we have epoll?]) - AC_MSG_RESULT([yes]) - ], [ - AC_MSG_RESULT([no]) - ]) +[AC_CACHE_CHECK([for epoll], + [php_cv_have_epoll], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include ], [dnl + int epollfd; + struct epoll_event e; + + epollfd = epoll_create(1); + if (epollfd < 0) { + return 1; + } + + e.events = EPOLLIN | EPOLLET; + e.data.fd = 0; + + if (epoll_ctl(epollfd, EPOLL_CTL_ADD, 0, &e) == -1) { + return 1; + } + + e.events = 0; + if (epoll_wait(epollfd, &e, 1, 1) < 0) { + return 1; + } + ])], + [php_cv_have_epoll=yes], + [php_cv_have_epoll=no])]) +AS_VAR_IF([php_cv_have_epoll], [yes], + [AC_DEFINE([HAVE_EPOLL], [1], [Define to 1 if system has a working epoll.])]) ]) AC_DEFUN([PHP_FPM_SELECT], -[ - AC_MSG_CHECKING([for select]) - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - /* According to POSIX.1-2001 */ - #include - - /* According to earlier standards */ - #include - #include - #include - ]], [[ - fd_set fds; - struct timeval t; - t.tv_sec = 0; - t.tv_usec = 42; - FD_ZERO(&fds); - /* 0 -> STDIN_FILENO */ - FD_SET(0, &fds); - select(FD_SETSIZE, &fds, NULL, NULL, &t); - ]])], [ - AC_DEFINE([HAVE_SELECT], 1, [do we have select?]) - AC_MSG_RESULT([yes]) - ], [ - AC_MSG_RESULT([no]) - ]) +[AC_CACHE_CHECK([for select], + [php_cv_have_select], + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([dnl + /* According to POSIX.1-2001 */ + #include + + /* According to earlier standards */ + #include + #include + #include + ], [dnl + fd_set fds; + struct timeval t; + t.tv_sec = 0; + t.tv_usec = 42; + FD_ZERO(&fds); + /* 0 -> STDIN_FILENO */ + FD_SET(0, &fds); + select(FD_SETSIZE, &fds, NULL, NULL, &t); + ])], + [php_cv_have_select=yes], + [php_cv_have_select=no])]) +AS_VAR_IF([php_cv_have_select], [yes], + [AC_DEFINE([HAVE_SELECT], [1], + [Define to 1 if system has a working 'select' function.])]) ]) AC_MSG_CHECKING(for FPM build) From 259e8c7f2f5eab9e43527240e6d3a881a603f721 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Wed, 26 Jun 2024 23:21:47 +0200 Subject: [PATCH 2/2] Fix -Wunused-but-set-variable warnings --- sapi/fpm/config.m4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index eec6b25f07684..dda5cfb7abd16 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -326,6 +326,7 @@ AC_DEFUN([PHP_FPM_KQUEUE], kfd = kqueue(); /* 0 -> STDIN_FILENO */ EV_SET(&k, 0, EVFILT_READ , EV_ADD | EV_CLEAR, 0, 0, NULL); + (void)kfd; ])], [php_cv_have_kqueue=yes], [php_cv_have_kqueue=no])]) @@ -347,7 +348,8 @@ AC_DEFUN([PHP_FPM_DEVPOLL], dvp.dp_fds = NULL; dvp.dp_nfds = 0; dvp.dp_timeout = 0; - n = ioctl(dp, DP_POLL, &dvp) + n = ioctl(dp, DP_POLL, &dvp); + (void)n; ])], [php_cv_have_devpoll=yes], [php_cv_have_devpoll=no])])