From: Bruno Haible <bruno@clisp.org>
Date: Thu, 5 May 2011 17:03:57 +0000 (+0200)
Subject: signal: Define sighandler_t.
X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa6f00004c5ea9f4b341a7c60db177a7419f06aa;p=pspp

signal: Define sighandler_t.

* lib/signal.in.h (sighandler_t): New type.
* m4/signal_h.m4 (gl_SIGNAL_H): Require AC_USE_SYSTEM_EXTENSIONS. Test
whether sighandler_t is defined.
(gl_SIGNAL_H_DEFAULTS): Initialize HAVE_SIGHANDLER_T.
* modules/signal (Depends-on): Add extensions.
(Makefile.am): Substitute HAVE_SIGHANDLER_T.
* doc/posix-headers/signal.texi: Mention the problem with sighandler_t.
Suggested by Markus Steinborn <gnugv_maintainer@yahoo.de>.
---

diff --git a/ChangeLog b/ChangeLog
index 55c709fc25..75a0b571d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2011-05-05  Bruno Haible  <bruno@clisp.org>
+
+	signal: Define sighandler_t.
+	* lib/signal.in.h (sighandler_t): New type.
+	* m4/signal_h.m4 (gl_SIGNAL_H): Require AC_USE_SYSTEM_EXTENSIONS. Test
+	whether sighandler_t is defined.
+	(gl_SIGNAL_H_DEFAULTS): Initialize HAVE_SIGHANDLER_T.
+	* modules/signal (Depends-on): Add extensions.
+	(Makefile.am): Substitute HAVE_SIGHANDLER_T.
+	* doc/posix-headers/signal.texi: Mention the problem with sighandler_t.
+	Suggested by Markus Steinborn <gnugv_maintainer@yahoo.de>.
+
 2011-05-05  Eric Blake  <eblake@redhat.com>
 
 	maint: remove useless REPLACE_*_H macros
diff --git a/doc/posix-headers/signal.texi b/doc/posix-headers/signal.texi
index 77a54323c3..7e953ce1ff 100644
--- a/doc/posix-headers/signal.texi
+++ b/doc/posix-headers/signal.texi
@@ -28,6 +28,11 @@ mingw.
 @item
 The macro @code{SA_NODEFER} is not defined on some platforms:
 Interix 3.5.
+@item
+The type @code{sighandler_t} (a GNU extension) is not defined on most non-glibc
+platforms:
+MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, AIX 5.1, HP-UX 11,
+IRIX 6.5, OSF/1 5.1, Solaris 11 2010-11, Cygwin, mingw, Interix 3.5, BeOS.
 @end itemize
 
 Portability problems not fixed by Gnulib:
diff --git a/lib/signal.in.h b/lib/signal.in.h
index 7a6d6ee856..036e4f2deb 100644
--- a/lib/signal.in.h
+++ b/lib/signal.in.h
@@ -66,6 +66,20 @@ typedef unsigned int sigset_t;
 # endif
 #endif
 
+/* Define sighandler_t, the type of signal handlers.  A GNU extension.  */
+#if !@HAVE_SIGHANDLER_T@
+# ifdef __cplusplus
+extern "C" {
+# endif
+# if !GNULIB_defined_sighandler_t
+typedef void (*sighandler_t) (int);
+#  define GNULIB_defined_sighandler_t 1
+# endif
+# ifdef __cplusplus
+}
+# endif
+#endif
+
 
 #if @GNULIB_SIGNAL_H_SIGPIPE@
 # ifndef SIGPIPE
diff --git a/m4/signal_h.m4 b/m4/signal_h.m4
index 77eb125710..459ec007f3 100644
--- a/m4/signal_h.m4
+++ b/m4/signal_h.m4
@@ -1,4 +1,4 @@
-# signal_h.m4 serial 11
+# signal_h.m4 serial 12
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,14 +8,22 @@ AC_DEFUN([gl_SIGNAL_H],
 [
   AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
   gl_NEXT_HEADERS([signal.h])
+
 # AIX declares sig_atomic_t to already include volatile, and C89 compilers
 # then choke on 'volatile sig_atomic_t'.  C99 requires that it compile.
   AC_CHECK_TYPE([volatile sig_atomic_t], [],
     [HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=0], [[
 #include <signal.h>
     ]])
+
   AC_REQUIRE([AC_TYPE_UID_T])
 
+  dnl Persuade glibc <signal.h> to define sighandler_t.
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+  AC_CHECK_TYPE([sighandler_t], [], [HAVE_SIGHANDLER_T=0], [[
+#include <signal.h>
+    ]])
+
   dnl Check for declarations of anything we want to poison if the
   dnl corresponding gnulib module is not in use.
   gl_WARN_ON_USE_PREPARE([[#include <signal.h>
@@ -46,4 +54,5 @@ AC_DEFUN([gl_SIGNAL_H_DEFAULTS],
                                AC_SUBST([HAVE_STRUCT_SIGACTION_SA_SIGACTION])
   HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=1;
                                AC_SUBST([HAVE_TYPE_VOLATILE_SIG_ATOMIC_T])
+  HAVE_SIGHANDLER_T=1;         AC_SUBST([HAVE_SIGHANDLER_T])
 ])
diff --git a/modules/signal b/modules/signal
index 29b7af3cf1..c8d93a1dc0 100644
--- a/modules/signal
+++ b/modules/signal
@@ -10,6 +10,7 @@ arg-nonnull
 c++defs
 include_next
 warn-on-use
+extensions
 
 configure.ac:
 gl_SIGNAL_H
@@ -35,6 +36,7 @@ signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
 	      -e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \
 	      -e 's|@''HAVE_STRUCT_SIGACTION_SA_SIGACTION''@|$(HAVE_STRUCT_SIGACTION_SA_SIGACTION)|g' \
 	      -e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \
+	      -e 's|@''HAVE_SIGHANDLER_T''@|$(HAVE_SIGHANDLER_T)|g' \
 	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
 	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \