summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-10 08:54:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-10 08:54:32 +0000
commit068dafd21f664e75bbadf958ad976afeeca45326 (patch)
treeddab848114ae4b4556f7027dbbe1ee5ab40d934b /thread_pthread.c
parent35c96b9003ee6c5a6af02113216ff37f7d1ebbaa (diff)
downloadruby-068dafd21f664e75bbadf958ad976afeeca45326.tar.gz
thread_pthread.c: adjust stack size
* thread_pthread.c (get_stack): seems stack size does not include guard size on Mac OS X. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index 8a77d70144..0a37f2fa30 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -503,8 +503,7 @@ get_stack(void **addr, size_t *size)
{
#define CHECK_ERR(expr) \
{int err = (expr); if (err) return err;}
-#if defined HAVE_PTHREAD_GETATTR_NP || defined HAVE_PTHREAD_ATTR_GET_NP || \
- (defined HAVE_PTHREAD_GET_STACKADDR_NP && defined HAVE_PTHREAD_GET_STACKSIZE_NP)
+#if defined HAVE_PTHREAD_GETATTR_NP || defined HAVE_PTHREAD_ATTR_GET_NP
pthread_attr_t attr;
size_t guard = 0;
@@ -529,15 +528,14 @@ get_stack(void **addr, size_t *size)
CHECK_ERR(pthread_attr_getstacksize(&attr, size));
STACK_DIR_UPPER((void)0, (void)(*addr = (char *)*addr + *size));
# endif
-# else /* MacOS X */
- pthread_t th = pthread_self();
- *addr = pthread_get_stackaddr_np(th);
- *size = pthread_get_stacksize_np(th);
- CHECK_ERR(pthread_attr_init(&attr));
-# endif
CHECK_ERR(pthread_attr_getguardsize(&attr, &guard));
*size -= guard;
pthread_attr_destroy(&attr);
+# endif
+#elif (defined HAVE_PTHREAD_GET_STACKADDR_NP && defined HAVE_PTHREAD_GET_STACKSIZE_NP) /* MacOS X */
+ pthread_t th = pthread_self();
+ *addr = pthread_get_stackaddr_np(th);
+ *size = pthread_get_stacksize_np(th);
#elif defined HAVE_THR_STKSEGMENT || defined HAVE_PTHREAD_STACKSEG_NP
stack_t stk;
# if defined HAVE_THR_STKSEGMENT /* Solaris */