From 313483ba2ef5aa1f70a137952c696cf499e3f0e3 Mon Sep 17 00:00:00 2001
From: Mackenzie Clark <mackenzie.a.z.c@gmail.com>
Date: Sun, 16 Dec 2018 16:23:53 -0800
Subject: [PATCH] add signal and raise bindings

separate for gnu and msvc


scope resolve c_int

these types are not allowed, and more scope resolution


use size_t
---
 libc-test/build.rs  |  1 +
 src/windows/gnu.rs  | 14 +++++++++++++-
 src/windows/msvc.rs | 13 ++++++++++++-
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/libc-test/build.rs b/libc-test/build.rs
index e6c9c790..d41d561f 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -76,6 +76,7 @@ fn main() {
         cfg.header("windows.h");
         cfg.header("process.h");
         cfg.header("ws2ipdef.h");
+        cfg.header("signal.h");
 
         if target.contains("gnu") {
             cfg.header("ws2tcpip.h");
diff --git a/src/windows/gnu.rs b/src/windows/gnu.rs
index a67af15a..cb38f543 100644
--- a/src/windows/gnu.rs
+++ b/src/windows/gnu.rs
@@ -1,8 +1,20 @@
+pub type __p_sig_fn_t = ::size_t;
+
 pub const L_tmpnam: ::c_uint = 14;
 pub const TMP_MAX: ::c_uint = 0x7fff;
+pub const SIGINT: ::c_int = 2;
+pub const SIGILL: ::c_int = 4;
+pub const SIGFPE: ::c_int = 8;
+pub const SIGSEGV: ::c_int = 11;
+pub const SIGTERM: ::c_int = 15;
+pub const SIGABRT: ::c_int = 22;
+pub const NSIG: ::c_int = 23;
+pub const SIG_ERR: ::c_int = -1;
 
 extern {
+    pub fn signal(signum: ::c_int, handler: __p_sig_fn_t) -> __p_sig_fn_t;
+    pub fn raise(signum: ::c_int) -> ::c_int;
     pub fn strcasecmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int;
     pub fn strncasecmp(s1: *const ::c_char, s2: *const ::c_char,
-                    n: ::size_t) -> ::c_int;
+                       n: ::size_t) -> ::c_int;
 }
diff --git a/src/windows/msvc.rs b/src/windows/msvc.rs
index 9e2a9b9e..47ceafea 100644
--- a/src/windows/msvc.rs
+++ b/src/windows/msvc.rs
@@ -1,10 +1,21 @@
+pub type _crt_signal_t = ::size_t;
+
 pub const L_tmpnam: ::c_uint = 260;
 pub const TMP_MAX: ::c_uint = 0x7fff_ffff;
+pub const SIGINT: ::c_int = 2;
+pub const SIGILL: ::c_int = 4;
+pub const SIGABRT: ::c_int = 22;
+pub const SIGFPE: ::c_int = 8;
+pub const SIGSEGV: ::c_int = 11;
+pub const SIGTERM: ::c_int = 15;
+pub const SIG_ERR: ::c_int = -1;
 
 extern {
+    pub fn signal(signum: ::c_int, handler: _crt_signal_t) -> _crt_signal_t;
+    pub fn raise(signum: ::c_int) -> ::c_int;
     #[link_name = "_stricmp"]
     pub fn stricmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int;
     #[link_name = "_strnicmp"]
     pub fn strnicmp(s1: *const ::c_char, s2: *const ::c_char,
                     n: ::size_t) -> ::c_int;
-}
\ No newline at end of file
+}
-- 
GitLab