zend call stack support for haiku w/o using posix pthread api but the (#12103)

underlying native BeOs one.
This commit is contained in:
David CARLIER 2023-09-29 11:47:23 +01:00 committed by GitHub
parent 569b95d2c3
commit 14b827049a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 0 deletions

View file

@ -55,6 +55,9 @@ typedef int boolean_t;
# include <sys/sysctl.h> # include <sys/sysctl.h>
# include <sys/syscall.h> # include <sys/syscall.h>
#endif #endif
#ifdef __HAIKU__
# include <kernel/OS.h>
#endif
#ifdef __linux__ #ifdef __linux__
#include <sys/syscall.h> #include <sys/syscall.h>
#endif #endif
@ -507,6 +510,32 @@ static bool zend_call_stack_get_openbsd(zend_call_stack *stack)
return false; return false;
} }
#endif /* defined(__OpenBSD__) */ #endif /* defined(__OpenBSD__) */
#if defined(__HAIKU__)
static bool zend_call_stack_get_haiku(zend_call_stack *stack)
{
thread_id id;
thread_info ti;
size_t guard_size;
// unlikely, main thread ought to be always available but we never know
if ((id = find_thread(NULL)) == B_NAME_NOT_FOUND || get_thread_info(id, &ti) != B_OK) {
return false;
}
// USER_STACK_GUARD_SIZE
guard_size = sysconf(_SC_PAGESIZE) * 4;
stack->base = ti.stack_end;
stack->max_size = ((size_t)ti.stack_end - (size_t)ti.stack_base) - guard_size;
return true;
}
#else
static bool zend_call_stack_get_haiku(zend_call_stack *stack)
{
return false;
}
#endif /* defined(__HAIKU__) */
#if defined(__NetBSD__) #if defined(__NetBSD__)
# ifdef HAVE_PTHREAD_GETATTR_NP # ifdef HAVE_PTHREAD_GETATTR_NP
@ -648,6 +677,10 @@ ZEND_API bool zend_call_stack_get(zend_call_stack *stack)
return true; return true;
} }
if (zend_call_stack_get_haiku(stack)) {
return true;
}
return false; return false;
} }

View file

@ -86,6 +86,9 @@ static inline size_t zend_call_stack_default_size(void)
} }
return 512 * 1024; return 512 * 1024;
#endif #endif
#ifdef __HAIKU__
return 64 * 4096;
#endif
return 2 * 1024 * 1024; return 2 * 1024 * 1024;
} }