summaryrefslogtreecommitdiff
path: root/lib/raise.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2011-09-24 00:50:39 +0200
committerBruno Haible <bruno@clisp.org>2011-09-24 00:50:39 +0200
commit492fd301bd2018288330c0a20a086b1a8cc611ce (patch)
tree3224054c4944f8ea1bd0358f8b2dc4f942e72ec8 /lib/raise.c
parentfd990b2577a77591d4a39cf2dea236aaf641a77d (diff)
downloadgnulib-492fd301bd2018288330c0a20a086b1a8cc611ce.tar.gz
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.
Diffstat (limited to 'lib/raise.c')
-rw-r--r--lib/raise.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/lib/raise.c b/lib/raise.c
index 88b8cb2ba2..980c9fd488 100644
--- a/lib/raise.c
+++ b/lib/raise.c
@@ -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