From 6e7e48942d842168eb0ea00f42146c53e192082b Mon Sep 17 00:00:00 2001 From: usa Date: Fri, 1 Dec 2006 08:03:31 +0000 Subject: * gc.c (ruby_init_stack): decrease "stack level too deep" in Windows. merge from trunk. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@11318 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ gc.c | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e09949b97..47880da52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Dec 1 17:01:49 2006 NAKAMURA Usaku + + * gc.c (ruby_init_stack): decrease "stack level too deep" in Windows. + merge from trunk. + Fri Dec 1 16:31:53 2006 Hidetoshi NAGAI * ext/tk/tcltklib.c: shouldn't run the killed thread at callback. diff --git a/gc.c b/gc.c index ccfa68b23..e3b088efd 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 } -- cgit