Skip to content

Commit 1a5c411

Browse files
authored
Wrap stack direction check in Zend M4 macro (#14694)
1 parent 01b3c05 commit 1a5c411

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

Zend/Zend.m4

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -167,33 +167,7 @@ AC_CHECK_FUNCS([sigsetjmp],,
167167
[AC_DEFINE([HAVE_SIGSETJMP], [1])],,
168168
[#include <setjmp.h>])])
169169
170-
dnl Test whether the stack grows downwards
171-
dnl Assumes contiguous stack
172-
AC_CACHE_CHECK([whether the stack grows downwards], [php_cv_have_stack_limit],
173-
[AC_RUN_IFELSE([AC_LANG_SOURCE([
174-
#include <stdint.h>
175-
176-
int (*volatile f)(uintptr_t);
177-
178-
int stack_grows_downwards(uintptr_t arg) {
179-
int local;
180-
return (uintptr_t)&local < arg;
181-
}
182-
183-
int main(void) {
184-
int local;
185-
186-
f = stack_grows_downwards;
187-
return f((uintptr_t)&local) ? 0 : 1;
188-
}
189-
])],
190-
[php_cv_have_stack_limit=yes],
191-
[php_cv_have_stack_limit=no],
192-
[php_cv_have_stack_limit=no])])
193-
AS_VAR_IF([php_cv_have_stack_limit], [yes],
194-
[AC_DEFINE([ZEND_CHECK_STACK_LIMIT], [1],
195-
[Define to 1 if checking the stack limit is supported.])])
196-
170+
ZEND_CHECK_STACK_DIRECTION
197171
ZEND_CHECK_FLOAT_PRECISION
198172
ZEND_DLSYM_CHECK
199173
ZEND_CHECK_GLOBAL_REGISTER_VARIABLES
@@ -326,6 +300,38 @@ AC_MSG_CHECKING(whether to enable zend max execution timers)
326300
AC_MSG_RESULT($ZEND_MAX_EXECUTION_TIMERS)
327301
])
328302

303+
dnl
304+
dnl ZEND_CHECK_STACK_DIRECTION
305+
dnl
306+
dnl Check whether the stack grows downwards, assumes contiguous stack.
307+
dnl
308+
AC_DEFUN([ZEND_CHECK_STACK_DIRECTION],
309+
[AC_CACHE_CHECK([whether the stack grows downwards],
310+
[php_cv_have_stack_limit],
311+
[AC_RUN_IFELSE([AC_LANG_SOURCE([dnl
312+
#include <stdint.h>
313+
314+
int (*volatile f)(uintptr_t);
315+
316+
int stack_grows_downwards(uintptr_t arg) {
317+
int local;
318+
return (uintptr_t)&local < arg;
319+
}
320+
321+
int main(void) {
322+
int local;
323+
324+
f = stack_grows_downwards;
325+
return f((uintptr_t)&local) ? 0 : 1;
326+
}])],
327+
[php_cv_have_stack_limit=yes],
328+
[php_cv_have_stack_limit=no],
329+
[php_cv_have_stack_limit=no])])
330+
AS_VAR_IF([php_cv_have_stack_limit], [yes],
331+
[AC_DEFINE([ZEND_CHECK_STACK_LIMIT], [1],
332+
[Define to 1 if checking the stack limit is supported.])])
333+
])
334+
329335
dnl
330336
dnl ZEND_CHECK_GLOBAL_REGISTER_VARIABLES
331337
dnl

0 commit comments

Comments
 (0)