Commit 492fd301 authored by Bruno Haible's avatar Bruno Haible

raise: Support for MSVC.

* lib/signal.in.h (raise): New declaration.
* lib/raise.c (raise_nothrow, rpl_raise): New alternate implementation
for native Windows platforms.
* m4/raise.m4: New file.
* m4/signal_h.m4 (gl_SIGNAL_H_DEFAULTS): Initialize GNULIB_RAISE,
HAVE_RAISE, REPLACE_RAISE.
* modules/signal (Makefile.am): Substitute GNULIB_RAISE, HAVE_RAISE,
REPLACE_RAISE.
* modules/raise (Status, Notice): Remove fields.
(Files): Add m4/raise.m4.
(Depends-on): Add signal, msvc-inval.
(configure.ac): Use the common idioms.
(Maintainer): Add me.
* tests/test-signal-c++.cc: Check the signature of raise.
* doc/posix-functions/raise.texi: Mention the problem on MSVC.
parent fd990b25
2011-09-23 Bruno Haible <bruno@clisp.org>
raise: Support for MSVC.
* lib/signal.in.h (raise): New declaration.
* lib/raise.c (raise_nothrow, rpl_raise): New alternate implementation
for native Windows platforms.
* m4/raise.m4: New file.
* m4/signal_h.m4 (gl_SIGNAL_H_DEFAULTS): Initialize GNULIB_RAISE,
HAVE_RAISE, REPLACE_RAISE.
* modules/signal (Makefile.am): Substitute GNULIB_RAISE, HAVE_RAISE,
REPLACE_RAISE.
* modules/raise (Status, Notice): Remove fields.
(Files): Add m4/raise.m4.
(Depends-on): Add signal, msvc-inval.
(configure.ac): Use the common idioms.
(Maintainer): Add me.
* tests/test-signal-c++.cc: Check the signature of raise.
* doc/posix-functions/raise.texi: Mention the problem on MSVC.
2011-09-23 Bruno Haible <bruno@clisp.org>
pipe2: Fix compilation on pre-C99 compilers.
......@@ -10,6 +10,9 @@ Portability problems fixed by Gnulib:
@itemize
@item
This function is missing on some old platforms.
@item
This function crashes when invoked with invalid arguments on some platforms:
MSVC 9.
@end itemize
Portability problems not fixed by Gnulib:
......
......@@ -15,16 +15,59 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* written by Jim Meyering */
/* written by Jim Meyering and Bruno Haible */
#include <config.h>
#include <sys/types.h>
/* Specification. */
#include <signal.h>
#include <unistd.h>
#if HAVE_RAISE
/* Native Windows platform. */
# include <errno.h>
# include "msvc-inval.h"
# undef raise
# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
static inline int
raise_nothrow (int sig)
{
int result;
TRY_MSVC_INVAL
{
result = raise (sig);
}
CATCH_MSVC_INVAL
{
result = -1;
errno = EINVAL;
}
DONE_MSVC_INVAL;
return result;
}
# define raise raise_nothrow
# endif
int
rpl_raise (int sig)
{
return raise_nothrow (sig);
}
#else
/* An old Unix platform. */
# include <unistd.h>
int
raise (int sig)
{
return kill (getpid (), sig);
}
#endif
......@@ -152,6 +152,29 @@ _GL_WARN_ON_USE (pthread_sigmask, "pthread_sigmask is not portable - "
#endif
#if @GNULIB_RAISE@
# if @REPLACE_RAISE@
# 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
# if !@HAVE_RAISE@
_GL_FUNCDECL_SYS (raise, int, (int sig));
# endif
_GL_CXXALIAS_SYS (raise, int, (int sig));
# endif
_GL_CXXALIASWARN (raise);
#elif defined GNULIB_POSIXCHECK
# undef raise
/* Assume raise is always declared. */
_GL_WARN_ON_USE (raise, "raise can crash on native Windows - "
"use gnulib module raise for portability");
#endif
#if @GNULIB_SIGPROCMASK@
# if !@HAVE_POSIX_SIGNALBLOCKING@
......
# raise.m4 serial 1
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,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_RAISE],
[
AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([gl_MSVC_INVAL])
AC_CHECK_FUNCS([raise])
if test $ac_cv_func_raise = no; then
HAVE_RAISE=0
else
if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
REPLACE_RAISE=1
fi
fi
])
# Prerequisites of lib/raise.c.
AC_DEFUN([gl_PREREQ_RAISE], [
AC_REQUIRE([AC_C_INLINE])
])
# signal_h.m4 serial 17
# signal_h.m4 serial 18
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,
......@@ -62,12 +62,14 @@ AC_DEFUN([gl_SIGNAL_MODULE_INDICATOR],
AC_DEFUN([gl_SIGNAL_H_DEFAULTS],
[
GNULIB_PTHREAD_SIGMASK=0; AC_SUBST([GNULIB_PTHREAD_SIGMASK])
GNULIB_RAISE=0; AC_SUBST([GNULIB_RAISE])
GNULIB_SIGNAL_H_SIGPIPE=0; AC_SUBST([GNULIB_SIGNAL_H_SIGPIPE])
GNULIB_SIGPROCMASK=0; AC_SUBST([GNULIB_SIGPROCMASK])
GNULIB_SIGACTION=0; AC_SUBST([GNULIB_SIGACTION])
dnl Assume proper GNU behavior unless another module says otherwise.
HAVE_POSIX_SIGNALBLOCKING=1; AC_SUBST([HAVE_POSIX_SIGNALBLOCKING])
HAVE_PTHREAD_SIGMASK=1; AC_SUBST([HAVE_PTHREAD_SIGMASK])
HAVE_RAISE=1; AC_SUBST([HAVE_RAISE])
HAVE_SIGSET_T=1; AC_SUBST([HAVE_SIGSET_T])
HAVE_SIGINFO_T=1; AC_SUBST([HAVE_SIGINFO_T])
HAVE_SIGACTION=1; AC_SUBST([HAVE_SIGACTION])
......@@ -77,4 +79,5 @@ AC_DEFUN([gl_SIGNAL_H_DEFAULTS],
AC_SUBST([HAVE_TYPE_VOLATILE_SIG_ATOMIC_T])
HAVE_SIGHANDLER_T=1; AC_SUBST([HAVE_SIGHANDLER_T])
REPLACE_PTHREAD_SIGMASK=0; AC_SUBST([REPLACE_PTHREAD_SIGMASK])
REPLACE_RAISE=0; AC_SUBST([REPLACE_RAISE])
])
Description:
Send a signal to the executing process.
Status:
obsolete
Notice:
This module is obsolete.
Files:
lib/raise.c
m4/raise.m4
Depends-on:
signal
msvc-inval [test $HAVE_RAISE = 0 || test $REPLACE_RAISE = 1]
configure.ac:
AC_REPLACE_FUNCS(raise)
gl_FUNC_RAISE
if test $HAVE_RAISE = 0 || test $REPLACE_RAISE = 1; then
AC_LIBOBJ([raise])
gl_PREREQ_RAISE
fi
gl_SIGNAL_MODULE_INDICATOR([raise])
Makefile.am:
......@@ -24,5 +26,5 @@ License:
LGPLv2+
Maintainer:
Jim Meyering
Jim Meyering, Bruno Haible
......@@ -29,11 +29,13 @@ signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SIGNAL_H''@|$(NEXT_SIGNAL_H)|g' \
-e 's|@''GNULIB_PTHREAD_SIGMASK''@|$(GNULIB_PTHREAD_SIGMASK)|g' \
-e 's|@''GNULIB_RAISE''@|$(GNULIB_RAISE)|g' \
-e 's/@''GNULIB_SIGNAL_H_SIGPIPE''@/$(GNULIB_SIGNAL_H_SIGPIPE)/g' \
-e 's/@''GNULIB_SIGPROCMASK''@/$(GNULIB_SIGPROCMASK)/g' \
-e 's/@''GNULIB_SIGACTION''@/$(GNULIB_SIGACTION)/g' \
-e 's|@''HAVE_POSIX_SIGNALBLOCKING''@|$(HAVE_POSIX_SIGNALBLOCKING)|g' \
-e 's|@''HAVE_PTHREAD_SIGMASK''@|$(HAVE_PTHREAD_SIGMASK)|g' \
-e 's|@''HAVE_RAISE''@|$(HAVE_RAISE)|g' \
-e 's|@''HAVE_SIGSET_T''@|$(HAVE_SIGSET_T)|g' \
-e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \
-e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \
......@@ -41,6 +43,7 @@ signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-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 's|@''REPLACE_PTHREAD_SIGMASK''@|$(REPLACE_PTHREAD_SIGMASK)|g' \
-e 's|@''REPLACE_RAISE''@|$(REPLACE_RAISE)|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)' \
......
......@@ -29,6 +29,10 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::pthread_sigmask, int,
(int, const sigset_t *, sigset_t *));
#endif
#if GNULIB_TEST_RAISE
SIGNATURE_CHECK (GNULIB_NAMESPACE::raise, int, (int));
#endif
#if GNULIB_TEST_SIGPROCMASK
SIGNATURE_CHECK (GNULIB_NAMESPACE::sigismember, int, (const sigset_t *, int));
SIGNATURE_CHECK (GNULIB_NAMESPACE::sigemptyset, int, (sigset_t *));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment