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

ruby-changes:14695

From: naruse <ko1@a...>
Date: Wed, 3 Feb 2010 12:35:26 +0900 (JST)
Subject: [ruby-changes:14695] Ruby:r26549 (trunk): * thread_pthread.c (ruby_init_stack): use pthread_get_attr_np

naruse	2010-02-03 12:35:11 +0900 (Wed, 03 Feb 2010)

  New Revision: 26549

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

  Log:
    * thread_pthread.c (ruby_init_stack): use pthread_get_attr_np
      to get the stack size of the main thread on FreeBSD.
    
    * thread_pthread.c: include pthread_np.h on FreeBSD.

  Modified files:
    trunk/ChangeLog
    trunk/thread_pthread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26548)
+++ ChangeLog	(revision 26549)
@@ -1,3 +1,10 @@
+Wed Feb  3 12:30:10 2010  NARUSE, Yui  <naruse@r...>
+
+	* thread_pthread.c (ruby_init_stack): use pthread_get_attr_np
+	  to get the stack size of the main thread on FreeBSD.
+
+	* thread_pthread.c: include pthread_np.h on FreeBSD.
+
 Wed Feb  3 11:38:44 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/dl/{closure,function}.c: removed C99 features and warnings.
Index: thread_pthread.c
===================================================================
--- thread_pthread.c	(revision 26548)
+++ thread_pthread.c	(revision 26549)
@@ -12,6 +12,9 @@
 #ifdef THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION
 
 #include "gc.h"
+#ifdef __FreeBSD__
+#include <pthread_np.h>
+#endif
 
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
@@ -292,18 +295,24 @@
         native_main_thread.register_stack_start = (VALUE*)bsp;
     }
 #endif
-#ifdef HAVE_GETRLIMIT
     {
+	size_t size = 0, space = 0;
+#ifdef __FreeBSD__
+	pthread_attr_t attr;
+	if (pthread_attr_init(&attr) == 0) {
+	    pthread_attr_get_np(native_main_thread.id, &attr) ||
+		pthread_attr_getstacksize(&attr, &size);
+	    pthread_attr_destroy(&attr);
+	}
+#elif defined(HAVE_GETRLIMIT)
 	struct rlimit rlim;
-
 	if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
-	    size_t space = (size_t)(rlim.rlim_cur/5);
-
-	    if (space > 1024*1024) space = 1024*1024;
-	    native_main_thread.stack_maxsize = (size_t)rlim.rlim_cur - space;
+	    size = (size_t)rlim.rlim_cur;
 	}
+#endif
+	space = size > 5 * 1024 * 1024 ? 1024 * 1024 : size / 5;
+	native_main_thread.stack_maxsize = size - space;
     }
-#endif
 }
 
 #define CHECK_ERR(expr) \

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

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