changeset 4969:0db24850c598

Fix c-stack.c portability bug on IRIX 5.3.
author Paul Eggert <eggert@cs.ucla.edu>
date Sun, 07 Mar 2004 23:51:09 +0000
parents 6a62e3fe65c1
children 595e9138157c
files lib/ChangeLog lib/c-stack.c m4/ChangeLog m4/c-stack.m4
diffstat 4 files changed, 32 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -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.
--- a/lib/c-stack.c
+++ b/lib/c-stack.c
@@ -91,6 +91,13 @@
 #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 @@
   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 @@
   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 @@
     act.sa_sigaction = segv_handler;
 
     return sigaction (SIGSEGV, &act, 0);
+# else
+    return signal (SIGSEGV, die) == SIG_ERR ? -1 : 0;
 # endif
   }
 }
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -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.
--- 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 @@
    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_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
 ])