ruby-changes:23963
From: nobu <ko1@a...>
Date: Sun, 10 Jun 2012 17:54:43 +0900 (JST)
Subject: [ruby-changes:23963] nobu:r36014 (trunk): thread_pthread.c: adjust stack size
nobu 2012-06-10 17:54:32 +0900 (Sun, 10 Jun 2012) New Revision: 36014 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36014 Log: thread_pthread.c: adjust stack size * thread_pthread.c (get_stack): seems stack size does not include guard size on Mac OS X. Modified files: trunk/ChangeLog trunk/thread_pthread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 36013) +++ ChangeLog (revision 36014) @@ -1,5 +1,8 @@ -Sun Jun 10 17:54:26 2012 Nobuyoshi Nakada <nobu@r...> +Sun Jun 10 17:54:31 2012 Nobuyoshi Nakada <nobu@r...> + * 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. Index: thread_pthread.c =================================================================== --- thread_pthread.c (revision 36013) +++ thread_pthread.c (revision 36014) @@ -503,8 +503,7 @@ { #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 @@ 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 */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/