Fix c-stack.c portability bug on IRIX 5.3.
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 7 Mar 2004 23:51:09 +0000 (23:51 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 7 Mar 2004 23:51:09 +0000 (23:51 +0000)
lib/ChangeLog
lib/c-stack.c
m4/ChangeLog
m4/c-stack.m4

index 9d8a505..5da01ef 100644 (file)
@@ -1,3 +1,12 @@
+2004-03-07  Paul Eggert  <eggert@twinsun.com>
+
+       * 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
+       <http://mail.gnu.org/archive/html/bug-textutils/2003-03/msg00027.html>.
+
 2004-01-18  Simon Josefsson  <jas@extundo.com>
 
        * strdup.h: New file.
index e42d5f5..a018e51 100644 (file)
@@ -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
   }
 }
index 2013cf5..29bc12e 100644 (file)
@@ -1,3 +1,10 @@
+2004-03-07  Paul Eggert  <eggert@twinsun.com>
+
+       * 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
+       <http://mail.gnu.org/archive/html/bug-textutils/2003-03/msg00027.html>.
+
 2004-01-18  Simon Josefsson  <jas@extundo.com>
 
        * strdup.m4 (gl_PREREQ_STRDUP): Check whether strdup is declared.
index 8049d96..9511e8f 100644 (file)
@@ -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 <signal.h>])
+
    AC_CHECK_TYPES([stack_t], , , [#include <signal.h>])])
 
 AC_DEFUN([gl_C_STACK],
 [
   dnl Prerequisites of lib/c-stack.c.
-  jm_PREREQ_C_STACK
+  gl_PREREQ_C_STACK
 ])