summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-25 03:15:32 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-25 03:15:32 (GMT)
commit55f7a4b72697497bd3c30272f3171b8944a38267 (patch)
treeb35c8062e7007ec9332e73b62be767d2636d007b /signal.c
parenta563664e064cb1c49ec1f061fba116b1516bca8e (diff)
signal.c: fix stack overflow check on Mac OS X
* signal.c (check_stack_overflow): fix condition to use ucontext register, mcontext_t dereference, and its member names, on Mac OS X. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/signal.c b/signal.c
index 2e28ed4..e24cc75 100644
--- a/signal.c
+++ b/signal.c
@@ -700,7 +700,7 @@ rb_get_next_signal(void)
#if defined(USE_SIGALTSTACK) || defined(_WIN32)
NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th));
-#if !(defined(HAVE_UCONTEXT_H) && (defined __i386__ || defined __x86_64__))
+#if (defined(HAVE_UCONTEXT_H) && (defined __i386__ || defined __x86_64__))
#elif defined __linux__
# define USE_UCONTEXT_REG 1
#elif defined __APPLE__
@@ -710,18 +710,19 @@ NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th));
static void
check_stack_overflow(const uintptr_t addr, const ucontext_t *ctx)
{
- const mcontext_t *mctx = &ctx->uc_mcontext;
# 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;
+ const uintptr_t sp = mctx->__ss.__rsp;
# else
- const uintptr_t sp = mctx->ss.esp;
+ const uintptr_t sp = mctx->__ss.__esp;
# endif
# endif
enum {pagesize = 4096};