summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authordas <das>2006-10-16 18:41:25 (GMT)
committerdas <das>2006-10-16 18:41:25 (GMT)
commit500354bed1dd1c346a7638475fdd9a3c4be70184 (patch)
treee9f59b4bacf228f286426398eabb8b58a1505d0f /unix
parent83ed8e2d6b100cc7247aea88a50772356195200e (diff)
downloadtcl-500354bed1dd1c346a7638475fdd9a3c4be70184.zip
tcl-500354bed1dd1c346a7638475fdd9a3c4be70184.tar.gz
tcl-500354bed1dd1c346a7638475fdd9a3c4be70184.tar.bz2
* unix/tclUnixThrd.c (TclpThreadGetStackSize): Darwin: fix for main
thread, where pthread_get_stacksize_np() returns incorrect info. * macosx/GNUmakefile: don't redo prebinding of non-prebound binaires.
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixThrd.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index 57795ab..adc508f 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -215,10 +215,10 @@ TclpThreadExit(
int
TclpThreadGetStackSize(void)
{
+ size_t stackSize = 0;
#if defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && defined(TclpPthreadGetAttrs)
pthread_attr_t threadAttr; /* This will hold the thread attributes for
* the current thread. */
- size_t stackSize;
if (pthread_attr_init(&threadAttr) != 0) {
return -1;
@@ -232,17 +232,22 @@ TclpThreadGetStackSize(void)
return -1;
}
pthread_attr_destroy(&threadAttr);
- return (int) stackSize;
#elif defined(HAVE_PTHREAD_GET_STACKSIZE_NP)
- return (int) pthread_get_stacksize_np(pthread_self());
+#ifdef __APPLE__
+ /*
+ * On Darwin, the API below does not return the correct stack size for the
+ * main thread (which is not a real pthread), so fallback to getrlimit().
+ */
+ if (!pthread_main_np())
+#endif
+ stackSize = pthread_get_stacksize_np(pthread_self());
#else
/*
* Cannot determine the real stack size of this thread. The caller might
* want to try looking at the process accounting limits instead.
*/
-
- return 0;
#endif
+ return (int) stackSize;
}
#endif /* TCL_THREADS */