$OpenBSD: patch-jsnativestack_cpp,v 1.1.1.1 2012/04/07 13:48:18 landry Exp $
--- jsnativestack.cpp.orig	Thu Mar 31 21:08:36 2011
+++ jsnativestack.cpp	Sun Apr  3 12:38:25 2011
@@ -50,7 +50,7 @@
 #elif defined(XP_MACOSX) || defined(DARWIN) || defined(XP_UNIX)
 # include <pthread.h>
 
-# if defined(__FreeBSD__)
+# if defined(__FreeBSD__) || defined (__OpenBSD__)
 #  include <pthread_np.h>
 # endif
 
@@ -198,24 +198,21 @@ GetNativeStackBaseImpl()
     pthread_attr_init(&sattr);
 #  if defined(PTHREAD_NP_H) || defined(_PTHREAD_NP_H_) || defined(NETBSD)
     /* e.g. on FreeBSD 4.8 or newer, neundorf@kde.org */
-    pthread_attr_get_np(thread, &sattr);
 #  else
     /*
      * FIXME: this function is non-portable;
      * other POSIX systems may have different np alternatives
      */
-    pthread_getattr_np(thread, &sattr);
 #  endif
 
     void *stackBase = 0;
     size_t stackSize = 0;
-#  ifdef DEBUG
-    int rc = 
-#  endif
-        pthread_attr_getstack(&sattr, &stackBase, &stackSize);
-    JS_ASSERT(!rc);
-    JS_ASSERT(stackBase);
-    pthread_attr_destroy(&sattr);
+	stack_t ss;
+	int rslt;
+
+	rslt = pthread_stackseg_np(pthread_self(), &ss);
+	stackBase = (void*)((size_t)ss.ss_sp - ss.ss_size);
+	stackSize = ss.ss_size;
 
 #  if JS_STACK_GROWTH_DIRECTION > 0
     return stackBase;
