Skip to content

Wrap stack direction check in Zend M4 macro #14694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 33 additions & 27 deletions Zend/Zend.m4
Original file line number Diff line number Diff line change
Expand Up @@ -167,33 +167,7 @@ AC_CHECK_FUNCS([sigsetjmp],,
[AC_DEFINE([HAVE_SIGSETJMP], [1])],,
[#include <setjmp.h>])])

dnl Test whether the stack grows downwards
dnl Assumes contiguous stack
AC_CACHE_CHECK([whether the stack grows downwards], [php_cv_have_stack_limit],
[AC_RUN_IFELSE([AC_LANG_SOURCE([
#include <stdint.h>

int (*volatile f)(uintptr_t);

int stack_grows_downwards(uintptr_t arg) {
int local;
return (uintptr_t)&local < arg;
}

int main(void) {
int local;

f = stack_grows_downwards;
return f((uintptr_t)&local) ? 0 : 1;
}
])],
[php_cv_have_stack_limit=yes],
[php_cv_have_stack_limit=no],
[php_cv_have_stack_limit=no])])
AS_VAR_IF([php_cv_have_stack_limit], [yes],
[AC_DEFINE([ZEND_CHECK_STACK_LIMIT], [1],
[Define to 1 if checking the stack limit is supported.])])

ZEND_CHECK_STACK_DIRECTION
ZEND_CHECK_FLOAT_PRECISION
ZEND_DLSYM_CHECK
ZEND_CHECK_GLOBAL_REGISTER_VARIABLES
Expand Down Expand Up @@ -326,6 +300,38 @@ AC_MSG_CHECKING(whether to enable zend max execution timers)
AC_MSG_RESULT($ZEND_MAX_EXECUTION_TIMERS)
])

dnl
dnl ZEND_CHECK_STACK_DIRECTION
dnl
dnl Check whether the stack grows downwards, assumes contiguous stack.
dnl
AC_DEFUN([ZEND_CHECK_STACK_DIRECTION],
[AC_CACHE_CHECK([whether the stack grows downwards],
[php_cv_have_stack_limit],
[AC_RUN_IFELSE([AC_LANG_SOURCE([dnl
#include <stdint.h>

int (*volatile f)(uintptr_t);

int stack_grows_downwards(uintptr_t arg) {
int local;
return (uintptr_t)&local < arg;
}

int main(void) {
int local;

f = stack_grows_downwards;
return f((uintptr_t)&local) ? 0 : 1;
}])],
[php_cv_have_stack_limit=yes],
[php_cv_have_stack_limit=no],
[php_cv_have_stack_limit=no])])
AS_VAR_IF([php_cv_have_stack_limit], [yes],
[AC_DEFINE([ZEND_CHECK_STACK_LIMIT], [1],
[Define to 1 if checking the stack limit is supported.])])
])

dnl
dnl ZEND_CHECK_GLOBAL_REGISTER_VARIABLES
dnl
Expand Down
Loading