GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base *sb)
{
stack_t stack;
- pthread_stackseg_np(pthread_self(), &stack);
+ if (pthread_stackseg_np(pthread_self(), &stack))
+ ABORT("pthread_stackseg_np(self) failed");
sb->mem_base = stack.ss_sp;
return GC_SUCCESS;
}
# endif
# ifdef GC_OPENBSD_THREADS
- if (pthread_suspend_np(p -> id) != 0)
- ABORT("pthread_suspend_np failed");
- /* This will only work for userland pthreads. It will */
- /* fail badly on rthreads. Perhaps we should consider */
- /* a pthread_sp_np() function that returns the stack */
- /* pointer for a suspended thread and implement in both */
- /* pthreads and rthreads. */
- p -> stop_info.stack_ptr =
- *(ptr_t *)((char *)p -> id + UTHREAD_SP_OFFSET);
+ {
+ stack_t stack;
+ if (pthread_suspend_np(p -> id) != 0)
+ ABORT("pthread_suspend_np failed");
+ if (pthread_stackseg_np(p->id, &stack))
+ ABORT("pthread_stackseg_np failed");
+ p -> stop_info.stack_ptr = (ptr_t)stack.ss_sp - stack.ss_size;
+ }
# else
# ifndef PLATFORM_ANDROID
result = pthread_kill(p -> id, SIG_SUSPEND);