[前][次][番号順一覧][スレッド一覧]

ruby-changes:24738

From: naruse <ko1@a...>
Date: Thu, 23 Aug 2012 11:21:49 +0900 (JST)
Subject: [ruby-changes:24738] naruse:r36789 (ruby_1_9_3): merge revision(s) 35978,36013,36014,36015,36052,36076,36487: [Backport #6898]

naruse	2012-08-23 11:21:38 +0900 (Thu, 23 Aug 2012)

  New Revision: 36789

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36789

  Log:
    merge revision(s) 35978,36013,36014,36015,36052,36076,36487: [Backport #6898]
    
    * thread_pthread.c (ruby_init_stack): use stack info if possible.
    
    * thread_pthread.c (ruby_init_stack): adjust stack size for offset of
      addr from the bottom.
    
    * thread_pthread.c (get_stack): seems stack size does not include
      guard size on Mac OS X.
    
    * gc.h (IS_STACK_DIR_UPPER): utility macro.
    
    * thread_pthread.c (get_stack): Linux is the only OS which includes
      the size of guard page into the stack size.
    
    * thread_pthread.c (ruby_init_stack): STACK_GROW_DIR_DETECTION is
      necessary on platforms with unknown stack direction.  [Bug #6761]

  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/gc.h
    branches/ruby_1_9_3/thread_pthread.c
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 36788)
+++ ruby_1_9_3/ChangeLog	(revision 36789)
@@ -1,3 +1,27 @@
+Thu Aug 23 11:19:51 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread_pthread.c (ruby_init_stack): STACK_GROW_DIR_DETECTION is
+	  necessary on platforms with unknown stack direction.  [Bug #6761]
+
+Thu Aug 23 11:19:51 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 Aug 23 11:19:51 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* gc.h (IS_STACK_DIR_UPPER): utility macro.
+
+	* 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.
+
+Thu Aug 23 11:19:51 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* thread_pthread.c (ruby_init_stack): use stack info if possible.
+
 Mon Aug 20 17:11:01 2012  NARUSE, Yui  <naruse@r...>
 
 	* file.c (file_path_convert): don't convert it when the path string is
Index: ruby_1_9_3/thread_pthread.c
===================================================================
--- ruby_1_9_3/thread_pthread.c	(revision 36788)
+++ ruby_1_9_3/thread_pthread.c	(revision 36789)
@@ -477,41 +477,38 @@
 {
 #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)
+#ifdef HAVE_PTHREAD_GETATTR_NP /* Linux */
     pthread_attr_t attr;
     size_t guard = 0;
-
-# 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
-# else /* MacOS X */
+# 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);
     *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);
 #elif defined HAVE_THR_STKSEGMENT || defined HAVE_PTHREAD_STACKSEG_NP
     stack_t stk;
 # if defined HAVE_THR_STKSEGMENT /* Solaris */
@@ -581,16 +578,18 @@
     {
 	size_t size = 0;
 	size_t space = 0;
-#if defined(HAVE_PTHREAD_ATTR_GET_NP)
-	void* addr;
-	get_stack(&addr, &size);
+#if defined(STACKADDR_AVAILABLE)
+	void* stackaddr;
+	STACK_GROW_DIR_DETECTION;
+	get_stack(&stackaddr, &size);
+	space = STACK_DIR_UPPER((char *)addr - (char *)stackaddr, (char *)stackaddr - (char *)addr);
 #elif defined(HAVE_GETRLIMIT)
 	struct rlimit rlim;
 	if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
 	    size = (size_t)rlim.rlim_cur;
 	}
-#endif
 	space = size > 5 * 1024 * 1024 ? 1024 * 1024 : size / 5;
+#endif
 	native_main_thread.stack_maxsize = size - space;
     }
 }
@@ -1310,7 +1309,7 @@
     }
     size /= 5;
     if (size > water_mark) size = water_mark;
-    if (STACK_DIR_UPPER(1, 0)) {
+    if (IS_STACK_DIR_UPPER()) {
 	if (size > ~(size_t)base+1) size = ~(size_t)base+1;
 	if (addr > base && addr <= (void *)((char *)base + size)) return 1;
     }
Index: ruby_1_9_3/gc.h
===================================================================
--- ruby_1_9_3/gc.h	(revision 36788)
+++ ruby_1_9_3/gc.h	(revision 36789)
@@ -81,6 +81,7 @@
 #define STACK_GROW_DIR_DETECTION VALUE stack_grow_dir_detection
 #define STACK_DIR_UPPER(a,b) STACK_UPPER(&stack_grow_dir_detection, (a), (b))
 #endif
+#define IS_STACK_DIR_UPPER() STACK_DIR_UPPER(1,0)
 
 #if defined __GNUC__ && __GNUC__ >= 4
 #pragma GCC visibility push(default)
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 36788)
+++ ruby_1_9_3/version.h	(revision 36789)
@@ -1,10 +1,10 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 261
+#define RUBY_PATCHLEVEL 262
 
-#define RUBY_RELEASE_DATE "2012-08-20"
+#define RUBY_RELEASE_DATE "2012-08-23"
 #define RUBY_RELEASE_YEAR 2012
 #define RUBY_RELEASE_MONTH 8
-#define RUBY_RELEASE_DAY 20
+#define RUBY_RELEASE_DAY 23
 
 #include "ruby/version.h"
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]