1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2010-10-26 09:09:45 +00:00
parent 67d7448fca
commit 767d70841a
5 changed files with 60 additions and 3 deletions

View file

@ -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.

View file

@ -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@

View file

@ -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

10
missing/x86_64-chkstk.s Normal file
View file

@ -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

View file

@ -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 */