diff --git a/src/coreclr/pal/src/thread/thread.cpp b/src/coreclr/pal/src/thread/thread.cpp index 7e9c3baa6a0cd1..f7174e69ba5be0 100644 --- a/src/coreclr/pal/src/thread/thread.cpp +++ b/src/coreclr/pal/src/thread/thread.cpp @@ -1423,7 +1423,7 @@ CPalThread::ThreadEntry( // vendor-modified Android kernels with strict SELinux policy) block // sched_setaffinity even when passed a mask extracted via sched_getaffinity. // Treat this as non-fatal — the thread will continue running on any - // available CPU rather than the originally affinitized one. + // available CPU rather than the originally affinitized one. WARN("sched_setaffinity failed with EPERM/EACCES, ignoring\n"); } else @@ -2316,6 +2316,12 @@ CPalThread::GetStackBase() #ifdef TARGET_APPLE // This is a Mac specific method stackBase = pthread_get_stackaddr_np(pthread_self()); +#elif defined(TARGET_OPENBSD) + stack_t stack; + int status = pthread_stackseg_np(pthread_self(), &stack); + _ASSERT_MSG(status == 0, "pthread_stackseg_np call failed"); + + stackBase = stack.ss_sp; #else pthread_attr_t attr; void* stackAddr; @@ -2361,6 +2367,12 @@ CPalThread::GetStackLimit() // This is a Mac specific method stackLimit = ((BYTE *)pthread_get_stackaddr_np(pthread_self()) - pthread_get_stacksize_np(pthread_self())); +#elif defined(TARGET_OPENBSD) + stack_t stack; + int status = pthread_stackseg_np(pthread_self(), &stack); + _ASSERT_MSG(status == 0, "pthread_stackseg_np call failed"); + + stackLimit = (void*)stack.ss_size; #else pthread_attr_t attr; size_t stackSize;