diff options
author | nipos <ni.pos@yandex.com> | 2023-02-19 10:24:05 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-19 11:44:45 +0100 |
commit | c42e949f5bc652c9894b67bdacbfb4d03ce5091c (patch) | |
tree | 914e4bef4221b1d3e76995a79de6b37377f5a060 | |
parent | 85287fcc1e372ee69ec06719e296bb25a401d02f (diff) | |
download | serenity-c42e949f5bc652c9894b67bdacbfb4d03ce5091c.zip |
AK/StackInfo: Add support for OpenBSD pthreads
-rw-r--r-- | AK/StackInfo.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/AK/StackInfo.cpp b/AK/StackInfo.cpp index 80e1d4271c..9b92e471d8 100644 --- a/AK/StackInfo.cpp +++ b/AK/StackInfo.cpp @@ -14,7 +14,7 @@ # include <serenity.h> #elif defined(AK_OS_LINUX) or defined(AK_OS_MACOS) # include <pthread.h> -#elif defined(AK_OS_FREEBSD) +#elif defined(AK_OS_FREEBSD) or defined(AK_OS_OPENBSD) # include <pthread.h> # include <pthread_np.h> #endif @@ -67,6 +67,16 @@ StackInfo::StackInfo() m_size = eight_megabytes; } m_base = top_of_stack - m_size; +#elif defined(AK_OS_OPENBSD) + int rc; + stack_t thread_stack; + if ((rc = pthread_stackseg_np(pthread_self(), &thread_stack)) != 0) { + fprintf(stderr, "pthread_stackseg_np: %s\n", strerror(rc)); + VERIFY_NOT_REACHED(); + } + FlatPtr top_of_stack = (FlatPtr)thread_stack.ss_sp; + m_size = (size_t)thread_stack.ss_size; + m_base = top_of_stack - m_size; #else # pragma message "StackInfo not supported on this platform! Recursion checks and stack scans may not work properly" m_size = (size_t)~0; |