mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
22ba8368ae
commit
fb15c0f16c
2 changed files with 25 additions and 9 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Wed Feb 3 12:30:10 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* 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@ruby-lang.org>
|
Wed Feb 3 11:38:44 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* ext/dl/{closure,function}.c: removed C99 features and warnings.
|
* ext/dl/{closure,function}.c: removed C99 features and warnings.
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
#ifdef THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION
|
#ifdef THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION
|
||||||
|
|
||||||
#include "gc.h"
|
#include "gc.h"
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <pthread_np.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SYS_RESOURCE_H
|
#ifdef HAVE_SYS_RESOURCE_H
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
|
@ -292,18 +295,24 @@ ruby_init_stack(volatile VALUE *addr
|
||||||
native_main_thread.register_stack_start = (VALUE*)bsp;
|
native_main_thread.register_stack_start = (VALUE*)bsp;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_GETRLIMIT
|
|
||||||
{
|
{
|
||||||
struct rlimit rlim;
|
size_t size = 0, space = 0;
|
||||||
|
#ifdef __FreeBSD__
|
||||||
if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
|
pthread_attr_t attr;
|
||||||
size_t space = (size_t)(rlim.rlim_cur/5);
|
if (pthread_attr_init(&attr) == 0) {
|
||||||
|
pthread_attr_get_np(native_main_thread.id, &attr) ||
|
||||||
if (space > 1024*1024) space = 1024*1024;
|
pthread_attr_getstacksize(&attr, &size);
|
||||||
native_main_thread.stack_maxsize = (size_t)rlim.rlim_cur - space;
|
pthread_attr_destroy(&attr);
|
||||||
|
}
|
||||||
|
#elif defined(HAVE_GETRLIMIT)
|
||||||
|
struct rlimit rlim;
|
||||||
|
if (getrlimit(RLIMIT_STACK, &rlim) == 0) {
|
||||||
|
size = (size_t)rlim.rlim_cur;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
space = size > 5 * 1024 * 1024 ? 1024 * 1024 : size / 5;
|
||||||
|
native_main_thread.stack_maxsize = size - space;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_ERR(expr) \
|
#define CHECK_ERR(expr) \
|
||||||
|
|
Loading…
Add table
Reference in a new issue