1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2012-06-10 08:54:32 +00:00
parent 35c96b9003
commit 068dafd21f
2 changed files with 10 additions and 9 deletions

View file

@ -1,4 +1,7 @@
Sun Jun 10 17:54:26 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> Sun Jun 10 17:54:31 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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 * thread_pthread.c (ruby_init_stack): adjust stack size for offset of
addr from the bottom. addr from the bottom.

View file

@ -503,8 +503,7 @@ get_stack(void **addr, size_t *size)
{ {
#define CHECK_ERR(expr) \ #define CHECK_ERR(expr) \
{int err = (expr); if (err) return err;} {int err = (expr); if (err) return err;}
#if defined HAVE_PTHREAD_GETATTR_NP || defined HAVE_PTHREAD_ATTR_GET_NP || \ #if defined HAVE_PTHREAD_GETATTR_NP || defined HAVE_PTHREAD_ATTR_GET_NP
(defined HAVE_PTHREAD_GET_STACKADDR_NP && defined HAVE_PTHREAD_GET_STACKSIZE_NP)
pthread_attr_t attr; pthread_attr_t attr;
size_t guard = 0; size_t guard = 0;
@ -529,15 +528,14 @@ get_stack(void **addr, size_t *size)
CHECK_ERR(pthread_attr_getstacksize(&attr, size)); CHECK_ERR(pthread_attr_getstacksize(&attr, size));
STACK_DIR_UPPER((void)0, (void)(*addr = (char *)*addr + *size)); STACK_DIR_UPPER((void)0, (void)(*addr = (char *)*addr + *size));
# endif # 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)); CHECK_ERR(pthread_attr_getguardsize(&attr, &guard));
*size -= guard; *size -= guard;
pthread_attr_destroy(&attr); 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 #elif defined HAVE_THR_STKSEGMENT || defined HAVE_PTHREAD_STACKSEG_NP
stack_t stk; stack_t stk;
# if defined HAVE_THR_STKSEGMENT /* Solaris */ # if defined HAVE_THR_STKSEGMENT /* Solaris */