Skip to content

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

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
Sep 29, 2023
Merged
Show file tree
Hide file tree
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
33 changes: 33 additions & 0 deletions Zend/zend_call_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ typedef int boolean_t;
# include <sys/sysctl.h>
# include <sys/syscall.h>
#endif
#ifdef __HAIKU__
# include <kernel/OS.h>
#endif
#ifdef __linux__
#include <sys/syscall.h>
#endif
Expand Down Expand Up @@ -507,6 +510,32 @@ static bool zend_call_stack_get_openbsd(zend_call_stack *stack)
return false;
}
#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__)
# ifdef HAVE_PTHREAD_GETATTR_NP
Expand Down Expand Up @@ -648,6 +677,10 @@ ZEND_API bool zend_call_stack_get(zend_call_stack *stack)
return true;
}

if (zend_call_stack_get_haiku(stack)) {
return true;
}

return false;
}

Expand Down
3 changes: 3 additions & 0 deletions Zend/zend_call_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ static inline size_t zend_call_stack_default_size(void)
}
return 512 * 1024;
#endif
#ifdef __HAIKU__
return 64 * 4096;
#endif

return 2 * 1024 * 1024;
}
Expand Down