From cbe3646e683e8d1112ff832cfb74ca2aec006991 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 4 Oct 2012 02:39:34 +0000 Subject: [PATCH] * thread_pthread.c (RUBY_STACK_MIN_LIMIT): name magic number. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread_pthread.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/thread_pthread.c b/thread_pthread.c index ab227e32b3..291b2f72a4 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -588,6 +588,26 @@ static struct { #endif } native_main_thread; + +enum { +#ifdef __SYMBIAN32__ + RUBY_STACK_MIN_LIMIT = 64 * 1024, /* 64KB: Let's be slightly more frugal on mobile platform */ +#else + RUBY_STACK_MIN_LIMIT = 512 * 1024, /* 512KB */ +#endif + RUBY_STACK_SPACE_LIMIT = 1024 * 1024, +#ifdef PTHREAD_STACK_MIN + RUBY_STACK_MIN = ((RUBY_STACK_MIN_LIMIT < PTHREAD_STACK_MIN) ? + PTHREAD_STACK_MIN * 2 : RUBY_STACK_MIN_LIMIT), +#else + RUBY_STACK_MIN = (RUBY_STACK_MIN_LIMIT), +#endif + RUBY_STACK_SPACE_RATIO = 5, + RUBY_STACK_MIN_SPACE = RUBY_STACK_MIN/RUBY_STACK_SPACE_RATIO, + RUBY_STACK_SPACE = ((RUBY_STACK_MIN_SPACE > RUBY_STACK_SPACE_LIMIT) ? + RUBY_STACK_SPACE_LIMIT : RUBY_STACK_MIN_SPACE) +}; + #ifdef STACK_END_ADDRESS extern void *STACK_END_ADDRESS; #endif @@ -806,24 +826,6 @@ use_cached_thread(rb_thread_t *th) return result; } -enum { -#ifdef __SYMBIAN32__ - RUBY_STACK_MIN_LIMIT = 64 * 1024, /* 64KB: Let's be slightly more frugal on mobile platform */ -#else - RUBY_STACK_MIN_LIMIT = 512 * 1024, /* 512KB */ -#endif - RUBY_STACK_SPACE_LIMIT = 1024 * 1024 -}; - -#ifdef PTHREAD_STACK_MIN -#define RUBY_STACK_MIN ((RUBY_STACK_MIN_LIMIT < PTHREAD_STACK_MIN) ? \ - PTHREAD_STACK_MIN * 2 : RUBY_STACK_MIN_LIMIT) -#else -#define RUBY_STACK_MIN (RUBY_STACK_MIN_LIMIT) -#endif -#define RUBY_STACK_SPACE (RUBY_STACK_MIN/5 > RUBY_STACK_SPACE_LIMIT ? \ - RUBY_STACK_SPACE_LIMIT : RUBY_STACK_MIN/5) - static int native_thread_create(rb_thread_t *th) { @@ -1425,7 +1427,7 @@ ruby_stack_overflowed_p(const rb_thread_t *th, const void *addr) else { return 0; } - size /= 5; + size /= RUBY_STACK_SPACE_RATIO; if (size > water_mark) size = water_mark; if (IS_STACK_DIR_UPPER()) { if (size > ~(size_t)base+1) size = ~(size_t)base+1;