From 3380a05bd6d5b3df1ddfba974d88b7e82a85b9ee Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 24 Nov 2008 14:25:45 +0000 Subject: [PATCH] * signal.c (register_sigaltstack): should not add external variable (with some cosmetic changes). [ruby-dev:37158] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ signal.c | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index f4360da055..c8a89b7098 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Nov 24 23:16:32 2008 Yukihiro Matsumoto + + * signal.c (register_sigaltstack): should not add external + variable (with some cosmetic changes). [ruby-dev:37158] + Mon Nov 24 22:57:25 2008 Shugo Maeda * strftime.c (rb_strftime): A width specifier for %t and %n should diff --git a/signal.c b/signal.c index 3ede0ec6db..b6bb12bec9 100644 --- a/signal.c +++ b/signal.c @@ -47,11 +47,6 @@ typedef int rb_atomic_t; # define NSIG (_SIGMAX + 1) /* For QNX */ #endif -#if defined(SIGSEGV) && defined(HAVE_SIGALTSTACK) -#define USE_SIGALTSTACK -int is_altstack_defined = 0; -#endif - static const struct signals { const char *signm; int signo; @@ -415,6 +410,10 @@ static struct { typedef RETSIGTYPE (*sighandler_t)(int); #ifdef POSIX_SIGNAL +#if defined(SIGSEGV) && defined(HAVE_SIGALTSTACK) +#define USE_SIGALTSTACK +#endif + #ifdef USE_SIGALTSTACK #ifdef SIGSTKSZ #define ALT_STACK_SIZE SIGSTKSZ @@ -422,14 +421,17 @@ typedef RETSIGTYPE (*sighandler_t)(int); #define ALT_STACK_SIZE (4*1024) #endif /* alternate stack for SIGSEGV */ -static void register_sigaltstack() { +static void +register_sigaltstack() +{ + static int is_altstack_defined = 0; stack_t newSS, oldSS; - if(is_altstack_defined) + if (is_altstack_defined) return; newSS.ss_sp = malloc(ALT_STACK_SIZE); - if(newSS.ss_sp == NULL) + if (newSS.ss_sp == NULL) /* should handle error */ rb_bug("register_sigaltstack. malloc error\n"); newSS.ss_size = ALT_STACK_SIZE;