From d110e1f264a271612d4f02ed86cd2dd471e70a20 Mon Sep 17 00:00:00 2001
From: Emmanuel Maillard <e.rsz@libertysurf.fr>
Date: Wed, 21 Jul 2004 03:06:03 +0000
Subject: [PATCH] wine_pthread_init_thread: retrieve the stack info on Darwin.

---
 configure           | 8 +++++++-
 configure.ac        | 8 ++++++--
 include/config.h.in | 6 ++++++
 loader/pthread.c    | 3 +++
 4 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index e3083ff2f01..9e8591c2b2f 100755
--- a/configure
+++ b/configure
@@ -11133,7 +11133,13 @@ fi
 ac_save_LIBS="$LIBS"
 LIBS="$LIBS $LIBPTHREAD"
 
-for ac_func in pthread_getattr_np
+
+
+for ac_func in \
+        pthread_getattr_np \
+        pthread_get_stackaddr_np \
+        pthread_get_stacksize_np \
+
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
diff --git a/configure.ac b/configure.ac
index 9e0a42f61f5..2a2619e587a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -548,10 +548,14 @@ dnl **** Check for pthread_rwlock_t ****
 AC_CHECK_TYPES([pthread_rwlock_t, pthread_rwlockattr_t],,,[#define _GNU_SOURCE
 #include <pthread.h>])
 
-dnl **** Check for pthread_getattr_np ****
+dnl **** Check for pthread functions ****
 ac_save_LIBS="$LIBS"
 LIBS="$LIBS $LIBPTHREAD"
-AC_CHECK_FUNCS(pthread_getattr_np)
+AC_CHECK_FUNCS(\
+        pthread_getattr_np \
+        pthread_get_stackaddr_np \
+        pthread_get_stacksize_np \
+)
 LIBS="$ac_save_LIBS"
 
 dnl **** Check for Open Sound System ****
diff --git a/include/config.h.in b/include/config.h.in
index 9e5302a1737..feb19052ae3 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -449,6 +449,12 @@
 /* Define to 1 if you have the `pthread_getattr_np' function. */
 #undef HAVE_PTHREAD_GETATTR_NP
 
+/* Define to 1 if you have the `pthread_get_stackaddr_np' function. */
+#undef HAVE_PTHREAD_GET_STACKADDR_NP
+
+/* Define to 1 if you have the `pthread_get_stacksize_np' function. */
+#undef HAVE_PTHREAD_GET_STACKSIZE_NP
+
 /* Define to 1 if you have the <pthread.h> header file. */
 #undef HAVE_PTHREAD_H
 
diff --git a/loader/pthread.c b/loader/pthread.c
index af3386f2f46..148438bae3a 100644
--- a/loader/pthread.c
+++ b/loader/pthread.c
@@ -69,6 +69,9 @@ void wine_pthread_init_thread( struct wine_pthread_thread_info *info )
         pthread_attr_t attr;
         pthread_getattr_np( pthread_self(), &attr );
         pthread_attr_getstack( &attr, &info->stack_base, &info->stack_size );
+#elif defined(HAVE_PTHREAD_GET_STACKSIZE_NP) && defined(HAVE_PTHREAD_GET_STACKADDR_NP)
+        info->stack_size = pthread_get_stacksize_np(pthread_self());
+        info->stack_base = pthread_get_stackaddr_np(pthread_self());
 #else
         /* assume that the stack allocation is page aligned */
         char dummy;
-- 
GitLab