--- js-1.8.5/js/src/jsnativestack.cpp
+++ js-1.8.5/js/src/jsnativestack.cpp
@@ -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
 
@@ -196,7 +196,9 @@
 # else
     pthread_attr_t sattr;
     pthread_attr_init(&sattr);
-#  if defined(PTHREAD_NP_H) || defined(_PTHREAD_NP_H_) || defined(NETBSD)
+#  if defined(__OpenBSD__)
+    stack_t ss;
+#  elif 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
@@ -212,7 +214,13 @@
 #  ifdef DEBUG
     int rc = 
 #  endif
+# if defined(__OpenBSD__)
+        pthread_stackseg_np(pthread_self(), &ss);
+    stackBase = (void*)((size_t) ss.ss_sp - ss.ss_size);
+    stackSize = ss.ss_size;
+# else
         pthread_attr_getstack(&sattr, &stackBase, &stackSize);
+# endif
     JS_ASSERT(!rc);
     JS_ASSERT(stackBase);
     pthread_attr_destroy(&sattr);
