[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature Request: define sighandler_t
From: |
Bruno Haible |
Subject: |
Re: Feature Request: define sighandler_t |
Date: |
Tue, 3 May 2011 22:58:10 +0200 |
User-agent: |
KMail/1.9.9 |
Hi Markus,
> the man-page signal(2) tells me (at least on my system):
>
> typedef void (*sighandler_t)(int);
>
> The use of sighandler_t is a GNU extension. ...
>
> Could you define sighandler_t in the signal package iff _GNU_SOURCE is
> defined?
In gnulib, we tend to make GNU extensions available unconditionally but
possibly in a separate module. But I don't see the point of having an
extra module 'signal-gnu', since this GNU extension does not conflict with
POSIX. So here's a proposed patch:
2011-05-03 Bruno Haible <address@hidden>
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 <address@hidden>.
--- doc/posix-headers/signal.texi.orig Tue May 3 22:57:03 2011
+++ doc/posix-headers/signal.texi Tue May 3 22:17:21 2011
@@ -28,6 +28,11 @@
@item
The macro @code{SA_NODEFER} is not defined on some platforms:
Interix 3.5.
address@hidden
+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:
--- lib/signal.in.h.orig Tue May 3 22:57:03 2011
+++ lib/signal.in.h Tue May 3 22:18:57 2011
@@ -66,6 +66,20 @@
# endif
#endif
+/* Define sighandler_t, the type of signal handlers. A GNU extension. */
+#if address@hidden@
+# 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
--- m4/signal_h.m4.orig Tue May 3 22:57:03 2011
+++ m4/signal_h.m4 Tue May 3 22:13:56 2011
@@ -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_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_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])
])
--- modules/signal.orig Tue May 3 22:57:03 2011
+++ modules/signal Tue May 3 22:56:47 2011
@@ -10,6 +10,7 @@
c++defs
include_next
warn-on-use
+extensions
configure.ac:
gl_SIGNAL_H
@@ -35,6 +36,7 @@
-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)' \
--
In memoriam Zbigniew Iwański <http://en.wikipedia.org/wiki/Henryk_Iwański>