mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
zend stack: prepare zend_call_stack_get implementation for OpenBSD. (#11578)
This commit is contained in:
parent
49864198cc
commit
75e9980054
2 changed files with 30 additions and 2 deletions
|
@ -146,7 +146,7 @@ _LT_AC_TRY_DLOPEN_SELF([
|
||||||
])
|
])
|
||||||
|
|
||||||
dnl Checks for library functions.
|
dnl Checks for library functions.
|
||||||
AC_CHECK_FUNCS(getpid kill sigsetjmp pthread_getattr_np pthread_attr_get_np pthread_get_stackaddr_np pthread_attr_getstack gettid)
|
AC_CHECK_FUNCS(getpid kill sigsetjmp pthread_getattr_np pthread_attr_get_np pthread_get_stackaddr_np pthread_attr_getstack pthread_stackseg_np gettid)
|
||||||
|
|
||||||
dnl Test whether the stack grows downwards
|
dnl Test whether the stack grows downwards
|
||||||
dnl Assumes contiguous stack
|
dnl Assumes contiguous stack
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# endif
|
# endif
|
||||||
#endif /* ZEND_WIN32 */
|
#endif /* ZEND_WIN32 */
|
||||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
|
#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) || defined(__OpenBSD__)
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
|
@ -44,6 +44,9 @@
|
||||||
# include <sys/sysctl.h>
|
# include <sys/sysctl.h>
|
||||||
# include <sys/user.h>
|
# include <sys/user.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
# include <pthread_np.h>
|
||||||
|
#endif
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -432,6 +435,27 @@ static bool zend_call_stack_get_macos(zend_call_stack *stack)
|
||||||
}
|
}
|
||||||
#endif /* defined(__APPLE__) && defined(HAVE_PTHREAD_GET_STACKADDR_NP) */
|
#endif /* defined(__APPLE__) && defined(HAVE_PTHREAD_GET_STACKADDR_NP) */
|
||||||
|
|
||||||
|
#if defined(HAVE_PTHREAD_STACKSEG_NP)
|
||||||
|
static bool zend_call_stack_get_openbsd(zend_call_stack *stack)
|
||||||
|
{
|
||||||
|
stack_t ss;
|
||||||
|
|
||||||
|
if (pthread_stackseg_np(pthread_self(), &ss) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
stack->base = (char *)ss.ss_sp - ss.ss_size;
|
||||||
|
stack->max_size = ss.ss_size - sysconf(_SC_PAGE_SIZE);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static bool zend_call_stack_get_openbsd(zend_call_stack *stack)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif /* defined(HAVE_PTHREAD_STACKSEG_NP) */
|
||||||
|
|
||||||
/** Get the stack information for the calling thread */
|
/** Get the stack information for the calling thread */
|
||||||
ZEND_API bool zend_call_stack_get(zend_call_stack *stack)
|
ZEND_API bool zend_call_stack_get(zend_call_stack *stack)
|
||||||
{
|
{
|
||||||
|
@ -451,6 +475,10 @@ ZEND_API bool zend_call_stack_get(zend_call_stack *stack)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (zend_call_stack_get_openbsd(stack)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue