From f49d92a13f08f505fe855afce40f173a6e7c922c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 7 Mar 2004 23:51:09 +0000 Subject: [PATCH] Fix c-stack.c portability bug on IRIX 5.3. --- lib/ChangeLog | 9 +++++++++ lib/c-stack.c | 15 +++++++++++---- m4/ChangeLog | 7 +++++++ m4/c-stack.m4 | 8 +++++--- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index 9d8a505b9f..5da01ef920 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,12 @@ +2004-03-07 Paul Eggert + + * c-stack.c (SIGACTION_WORKS): New macro. Use it instead of long + '#if' expressions. Unlike the code it replaces, it it does not + depend on (defined _SC_PAGESIZE). However, it does depend on + HAVE_STRUCT_SIGACTION_SA_SIGACTION; this last change fixes a bug + first reported by Jason Andrade in + . + 2004-01-18 Simon Josefsson * strdup.h: New file. diff --git a/lib/c-stack.c b/lib/c-stack.c index e42d5f5276..a018e5158e 100644 --- a/lib/c-stack.c +++ b/lib/c-stack.c @@ -91,6 +91,13 @@ typedef struct sigaltstack stack_t; #include "c-stack.h" #include "exitfail.h" +#if (HAVE_STRUCT_SIGACTION_SA_SIGACTION && defined SA_NODEFER \ + && defined SA_ONSTACK && defined SA_RESETHAND && defined SA_SIGINFO) +# define SIGACTION_WORKS 1 +#else +# define SIGACTION_WORKS 0 +#endif + extern char *program_name; /* The user-specified action to take when a SEGV-related program error @@ -153,7 +160,7 @@ static union void *p; } alternate_signal_stack; -# if defined SA_ONSTACK && defined SA_SIGINFO && defined _SC_PAGESIZE +# if SIGACTION_WORKS /* Handle a segmentation violation and exit. This function is async-signal-safe. */ @@ -238,9 +245,7 @@ c_stack_action (void (*action) (int)) stack_overflow_message = _("stack overflow"); { -# if ! (defined SA_ONSTACK && defined SA_SIGINFO && defined _SC_PAGESIZE) - return signal (SIGSEGV, die) == SIG_ERR ? -1 : 0; -# else +# if SIGACTION_WORKS struct sigaction act; sigemptyset (&act.sa_mask); @@ -252,6 +257,8 @@ c_stack_action (void (*action) (int)) act.sa_sigaction = segv_handler; return sigaction (SIGSEGV, &act, 0); +# else + return signal (SIGSEGV, die) == SIG_ERR ? -1 : 0; # endif } } diff --git a/m4/ChangeLog b/m4/ChangeLog index 2013cf5498..29bc12e5cc 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,10 @@ +2004-03-07 Paul Eggert + + * c-stack.m4 (gl_PREREQ_C_STACK): Renamed from jm_PREREQ_C_STACK. + All uses changed. Check for sa_sigaction member; this fixes + a bug first reported by Jason Andrade in + . + 2004-01-18 Simon Josefsson * strdup.m4 (gl_PREREQ_STRDUP): Check whether strdup is declared. diff --git a/m4/c-stack.m4 b/m4/c-stack.m4 index 8049d96bdf..9511e8f965 100644 --- a/m4/c-stack.m4 +++ b/m4/c-stack.m4 @@ -1,6 +1,6 @@ # Check prerequisites for compiling lib/c-stack.c. -# Copyright (C) 2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -138,7 +138,7 @@ AC_DEFUN([AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC], fi]) -AC_DEFUN([jm_PREREQ_C_STACK], +AC_DEFUN([gl_PREREQ_C_STACK], [AC_REQUIRE([AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC]) # for STACK_DIRECTION @@ -151,10 +151,12 @@ AC_DEFUN([jm_PREREQ_C_STACK], AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h) AC_CHECK_HEADERS(sys/resource.h ucontext.h) + AC_CHECK_MEMBERS([struct sigaction.sa_sigaction], , , [#include ]) + AC_CHECK_TYPES([stack_t], , , [#include ])]) AC_DEFUN([gl_C_STACK], [ dnl Prerequisites of lib/c-stack.c. - jm_PREREQ_C_STACK + gl_PREREQ_C_STACK ]) -- 2.30.2