* lib/signal.in.h (GNULIB_defined_signal_blocking): New macro.
(raise): Remove older, duplicated declaration.
(_gl_raise_SIGPIPE): New declaration.
* lib/sigprocmask.c (_gl_raise_SIGPIPE): New function.
(rpl_raise): Remove function.
* lib/raise.c (rpl_raise, raise): Merge into a single function. Handle
a gnulib-defined SIGPIPE here.
* m4/raise.m4 (gl_FUNC_RAISE): Set REPLACE_RAISE also if the module
'sigprocmask' has detected missing signal-blocking and the module
'sigpipe' is enabled.
Reported by Tatsuro MATSUOKA <tmacchant5@yahoo.co.jp>.
+2011-09-26 Bruno Haible <bruno@clisp.org>
+
+ raise: Fix double declaration with modules 'sigprocmask' and 'sigpipe'.
+ * lib/signal.in.h (GNULIB_defined_signal_blocking): New macro.
+ (raise): Remove older, duplicated declaration.
+ (_gl_raise_SIGPIPE): New declaration.
+ * lib/sigprocmask.c (_gl_raise_SIGPIPE): New function.
+ (rpl_raise): Remove function.
+ * lib/raise.c (rpl_raise, raise): Merge into a single function. Handle
+ a gnulib-defined SIGPIPE here.
+ * m4/raise.m4 (gl_FUNC_RAISE): Set REPLACE_RAISE also if the module
+ 'sigprocmask' has detected missing signal-blocking and the module
+ 'sigpipe' is enabled.
+ Reported by Tatsuro MATSUOKA <tmacchant5@yahoo.co.jp>.
+
2011-09-26 Gijs van Tulder <gvtulder@gmail.com>
base64-tests: avoid memory leak
return result;
}
-# define raise raise_nothrow
+# else
+# define raise_nothrow raise
# endif
-int
-rpl_raise (int sig)
-{
- return raise_nothrow (sig);
-}
-
#else
/* An old Unix platform. */
# include <unistd.h>
+# define rpl_raise raise
+
+#endif
+
int
-raise (int sig)
+rpl_raise (int sig)
{
- return kill (getpid (), sig);
-}
+#if GNULIB_defined_signal_blocking && GNULIB_defined_SIGPIPE
+ if (sig == SIGPIPE)
+ return _gl_raise_SIGPIPE ();
+#endif
+#if HAVE_RAISE
+ return raise_nothrow (sig);
+#else
+ return kill (getpid (), sig);
#endif
+}
#if @GNULIB_SIGPROCMASK@
# if !@HAVE_POSIX_SIGNALBLOCKING@
+# ifndef GNULIB_defined_signal_blocking
+# define GNULIB_defined_signal_blocking 1
+# endif
+
/* Maximum signal number + 1. */
# ifndef NSIG
# define NSIG 32
# endif
_GL_CXXALIASWARN (signal);
-/* Raise signal SIG. */
# if !@HAVE_POSIX_SIGNALBLOCKING@ && GNULIB_defined_SIGPIPE
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef raise
-# define raise rpl_raise
-# endif
-_GL_FUNCDECL_RPL (raise, int, (int sig));
-_GL_CXXALIAS_RPL (raise, int, (int sig));
-# else
-_GL_CXXALIAS_SYS (raise, int, (int sig));
+/* Raise signal SIGPIPE. */
+_GL_EXTERN_C int _gl_raise_SIGPIPE (void);
# endif
-_GL_CXXALIASWARN (raise);
#elif defined GNULIB_POSIXCHECK
# undef sigaddset
}
#if GNULIB_defined_SIGPIPE
-/* Raise the signal SIG. */
+/* Raise the signal SIGPIPE. */
int
-rpl_raise (int sig)
-# undef raise
+_gl_raise_SIGPIPE (void)
{
- switch (sig)
+ if (blocked_set & (1U << SIGPIPE))
+ pending_array[SIGPIPE] = 1;
+ else
{
- case SIGPIPE:
- if (blocked_set & (1U << sig))
- pending_array[sig] = 1;
- else
- {
- handler_t handler = SIGPIPE_handler;
- if (handler == SIG_DFL)
- exit (128 + SIGPIPE);
- else if (handler != SIG_IGN)
- (*handler) (sig);
- }
- return 0;
- default: /* System defined signal */
- return raise (sig);
+ handler_t handler = SIGPIPE_handler;
+ if (handler == SIG_DFL)
+ exit (128 + SIGPIPE);
+ else if (handler != SIG_IGN)
+ (*handler) (SIGPIPE);
}
}
#endif
-# raise.m4 serial 1
+# raise.m4 serial 2
dnl Copyright (C) 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,
if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
REPLACE_RAISE=1
fi
+ m4_ifdef([gl_SIGNALBLOCKING], [
+ gl_SIGNALBLOCKING
+ if test $HAVE_POSIX_SIGNALBLOCKING = 0; then
+ m4_ifdef([gl_SIGNAL_SIGPIPE], [
+ gl_SIGNAL_SIGPIPE
+ if test $gl_cv_header_signal_h_SIGPIPE != yes; then
+ REPLACE_RAISE=1
+ fi
+ ], [:])
+ fi
+ ])
fi
])