signal.h: always support 'volatile sig_atomic_t'
authorEric Blake <ebb9@byu.net>
Sat, 21 Mar 2009 23:57:40 +0000 (17:57 -0600)
committerEric Blake <ebb9@byu.net>
Mon, 23 Mar 2009 10:55:12 +0000 (04:55 -0600)
* m4/signal_h.m4 (gl_SIGNAL_H): Check for AIX limitation.
(gl_SIGNAL_H_DEFAULTS): Add a default.
* modules/signal (Makefile.am): Substitute if needed.
* lib/signal.in.h (sig_atomic_t): Redefine if needed, so that
users can blindly add volatile.
* doc/posix-headers/signal.texi (signal.h): Document it.
Reported by Matthew Woehlke.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
doc/posix-headers/signal.texi
lib/signal.in.h
m4/signal_h.m4
modules/signal

index 567c948..653517c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-03-23  Eric Blake  <ebb9@byu.net>
+
+       signal.h: always support 'volatile sig_atomic_t'
+       * m4/signal_h.m4 (gl_SIGNAL_H): Check for AIX limitation.
+       (gl_SIGNAL_H_DEFAULTS): Add a default.
+       * modules/signal (Makefile.am): Substitute if needed.
+       * lib/signal.in.h (sig_atomic_t): Redefine if needed, so that
+       users can blindly add volatile.
+       * doc/posix-headers/signal.texi (signal.h): Document it.
+       Reported by Matthew Woehlke.
+
 2009-03-23  Jim Meyering  <meyering@redhat.com>
 
        pathmax: PATH_MAX: use pathconf only when available
index 860a79d..05be64b 100644 (file)
@@ -8,6 +8,10 @@ Gnulib module: signal
 Portability problems fixed by Gnulib:
 @itemize
 @item
+@code{volatile sig_atomic_t} is rejected by older compilers on some
+platforms:
+AIX.
+@item
 @code{sigset_t} is only declared in <sys/types.h> on some platforms:
 mingw.
 @item
index 3c74fd8..5c42fe9 100644 (file)
@@ -1,6 +1,6 @@
 /* A GNU-like <signal.h>.
 
-   Copyright (C) 2006-2008 Free Software Foundation, Inc.
+   Copyright (C) 2006-2009 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
    Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.  */
 #include <sys/types.h>
 
+/* On AIX, sig_atomic_t already includes volatile.  C99 requires that
+   'volatile sig_atomic_t' ignore the extra modifier, but C89 did not.
+   Hence, redefine this to a non-volatile type as needed.  */
+#if ! @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@
+typedef int rpl_sig_atomic_t;
+# undef sig_atomic_t
+# define sig_atomic_t rpl_sig_atomic_t
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
index 4ac2e04..e69befd 100644 (file)
@@ -1,5 +1,5 @@
-# signal_h.m4 serial 6
-dnl Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+# signal_h.m4 serial 7
+dnl Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -8,6 +8,12 @@ AC_DEFUN([gl_SIGNAL_H],
 [
   AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
   gl_CHECK_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_DEFUN([gl_SIGNAL_MODULE_INDICATOR],
@@ -29,4 +35,6 @@ AC_DEFUN([gl_SIGNAL_H_DEFAULTS],
   HAVE_SIGACTION=1;            AC_SUBST([HAVE_SIGACTION])
   HAVE_STRUCT_SIGACTION_SA_SIGACTION=1;
                                AC_SUBST([HAVE_STRUCT_SIGACTION_SA_SIGACTION])
+  HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=1;
+                               AC_SUBST([HAVE_TYPE_VOLATILE_SIG_ATOMIC_T])
 ])
index 5afb24f..bfef96f 100644 (file)
@@ -31,6 +31,7 @@ signal.h: signal.in.h
              -e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \
              -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 '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
              < $(srcdir)/signal.in.h; \
        } > $@-t