Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5586d0c

Browse files
authored
Autotools: Refactor ptrace check for PHP-FPM (#14907)
- This syncs CS and wraps ptrace function check in a single AC_CACHE_CHECK for optional edge case cross-compiling adjustments - Overquoted arguments are reduced (first the compilation check if ptrace in proper form is available on the system and then the run check if ptrace works as expected) - The cache variable php_cv_have_mach_vm_read is renamed to php_cv_func_mach_vm_read.
1 parent d59691c commit 5586d0c

File tree

1 file changed

+35
-53
lines changed

1 file changed

+35
-53
lines changed

‎sapi/fpm/config.m4‎

Lines changed: 35 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,13 @@ AS_VAR_IF([ac_cv_func_clock_gettime], [no],
4545
])])
4646

4747
AC_DEFUN([PHP_FPM_TRACE],
48-
[
49-
have_ptrace=no
50-
have_broken_ptrace=no
51-
52-
AC_MSG_CHECKING([for ptrace])
53-
54-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
48+
[AC_CACHE_CHECK([for ptrace], [php_cv_func_ptrace],
49+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
5550
#include <sys/types.h>
56-
#include <sys/ptrace.h> ]], [[ptrace(0, 0, (void *) 0, 0);]])], [
57-
have_ptrace=yes
58-
AC_MSG_RESULT([yes])
59-
], [
60-
AC_MSG_RESULT([no])
61-
])
62-
63-
if test "$have_ptrace" = "yes"; then
64-
AC_MSG_CHECKING([whether ptrace works])
65-
66-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
51+
#include <sys/ptrace.h>
52+
],
53+
[ptrace(0, 0, (void *) 0, 0);])],
54+
[AC_RUN_IFELSE([AC_LANG_SOURCE([
6755
#include <unistd.h>
6856
#include <signal.h>
6957
#include <sys/wait.h>
@@ -85,7 +73,8 @@ AC_DEFUN([PHP_FPM_TRACE],
8573
8674
int main(void)
8775
{
88-
long v1 = (unsigned int) -1; /* copy will fail if sizeof(long) == 8 and we've got "int ptrace()" */
76+
/* copy will fail if sizeof(long) == 8 and we've got "int ptrace()" */
77+
long v1 = (unsigned int) -1;
8978
long v2;
9079
pid_t child;
9180
int status;
@@ -130,40 +119,33 @@ AC_DEFUN([PHP_FPM_TRACE],
130119
return 0;
131120
}
132121
}
133-
]])], [
134-
AC_MSG_RESULT([yes])
135-
], [
136-
have_ptrace=no
137-
have_broken_ptrace=yes
138-
AC_MSG_RESULT([no])
122+
])],
123+
[php_cv_func_ptrace=yes],
124+
[php_cv_func_ptrace=no],
125+
[php_cv_func_ptrace=yes])],
126+
[php_cv_func_ptrace=no])])
127+
128+
AS_VAR_IF([php_cv_func_ptrace], [yes],
129+
[AC_DEFINE([HAVE_PTRACE], [1],
130+
[Define to 1 if you have the 'ptrace' function.])],
131+
[AC_CACHE_CHECK([for mach_vm_read], [php_cv_func_mach_vm_read],
132+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <mach/mach.h>
133+
#include <mach/mach_vm.h>
139134
], [
140-
AC_MSG_RESULT([skipped (cross-compiling)])
141-
])
142-
fi
143-
144-
if test "$have_ptrace" = "yes"; then
145-
AC_DEFINE([HAVE_PTRACE], 1, [do we have ptrace?])
146-
fi
147-
148-
AS_VAR_IF([have_broken_ptrace], [yes],
149-
[AC_CACHE_CHECK([for mach_vm_read], [php_cv_have_mach_vm_read],
150-
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <mach/mach.h>
151-
#include <mach/mach_vm.h>
152-
], [
153-
mach_vm_read(
154-
(vm_map_t)0,
155-
(mach_vm_address_t)0,
156-
(mach_vm_size_t)0,
157-
(vm_offset_t *)0,
158-
(mach_msg_type_number_t*)0);
159-
])],
160-
[php_cv_have_mach_vm_read=yes],
161-
[php_cv_have_mach_vm_read=no])])
162-
])
135+
mach_vm_read(
136+
(vm_map_t)0,
137+
(mach_vm_address_t)0,
138+
(mach_vm_size_t)0,
139+
(vm_offset_t *)0,
140+
(mach_msg_type_number_t*)0);
141+
])],
142+
[php_cv_func_mach_vm_read=yes],
143+
[php_cv_func_mach_vm_read=no])])
144+
])
163145
164-
AS_VAR_IF([php_cv_have_mach_vm_read], [yes],
165-
[AC_DEFINE([HAVE_MACH_VM_READ], [1],
166-
[Define to 1 if you have the 'mach_vm_read'.])])
146+
AS_VAR_IF([php_cv_func_mach_vm_read], [yes],
147+
[AC_DEFINE([HAVE_MACH_VM_READ], [1],
148+
[Define to 1 if you have the 'mach_vm_read' function.])])
167149
168150
proc_mem_file=""
169151
@@ -222,13 +204,13 @@ AC_DEFUN([PHP_FPM_TRACE],
222204
223205
fpm_trace_type=""
224206
225-
if test "$have_ptrace" = "yes"; then
207+
if test "$php_cv_func_ptrace" = "yes"; then
226208
fpm_trace_type=ptrace
227209
228210
elif test -n "$proc_mem_file"; then
229211
fpm_trace_type=pread
230212
231-
elif test "$php_cv_have_mach_vm_read" = "yes" ; then
213+
elif test "$php_cv_func_mach_vm_read" = "yes" ; then
232214
fpm_trace_type=mach
233215
234216
else

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /