Skip to content

Commit 80e4a26

Browse files
committed
Auto merge of #2304 - mkroening:sigrt, r=JohnTitor
Add SIGRTMAX and SIGRTMIN on linux-like systems Fixes #1883. This is based on #2195, which has not seen activity in a while. The original issue was resolved by making `__libc_current_sigrtmax` and `__libc_current_sigrtmax` `pub`. I also added a test similar to `errqueue`'s, where the actual value of the macro is compared to `libc`'s implementation. Closes #2195
2 parents b657542 + 8af1a48 commit 80e4a26

File tree

6 files changed

+68
-0
lines changed

6 files changed

+68
-0
lines changed

libc-test/Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ name = "errqueue"
7171
path = "test/errqueue.rs"
7272
harness = true
7373

74+
[[test]]
75+
name = "sigrt"
76+
path = "test/sigrt.rs"
77+
harness = true
78+
7479
[[test]]
7580
name = "semver"
7681
path = "test/semver.rs"

libc-test/build.rs

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ fn do_cc() {
2626
if target.contains("android") || target.contains("linux") {
2727
cc::Build::new().file("src/errqueue.c").compile("errqueue");
2828
}
29+
if target.contains("linux")
30+
|| target.contains("l4re")
31+
|| target.contains("android")
32+
|| target.contains("emscripten")
33+
{
34+
cc::Build::new().file("src/sigrt.c").compile("sigrt");
35+
}
2936
}
3037

3138
fn do_ctest() {

libc-test/semver/linux.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1972,6 +1972,8 @@ SIGEV_SIGNAL
19721972
SIGEV_THREAD
19731973
SIGPOLL
19741974
SIGPWR
1975+
SIGRTMAX
1976+
SIGRTMIN
19751977
SIGSTKSZ
19761978
SIOCADDMULTI
19771979
SIOCADDRT

libc-test/src/sigrt.c

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <signal.h>
2+
3+
int sigrtmax() {
4+
return SIGRTMAX;
5+
}
6+
7+
int sigrtmin() {
8+
return SIGRTMIN;
9+
}

libc-test/test/sigrt.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//! Compare libc's SIGRTMAX and SIGRTMIN functions against the actual C macros
2+
3+
extern crate libc;
4+
5+
#[cfg(any(
6+
target_os = "linux",
7+
target_os = "l4re",
8+
target_os = "android",
9+
target_os = "emscripten"
10+
))]
11+
mod t {
12+
use libc;
13+
14+
extern "C" {
15+
pub fn sigrtmax() -> libc::c_int;
16+
pub fn sigrtmin() -> libc::c_int;
17+
}
18+
19+
#[test]
20+
fn test_sigrtmax() {
21+
unsafe {
22+
assert_eq!(libc::SIGRTMAX(), sigrtmax());
23+
}
24+
}
25+
26+
#[test]
27+
fn test_sigrtmin() {
28+
unsafe {
29+
assert_eq!(libc::SIGRTMIN(), sigrtmin());
30+
}
31+
}
32+
}

src/unix/linux_like/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,14 @@ f! {
14181418
}
14191419

14201420
safe_f! {
1421+
pub fn SIGRTMAX() -> ::c_int {
1422+
unsafe { __libc_current_sigrtmax() }
1423+
}
1424+
1425+
pub fn SIGRTMIN() -> ::c_int {
1426+
unsafe { __libc_current_sigrtmin() }
1427+
}
1428+
14211429
pub {const} fn WIFSTOPPED(status: ::c_int) -> bool {
14221430
(status & 0xff) == 0x7f
14231431
}
@@ -1480,6 +1488,11 @@ safe_f! {
14801488
}
14811489

14821490
extern "C" {
1491+
#[doc(hidden)]
1492+
pub fn __libc_current_sigrtmax() -> ::c_int;
1493+
#[doc(hidden)]
1494+
pub fn __libc_current_sigrtmin() -> ::c_int;
1495+
14831496
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
14841497
pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::c_int;
14851498
pub fn fdatasync(fd: ::c_int) -> ::c_int;

0 commit comments

Comments
 (0)