summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--Makefile.in7
-rw-r--r--configure.in21
-rw-r--r--missing/x86_64-chkstk.s10
-rw-r--r--thread_win32.c13
5 files changed, 60 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index a9bdb28..d1dd7d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Tue Oct 26 18:09:36 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * Makefile.in (ASFLAGS): needs INCFLAGS.
+
+ * configure.in (rb_cv_dynamic_alloca): check if extra source for
+ dynamic size alloca.
+
+ * missing/x86_64-chkstk.s (___chkstk): necessary for alloca of
+ amd64-mingw32msvc-gcc on Ubutu.
+
+ * thread_win32.c (ruby_alloca_chkstk): check stack overflow
+
Tue Oct 26 18:04:53 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* template/ruby.pc.in (Libs): needs DLDFLAGS.
diff --git a/Makefile.in b/Makefile.in
index 7b81952..6cbb983 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -52,8 +52,9 @@ cflags = @cflags@
optflags = @optflags@
debugflags = @debugflags@
warnflags = @warnflags@
-XCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) @XCFLAGS@
-CPPFLAGS = @CPPFLAGS@
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir)
+XCFLAGS = @XCFLAGS@
+CPPFLAGS = @CPPFLAGS@ $(INCFLAGS)
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
EXTLDFLAGS =
XLDFLAGS = @XLDFLAGS@ $(EXTLDFLAGS)
@@ -122,7 +123,7 @@ AR = @AR@
ARFLAGS = rcu
RANLIB = @RANLIB@
AS = @AS@
-ASFLAGS = @ASFLAGS@
+ASFLAGS = @ASFLAGS@ $(INCFLAGS)
IFCHANGE = $(srcdir)/tool/ifchange
SET_LC_MESSAGES = env LC_MESSAGES=C
OBJDUMP = @OBJDUMP@
diff --git a/configure.in b/configure.in
index 5dc5939..73e7c13 100644
--- a/configure.in
+++ b/configure.in
@@ -1199,6 +1199,27 @@ AS_CASE(["${target_cpu}-${target_os}:${target_archs}"],
[
AC_FUNC_ALLOCA
])
+if test "x$ALLOCA" = "x"; then
+ AC_CACHE_CHECK([for dynamic size alloca], rb_cv_dynamic_alloca, [
+ for chk in ok __chkstk; do
+ AC_TRY_LINK([
+ @%:@ifdef HAVE_ALLOCA_H
+ @%:@include <alloca.h>
+ @%:@endif
+ void $chk() {}
+ int dynamic_alloca_test;
+ int dynamic_alloca_result;],
+ [dynamic_alloca_result = alloca(dynamic_alloca_test) != 0;],
+ [rb_cv_dynamic_alloca=$chk; break])
+ done])
+ if test "x$rb_cv_dynamic_alloca" = "x__chkstk"; then
+ AC_DEFINE_UNQUOTED(RUBY_ALLOCA_CHKSTK, _$rb_cv_dynamic_alloca)
+ AS_CASE("$target_cpu",
+ [x64|x86_64], [
+ AC_SUBST([ALLOCA], [\${LIBOBJDIR}x86_64-chkstk.${ac_objext}])
+ ],)
+ fi
+fi
AC_FUNC_MEMCMP
# http://sources.redhat.com/ml/libc-hacker/2005-08/msg00008.html
diff --git a/missing/x86_64-chkstk.s b/missing/x86_64-chkstk.s
new file mode 100644
index 0000000..6d1227b
--- /dev/null
+++ b/missing/x86_64-chkstk.s
@@ -0,0 +1,10 @@
+ .text
+.globl ___chkstk
+___chkstk:
+ pushq %rax
+ movq %rax, %rcx
+ movq %rsp, %rdx
+ call _ruby_alloca_chkstk
+ popq %rax
+ subq %rax, %rsp
+ ret
diff --git a/thread_win32.c b/thread_win32.c
index 46764f0..d9f006a 100644
--- a/thread_win32.c
+++ b/thread_win32.c
@@ -597,4 +597,17 @@ native_reset_timer_thread(void)
}
}
+#ifdef RUBY_ALLOCA_CHKSTK
+void
+ruby_alloca_chkstk(size_t len, void *sp)
+{
+ if (ruby_stack_length(NULL) * sizeof(VALUE) >= len) {
+ rb_thread_t *th = GET_THREAD();
+ if (!rb_thread_raised_p(th, RAISED_STACKOVERFLOW)) {
+ rb_thread_raised_set(th, RAISED_STACKOVERFLOW);
+ rb_exc_raise(sysstack_error);
+ }
+ }
+}
+#endif
#endif /* THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION */