summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-04 02:39:34 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-04 02:39:34 +0000
commitcbe3646e683e8d1112ff832cfb74ca2aec006991 (patch)
treec88688c2d64cd9b7da26073e8ca0d95358f66595 /thread_pthread.c
parent6ed36284db86cf180280ee3fe1feb2509d978c4c (diff)
* 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
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c40
1 files 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;