From 068dafd21f664e75bbadf958ad976afeeca45326 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 10 Jun 2012 08:54:32 +0000 Subject: [PATCH] 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 --- ChangeLog | 5 ++++- thread_pthread.c | 14 ++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 71fd8e3097..55ebea5c87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,7 @@ -Sun Jun 10 17:54:26 2012 Nobuyoshi Nakada +Sun Jun 10 17:54:31 2012 Nobuyoshi Nakada + + * thread_pthread.c (get_stack): seems stack size does not include + guard size on Mac OS X. * thread_pthread.c (ruby_init_stack): adjust stack size for offset of addr from the bottom. 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 */