$OpenBSD: patch-Source_JavaScriptCore_heap_MachineStackMarker_cpp,v 1.5 2014/09/28 06:52:14 ajacoutot Exp $

https://bugs.webkit.org/show_bug.cgi?id=129965

--- Source/JavaScriptCore/heap/MachineStackMarker.cpp.orig	Tue Feb  4 17:38:03 2014
+++ Source/JavaScriptCore/heap/MachineStackMarker.cpp	Fri Feb 14 20:41:39 2014
@@ -352,8 +352,10 @@ static size_t getPlatformThreadRegisters(const Platfor
 #elif USE(PTHREADS)
     pthread_attr_init(&regs);
 #if HAVE(PTHREAD_NP_H) || OS(NETBSD)
+#  ifndef __OpenBSD__
     // e.g. on FreeBSD 5.4, neundorf@kde.org
     pthread_attr_get_np(platformThread, &regs);
+#  endif
 #else
     // FIXME: this function is non-portable; other POSIX systems may have different np alternatives
     pthread_getattr_np(platformThread, &regs);
@@ -416,7 +418,14 @@ static inline void* otherThreadStackPointer(const Plat
 #elif USE(PTHREADS)
     void* stackBase = 0;
     size_t stackSize = 0;
+# if defined(__OpenBSD__)
+    stack_t ss;
+    int rc = pthread_stackseg_np(pthread_self(), &ss);
+    stackBase = (void*)((size_t) ss.ss_sp - ss.ss_size);
+    stackSize = ss.ss_size;
+#else
     int rc = pthread_attr_getstack(&regs, &stackBase, &stackSize);
+#endif
     (void)rc; // FIXME: Deal with error code somehow? Seems fatal.
     ASSERT(stackBase);
     return static_cast<char*>(stackBase) + stackSize;
