--- js/src/jsnativestack.cpp.orig	2011-03-31 12:08:36.000000000 -0700
+++ js/src/jsnativestack.cpp	2012-10-15 13:03:20.000000000 -0700
@@ -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,7 +198,9 @@
     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);
+#   if (!defined(__OpenBSD__))
+     pthread_attr_get_np(thread, &sattr);
+#   endif
 #  else
     /*
      * FIXME: this function is non-portable;
@@ -209,14 +211,24 @@
 
     void *stackBase = 0;
     size_t stackSize = 0;
-#  ifdef DEBUG
-    int rc = 
-#  endif
+#  if defined(__OpenBSD__)
+	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;
+#  else
+#   ifdef DEBUG
+     int rc = 
+#   endif
         pthread_attr_getstack(&sattr, &stackBase, &stackSize);
     JS_ASSERT(!rc);
     JS_ASSERT(stackBase);
     pthread_attr_destroy(&sattr);
 
+#  endif
+
 #  if JS_STACK_GROWTH_DIRECTION > 0
     return stackBase;
 #  else
