19#ifndef ZEND_CALL_STACK_H
20#define ZEND_CALL_STACK_H
28#ifdef ZEND_CHECK_STACK_LIMIT
30typedef struct _zend_call_stack {
35ZEND_API void zend_call_stack_init(
void);
37ZEND_API bool zend_call_stack_get(zend_call_stack *stack);
42 return _AddressOfReturnAddress();
43#elif defined(PHP_HAVE_BUILTIN_FRAME_ADDRESS)
44 return __builtin_frame_address(0);
47 void *
pos = (
void*)&
a;
53 return (uintptr_t) zend_call_stack_position() <= (uintptr_t) stack_limit;
56static inline void* zend_call_stack_limit(
void *base,
size_t size,
size_t reserved_size)
62 base = (int8_t*)base -
size;
64 if (
UNEXPECTED(UINTPTR_MAX - (uintptr_t)base < reserved_size)) {
65 return (
void*)UINTPTR_MAX;
68 return (int8_t*)base + reserved_size;
71static inline size_t zend_call_stack_default_size(
void)
74 return 8 * 1024 * 1024;
76#if defined(__FreeBSD__) || defined(__NetBSD__)
77 return 4 * 1024 * 1024;
79#if defined(__DragonFly__)
80 return 2 * 1024 * 1024;
87 if (pthread_main_np()) {
88 return 8 * 1024 * 1024;
99 return 2 * 1024 * 1024;
unsigned const char * pos
#define zend_always_inline
#define UNEXPECTED(condition)