Skip to content

Commit 1acf27c

Browse files
bors[bot]rtzoeller
andauthored
Merge #1683
1683: Fix build for Redox and uclibc r=asomers a=rtzoeller - Redox renamed `sigaction.sa_handler` to `.sa_sigaction`, which lets us drop some specialized code for the platform. - uclibc now uses a `u32` for the `RLIMIT` definitions, like Linux GNU. Co-authored-by: Ryan Zoeller <[email protected]>
2 parents 445a438 + e3983d1 commit 1acf27c

File tree

3 files changed

+5
-37
lines changed

3 files changed

+5
-37
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ targets = [
2727
]
2828

2929
[dependencies]
30-
libc = { version = "0.2.115", features = [ "extra_traits" ] }
30+
libc = { version = "0.2.121", features = [ "extra_traits" ] }
3131
bitflags = "1.1"
3232
cfg-if = "1.0"
3333

src/sys/resource.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ libc_enum! {
3939
//
4040
// https://gcc.gnu.org/legacy-ml/gcc/2015-08/msg00441.html
4141
// https://github.com/rust-lang/libc/blob/master/src/unix/linux_like/linux/gnu/mod.rs
42-
#[cfg_attr(all(target_os = "linux", target_env = "gnu"), repr(u32))]
42+
#[cfg_attr(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc")), repr(u32))]
4343
#[cfg_attr(any(
4444
target_os = "freebsd",
4545
target_os = "openbsd",
@@ -48,7 +48,7 @@ libc_enum! {
4848
target_os = "ios",
4949
target_os = "android",
5050
target_os = "dragonfly",
51-
all(target_os = "linux", not(target_env = "gnu"))
51+
all(target_os = "linux", not(any(target_env = "gnu", target_env = "uclibc")))
5252
), repr(i32))]
5353
#[non_exhaustive]
5454
pub enum Resource {

src/sys/signal.rs

+2-34
Original file line numberDiff line numberDiff line change
@@ -670,21 +670,12 @@ impl SigAction {
670670
/// is the `SigAction` variant). `mask` specifies other signals to block during execution of
671671
/// the signal-catching function.
672672
pub fn new(handler: SigHandler, flags: SaFlags, mask: SigSet) -> SigAction {
673-
#[cfg(target_os = "redox")]
674-
unsafe fn install_sig(p: *mut libc::sigaction, handler: SigHandler) {
675-
(*p).sa_handler = match handler {
676-
SigHandler::SigDfl => libc::SIG_DFL,
677-
SigHandler::SigIgn => libc::SIG_IGN,
678-
SigHandler::Handler(f) => f as *const extern fn(libc::c_int) as usize,
679-
};
680-
}
681-
682-
#[cfg(not(target_os = "redox"))]
683673
unsafe fn install_sig(p: *mut libc::sigaction, handler: SigHandler) {
684674
(*p).sa_sigaction = match handler {
685675
SigHandler::SigDfl => libc::SIG_DFL,
686676
SigHandler::SigIgn => libc::SIG_IGN,
687677
SigHandler::Handler(f) => f as *const extern fn(libc::c_int) as usize,
678+
#[cfg(not(target_os = "redox"))]
688679
SigHandler::SigAction(f) => f as *const extern fn(libc::c_int, *mut libc::siginfo_t, *mut libc::c_void) as usize,
689680
};
690681
}
@@ -716,12 +707,11 @@ impl SigAction {
716707
}
717708

718709
/// Returns the action's handler.
719-
#[cfg(not(target_os = "redox"))]
720-
#[cfg_attr(docsrs, doc(cfg(all())))]
721710
pub fn handler(&self) -> SigHandler {
722711
match self.sigaction.sa_sigaction {
723712
libc::SIG_DFL => SigHandler::SigDfl,
724713
libc::SIG_IGN => SigHandler::SigIgn,
714+
#[cfg(not(target_os = "redox"))]
725715
p if self.flags().contains(SaFlags::SA_SIGINFO) =>
726716
SigHandler::SigAction(
727717
// Safe for one of two reasons:
@@ -749,28 +739,6 @@ impl SigAction {
749739
as extern fn(libc::c_int)),
750740
}
751741
}
752-
753-
/// Returns the action's handler.
754-
#[cfg(target_os = "redox")]
755-
#[cfg_attr(docsrs, doc(cfg(all())))]
756-
pub fn handler(&self) -> SigHandler {
757-
match self.sigaction.sa_handler {
758-
libc::SIG_DFL => SigHandler::SigDfl,
759-
libc::SIG_IGN => SigHandler::SigIgn,
760-
p => SigHandler::Handler(
761-
// Safe for one of two reasons:
762-
// * The SigHandler was created by SigHandler::new, in which
763-
// case the pointer is correct, or
764-
// * The SigHandler was created by signal or sigaction, which
765-
// are unsafe functions, so the caller should've somehow
766-
// ensured that it is correctly initialized.
767-
unsafe{
768-
*(&p as *const usize
769-
as *const extern fn(libc::c_int))
770-
}
771-
as extern fn(libc::c_int)),
772-
}
773-
}
774742
}
775743

776744
/// Changes the action taken by a process on receipt of a specific signal.

0 commit comments

Comments
 (0)