ruby-changes:24025
From: naruse <ko1@a...>
Date: Thu, 14 Jun 2012 08:18:45 +0900 (JST)
Subject: [ruby-changes:24025] naruse:r36076 (trunk): * thread_pthread.c (get_stack): Linux is the only OS which includes
naruse 2012-06-14 08:18:35 +0900 (Thu, 14 Jun 2012) New Revision: 36076 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36076 Log: * thread_pthread.c (get_stack): Linux is the only OS which includes the size of guard page into the stack size. Modified files: trunk/ChangeLog trunk/thread_pthread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 36075) +++ ChangeLog (revision 36076) @@ -1,3 +1,8 @@ +Thu Jun 14 07:59:12 2012 NARUSE, Yui <naruse@r...> + + * thread_pthread.c (get_stack): Linux is the only OS which includes + the size of guard page into the stack size. + Thu Jun 14 06:21:00 2012 Eric Hodel <drbrain@s...> * lib/drb/drb.rb: Replace broken links to the English DRb book. Index: thread_pthread.c =================================================================== --- thread_pthread.c (revision 36075) +++ thread_pthread.c (revision 36076) @@ -507,37 +507,34 @@ { #define CHECK_ERR(expr) \ {int err = (expr); if (err) return err;} -#if defined HAVE_PTHREAD_GETATTR_NP || defined HAVE_PTHREAD_ATTR_GET_NP +#ifdef HAVE_PTHREAD_GETATTR_NP /* Linux */ pthread_attr_t attr; -# if defined HAVE_PTHREAD_ATTR_GET_NP /* HAVE_PTHREAD_ATTR_GETGUARDSIZE */ size_t guard = 0; -# endif - -# ifdef HAVE_PTHREAD_GETATTR_NP /* Linux */ STACK_GROW_DIR_DETECTION; CHECK_ERR(pthread_getattr_np(pthread_self(), &attr)); -# ifdef HAVE_PTHREAD_ATTR_GETSTACK +# ifdef HAVE_PTHREAD_ATTR_GETSTACK CHECK_ERR(pthread_attr_getstack(&attr, addr, size)); STACK_DIR_UPPER((void)0, (void)(*addr = (char *)*addr + *size)); -# else +# else CHECK_ERR(pthread_attr_getstackaddr(&attr, addr)); CHECK_ERR(pthread_attr_getstacksize(&attr, size)); -# endif -# elif defined HAVE_PTHREAD_ATTR_GET_NP /* FreeBSD, DragonFly BSD, NetBSD */ +# endif + CHECK_ERR(pthread_attr_getguardsize(&attr, &guard)); + *size -= guard; + pthread_attr_destroy(&attr); +#elif defined HAVE_PTHREAD_ATTR_GET_NP /* FreeBSD, DragonFly BSD, NetBSD */ + pthread_attr_t attr; CHECK_ERR(pthread_attr_init(&attr)); CHECK_ERR(pthread_attr_get_np(pthread_self(), &attr)); -# ifdef HAVE_PTHREAD_ATTR_GETSTACK +# ifdef HAVE_PTHREAD_ATTR_GETSTACK CHECK_ERR(pthread_attr_getstack(&attr, addr, size)); STACK_DIR_UPPER((void)0, (void)(*addr = (char *)*addr + *size)); -# else +# else CHECK_ERR(pthread_attr_getstackaddr(&attr, addr)); CHECK_ERR(pthread_attr_getstacksize(&attr, size)); STACK_DIR_UPPER((void)0, (void)(*addr = (char *)*addr + *size)); -# endif - CHECK_ERR(pthread_attr_getguardsize(&attr, &guard)); - *size -= guard; - pthread_attr_destroy(&attr); # endif + pthread_attr_destroy(&attr); #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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/