openbsd-ports/devel/spidermonkey/patches/patch-jsnativestack_cpp
2012-09-17 06:00:09 +00:00

38 lines
1.2 KiB
Plaintext

$OpenBSD: patch-jsnativestack_cpp,v 1.2 2012/09/17 06:00:09 ajacoutot Exp $
--- jsnativestack.cpp.orig Thu Mar 31 21:08:36 2011
+++ jsnativestack.cpp Sat Sep 15 18:10:03 2012
@@ -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 @@ GetNativeStackBaseImpl()
# 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 @@ GetNativeStackBaseImpl()
# 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);