[前][次][番号順一覧][スレッド一覧]

ruby-changes:36745

From: nobu <ko1@a...>
Date: Sat, 13 Dec 2014 18:00:08 +0900 (JST)
Subject: [ruby-changes:36745] nobu:r48826 (trunk): configure.in: rb_cv_mcontext_t_ptr

nobu	2014-12-13 17:59:54 +0900 (Sat, 13 Dec 2014)

  New Revision: 48826

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48826

  Log:
    configure.in: rb_cv_mcontext_t_ptr
    
    * configure.in (rb_cv_mcontext_t_ptr): abstract whether mcontext_t
      is a pointer type.

  Modified files:
    trunk/configure.in
    trunk/signal.c
Index: configure.in
===================================================================
--- configure.in	(revision 48825)
+++ configure.in	(revision 48826)
@@ -2712,6 +2712,17 @@ if test x"$enable_pthread" = xyes; then https://github.com/ruby/ruby/blob/trunk/configure.in#L2712
     fi
 fi
 if test x"$ac_cv_header_ucontext_h" = xyes; then
+    AC_CACHE_CHECK([if mcontext_t is a pointer], [rb_cv_mcontext_t_ptr],
+	[AC_TRY_COMPILE([@%:@include <ucontext.h>
+	mcontext_t test(mcontext_t mc) {return mc+1;}
+	],
+	[test(0);],
+	[rb_cv_mcontext_t_ptr=yes], [rb_cv_mcontext_t_ptr=no])])
+    if test x"$rb_cv_mcontext_t_ptr" = xyes; then
+	AC_DEFINE_UNQUOTED(DEFINE_MCONTEXT_PTR(mc, uc), mcontext_t mc = (uc)->uc_mcontext)
+    else
+	AC_DEFINE_UNQUOTED(DEFINE_MCONTEXT_PTR(mc, uc), mcontext_t *mc = &(uc)->uc_mcontext)
+    fi
     if test x"$rb_with_pthread" = xyes; then
 	AC_CHECK_FUNCS(getcontext setcontext)
     fi
Index: signal.c
===================================================================
--- signal.c	(revision 48825)
+++ signal.c	(revision 48826)
@@ -742,15 +742,14 @@ NORETURN(void ruby_thread_stack_overflow https://github.com/ruby/ruby/blob/trunk/signal.c#L742
 static void
 check_stack_overflow(const uintptr_t addr, const ucontext_t *ctx)
 {
+    const DEFINE_MCONTEXT_PTR(mctx, ctx);
 # if defined __linux__
-    const mcontext_t *mctx = &ctx->uc_mcontext;
 #   if defined REG_RSP
     const greg_t sp = mctx->gregs[REG_RSP];
 #   else
     const greg_t sp = mctx->gregs[REG_ESP];
 #   endif
 # elif defined __APPLE__
-    const mcontext_t mctx = ctx->uc_mcontext;
 #   if defined(__LP64__)
     const uintptr_t sp = mctx->__ss.__rsp;
 #   else

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]