ruby-changes:27304
From: nobu <ko1@a...>
Date: Thu, 21 Feb 2013 16:35:17 +0900 (JST)
Subject: [ruby-changes:27304] nobu:r39356 (trunk): signal.c: extract check_stack_overflow
nobu 2013-02-21 16:34:53 +0900 (Thu, 21 Feb 2013) New Revision: 39356 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39356 Log: signal.c: extract check_stack_overflow * signal.c (check_stack_overflow): extract duplicated code and get rid of declaration-after-statement. [Bug #5014] Modified files: trunk/ChangeLog trunk/signal.c Index: ChangeLog =================================================================== --- ChangeLog (revision 39355) +++ ChangeLog (revision 39356) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Feb 21 16:34:46 2013 Nobuyoshi Nakada <nobu@r...> + + * signal.c (check_stack_overflow): extract duplicated code and get rid + of declaration-after-statement. [Bug #5014] + Thu Feb 21 14:14:13 2013 KOSAKI Motohiro <kosaki.motohiro@g...> * signal.c (sigsegv): avoid to use async signal unsafe functions Index: signal.c =================================================================== --- signal.c (revision 39355) +++ signal.c (revision 39356) @@ -604,6 +604,23 @@ rb_get_next_signal(void) https://github.com/ruby/ruby/blob/trunk/signal.c#L604 return sig; } + +#ifdef USE_SIGALTSTACK +static void +check_stack_overflow(const void *addr) +{ + int ruby_stack_overflowed_p(const rb_thread_t *, const void *); + NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th)); + rb_thread_t *th = GET_THREAD(); + if (ruby_stack_overflowed_p(th, addr)) { + ruby_thread_stack_overflow(th); + } +} +#define CHECK_STACK_OVERFLOW() check_stack_overflow(info->si_addr) +#else +#define CHECK_STACK_OVERFLOW() (void)0 +#endif + #ifdef SIGBUS static RETSIGTYPE sigbus(int sig SIGINFO_ARG) @@ -613,13 +630,8 @@ sigbus(int sig SIGINFO_ARG) https://github.com/ruby/ruby/blob/trunk/signal.c#L630 * and it's delivered as SIGBUS instaed of SIGSEGV to userland. It's crazy * wrong IMHO. but anyway we have to care it. Sigh. */ -#if defined __APPLE__ && defined USE_SIGALTSTACK - int ruby_stack_overflowed_p(const rb_thread_t *, const void *); - NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th)); - rb_thread_t *th = GET_THREAD(); - if (ruby_stack_overflowed_p(th, info->si_addr)) { - ruby_thread_stack_overflow(th); - } +#if defined __APPLE__ + CHECK_STACK_OVERFLOW(); #endif rb_bug("Bus Error"); } @@ -651,14 +663,7 @@ sigsegv(int sig SIGINFO_ARG) https://github.com/ruby/ruby/blob/trunk/signal.c#L663 ruby_abort(); } -#ifdef USE_SIGALTSTACK - int ruby_stack_overflowed_p(const rb_thread_t *, const void *); - NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th)); - rb_thread_t *th = GET_THREAD(); - if (ruby_stack_overflowed_p(th, info->si_addr)) { - ruby_thread_stack_overflow(th); - } -#endif + CHECK_STACK_OVERFLOW(); segv_received = 1; ruby_disable_gc_stress = 1; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/