Skip to content

Commit 28475a6

Browse files
committed
Add shim for SIGRTMIN
Fixes #2832.
1 parent 3a9920b commit 28475a6

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

src/machine.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ use crate::{
3232
*,
3333
};
3434

35-
/// The number of the available real-time signal with the lowest priority.
36-
/// Dummy constant related to epoll, must be between 32 and 64.
35+
/// First real-time signal.
36+
/// `signal(7)` says this must be between 32 and 64 and specifies 34 or 35
37+
/// as typical values.
38+
pub const SIGRTMIN: i32 = 34;
39+
40+
/// Last real-time signal.
41+
/// `signal(7)` says it must be between 32 and 64 and specifies
42+
/// `SIGRTMAX` - `SIGRTMIN` >= 8 (which is the value of `_POSIX_RTSIG_MAX`)
3743
pub const SIGRTMAX: i32 = 42;
3844

3945
/// Extra data stored with each stack frame

src/shims/unix/linux/foreign_items.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use rustc_span::Symbol;
22
use rustc_target::spec::abi::Abi;
33

44
use crate::machine::SIGRTMAX;
5+
use crate::machine::SIGRTMIN;
56
use crate::*;
67
use shims::foreign_items::EmulateByNameResult;
78
use shims::unix::fs::EvalContextExt as _;
@@ -74,6 +75,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
7475
let result = this.socketpair(domain, type_, protocol, sv)?;
7576
this.write_scalar(result, dest)?;
7677
}
78+
"__libc_current_sigrtmin" => {
79+
let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
80+
81+
this.write_scalar(Scalar::from_i32(SIGRTMIN), dest)?;
82+
}
7783
"__libc_current_sigrtmax" => {
7884
let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
7985

tests/pass-dep/shims/libc-misc.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,24 @@ fn test_posix_mkstemp() {
302302
}
303303
}
304304

305+
#[cfg(target_os = "linux")]
306+
fn test_sigrt() {
307+
let min = libc::SIGRTMIN();
308+
let max = libc::SIGRTMAX();
309+
310+
// "The Linux kernel supports a range of 33 different real-time
311+
// signals, numbered 32 to 64"
312+
assert!(min >= 32);
313+
assert!(max >= 32);
314+
assert!(min <= 64);
315+
assert!(max <= 64);
316+
317+
// "POSIX.1-2001 requires that an implementation support at least
318+
// _POSIX_RTSIG_MAX (8) real-time signals.""
319+
assert!(min < max);
320+
assert!(max - min >= 8)
321+
}
322+
305323
fn main() {
306324
test_posix_gettimeofday();
307325
test_posix_mkstemp();
@@ -319,5 +337,6 @@ fn main() {
319337
{
320338
test_posix_fadvise();
321339
test_sync_file_range();
340+
test_sigrt();
322341
}
323342
}

0 commit comments

Comments
 (0)