Skip to content

Commit 313483b

Browse files
committed
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
1 parent ed8309b commit 313483b

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

libc-test/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ fn main() {
7676
cfg.header("windows.h");
7777
cfg.header("process.h");
7878
cfg.header("ws2ipdef.h");
79+
cfg.header("signal.h");
7980

8081
if target.contains("gnu") {
8182
cfg.header("ws2tcpip.h");

src/windows/gnu.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
pub type __p_sig_fn_t = ::size_t;
2+
13
pub const L_tmpnam: ::c_uint = 14;
24
pub const TMP_MAX: ::c_uint = 0x7fff;
5+
pub const SIGINT: ::c_int = 2;
6+
pub const SIGILL: ::c_int = 4;
7+
pub const SIGFPE: ::c_int = 8;
8+
pub const SIGSEGV: ::c_int = 11;
9+
pub const SIGTERM: ::c_int = 15;
10+
pub const SIGABRT: ::c_int = 22;
11+
pub const NSIG: ::c_int = 23;
12+
pub const SIG_ERR: ::c_int = -1;
313

414
extern {
15+
pub fn signal(signum: ::c_int, handler: __p_sig_fn_t) -> __p_sig_fn_t;
16+
pub fn raise(signum: ::c_int) -> ::c_int;
517
pub fn strcasecmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int;
618
pub fn strncasecmp(s1: *const ::c_char, s2: *const ::c_char,
7-
n: ::size_t) -> ::c_int;
19+
n: ::size_t) -> ::c_int;
820
}

src/windows/msvc.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
1+
pub type _crt_signal_t = ::size_t;
2+
13
pub const L_tmpnam: ::c_uint = 260;
24
pub const TMP_MAX: ::c_uint = 0x7fff_ffff;
5+
pub const SIGINT: ::c_int = 2;
6+
pub const SIGILL: ::c_int = 4;
7+
pub const SIGABRT: ::c_int = 22;
8+
pub const SIGFPE: ::c_int = 8;
9+
pub const SIGSEGV: ::c_int = 11;
10+
pub const SIGTERM: ::c_int = 15;
11+
pub const SIG_ERR: ::c_int = -1;
312

413
extern {
14+
pub fn signal(signum: ::c_int, handler: _crt_signal_t) -> _crt_signal_t;
15+
pub fn raise(signum: ::c_int) -> ::c_int;
516
#[link_name = "_stricmp"]
617
pub fn stricmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int;
718
#[link_name = "_strnicmp"]
819
pub fn strnicmp(s1: *const ::c_char, s2: *const ::c_char,
920
n: ::size_t) -> ::c_int;
10-
}
21+
}

0 commit comments

Comments
 (0)