diff --git a/Zend/zend_call_stack.h b/Zend/zend_call_stack.h index 566634deeb68..62629e0fd639 100644 --- a/Zend/zend_call_stack.h +++ b/Zend/zend_call_stack.h @@ -27,6 +27,9 @@ #ifdef __APPLE__ # include #endif +#ifdef __FreeBSD__ +# include +#endif #ifdef ZEND_CHECK_STACK_LIMIT @@ -76,7 +79,14 @@ static inline size_t zend_call_stack_default_size(void) #ifdef __linux__ return 8 * 1024 * 1024; #endif -#if defined(__FreeBSD__) || defined(__NetBSD__) +#ifdef __FreeBSD__ + // libthr: THR_STACK_DEFAULT in lib/libthr/thread/thr_private.h + if (pthread_main_np() == 0) { + return sizeof(void *) / 4 * 1024 * 1024; + } + return 4 * 1024 * 1024; +#endif +#ifdef __NetBSD__ return 4 * 1024 * 1024; #endif #if defined(__DragonFly__)