Skip to content

Commit 300d092

Browse files
authored
Autotools: Refactor phpdbg POSIX Threads checks (php#14865)
- AS_VAR_IF, AS_VAR_APPEND used and CS synced - Added one missing AC_MSG_RESULT to properly put the configure output log on each line - AH_TEMPLATE used for HAVE_USERFAULTFD_WRITEFAULT to have help text on lesser places - Redundant terminating semicolons removed - Redundant PTHREADS_CHECK call removed as it is already done in configure.ac and before including SAPI M4 stubs - Redundant CFLAGS and LIBS storing and restoring removed
1 parent 3d8bd8f commit 300d092

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

sapi/phpdbg/config.m4

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,26 @@ if test "$PHP_PHPDBG" != "no"; then
4242
AC_MSG_RESULT([disabled])
4343
fi
4444

45-
AC_CHECK_DECL([UFFDIO_WRITEPROTECT_MODE_WP], [
46-
if test "$enable_zts" != "yes"; then
47-
CFLAGS_SAVE="$CFLAGS"
48-
LIBS_SAVE="$LIBS"
49-
50-
PTHREADS_CHECK
51-
AC_MSG_CHECKING([working pthreads]);
52-
53-
if test "$pthreads_working" = "yes"; then
54-
AC_MSG_RESULT([$ac_cv_pthreads_cflags -l$ac_cv_pthreads_lib]);
55-
PHP_PHPDBG_CFLAGS="$PHP_PHPDBG_CFLAGS $ac_cv_pthreads_cflags"
56-
PHPDBG_EXTRA_LIBS="$PHPDBG_EXTRA_LIBS -l$ac_cv_pthreads_lib"
57-
AC_DEFINE(HAVE_USERFAULTFD_WRITEFAULT, 1, [Whether faulting on write-protected memory support can be compiled for userfaultfd])
58-
else
59-
AC_MSG_WARN([pthreads not available])
60-
fi
61-
62-
CFLAGS="$CFLAGS_SAVE"
63-
LIBS="$LIBS_SAVE"
64-
else
65-
AC_DEFINE(HAVE_USERFAULTFD_WRITEFAULT, 1, [Whether faulting on write-protected memory support can be compiled for userfaultfd])
66-
fi
67-
],,[#include <linux/userfaultfd.h>])
45+
AH_TEMPLATE([HAVE_USERFAULTFD_WRITEFAULT],
46+
[Define to 1 if faulting on write-protected memory support can be compiled
47+
for userfaultfd.])
48+
49+
AC_CHECK_DECL([UFFDIO_WRITEPROTECT_MODE_WP],
50+
[AS_VAR_IF([enable_zts], [yes],
51+
[AC_DEFINE([HAVE_USERFAULTFD_WRITEFAULT], [1])],
52+
[AC_MSG_CHECKING([working pthreads])
53+
AS_VAR_IF([pthreads_working], [yes], [
54+
AC_MSG_RESULT([$ac_cv_pthreads_cflags -l$ac_cv_pthreads_lib])
55+
AS_VAR_APPEND([PHP_PHPDBG_CFLAGS], [" $ac_cv_pthreads_cflags"])
56+
AS_VAR_APPEND([PHPDBG_EXTRA_LIBS], [" -l$ac_cv_pthreads_lib"])
57+
AC_DEFINE([HAVE_USERFAULTFD_WRITEFAULT], [1])
58+
], [
59+
AC_MSG_RESULT([no])
60+
AC_MSG_WARN([pthreads not available])
61+
])
62+
])
63+
],,
64+
[#include <linux/userfaultfd.h>])
6865

6966
PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/phpdbg/Makefile.frag],
7067
[$abs_srcdir/sapi/phpdbg],

0 commit comments

Comments
 (0)