summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-12-01 08:03:31 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-12-01 08:03:31 +0000
commit5fbfcbac152798ce4d97486868691c17ad1c225f (patch)
tree1d386417cec5c8e31c4a2025b4ee69d4edd4e4c4 /gc.c
parent26474005b0dd56b0df7fc9c12f7ee4f2093b02b3 (diff)
* gc.c (ruby_init_stack): decrease "stack level too deep" in Windows.
merge from trunk. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11318 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index ccfa68b..e3b088e 100644
--- a/gc.c
+++ b/gc.c
@@ -424,7 +424,7 @@ static unsigned int STACK_LEVEL_MAX = 65535;
unsigned int _stacksize = 262144;
# define STACK_LEVEL_MAX (_stacksize - 4096)
# undef HAVE_GETRLIMIT
-#elif defined(HAVE_GETRLIMIT)
+#elif defined(HAVE_GETRLIMIT) || defined(_WIN32)
static unsigned int STACK_LEVEL_MAX = 655300;
#else
# define STACK_LEVEL_MAX 655300
@@ -1542,6 +1542,19 @@ void ruby_init_stack(VALUE *addr
STACK_LEVEL_MAX = (rlim.rlim_cur - space) / sizeof(VALUE);
}
}
+#elif defined _WIN32
+ {
+ MEMORY_BASIC_INFORMATION mi;
+ DWORD size;
+ DWORD space;
+
+ if (VirtualQuery(&mi, &mi, sizeof(mi))) {
+ size = (char *)mi.BaseAddress - (char *)mi.AllocationBase;
+ space = size / 5;
+ if (space > 1024*1024) space = 1024*1024;
+ STACK_LEVEL_MAX = (size - space) / sizeof(VALUE);
+ }
+ }
#endif
}