summaryrefslogtreecommitdiff
path: root/signal.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-13 09:01:59 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-13 09:01:59 (GMT)
commit02e8b4d9a89e9af8ddbf1507261fec67fbfcabac (patch)
tree90a524b14b66304ef47eeaf709f7026c68b59714 /signal.c
parent7dc4bbc1406202a48ef31e9fb97d542ece4d5519 (diff)
signal.c: stack overflow on FreeBSD
* signal.c (check_stack_overflow): check sp also on i386/x86_64 FreeBSD. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/signal.c b/signal.c
index fd356e2..a0f9bff 100644
--- a/signal.c
+++ b/signal.c
@@ -732,11 +732,13 @@ 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__ || defined __amd64__))
# elif defined __linux__
# define USE_UCONTEXT_REG 1
# elif defined __APPLE__
# define USE_UCONTEXT_REG 1
+# elif defined __FreeBSD__
+# define USE_UCONTEXT_REG 1
# endif
# ifdef USE_UCONTEXT_REG
static void
@@ -755,6 +757,12 @@ check_stack_overflow(const uintptr_t addr, const ucontext_t *ctx)
# else
const uintptr_t sp = mctx->__ss.__esp;
# endif
+# elif defined __FreeBSD__
+# if defined(__amd64__)
+ const __register_t sp = mctx->mc_rsp;
+# else
+ const __register_t sp = mctx->mc_esp;
+# endif
# endif
enum {pagesize = 4096};
const uintptr_t sp_page = (uintptr_t)sp / pagesize;