diff options
| author | bors <bors@rust-lang.org> | 2019-08-20 15:01:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-08-20 15:01:24 +0000 |
| commit | 5a56e05abd34e1936df74625c1f40cb6fee0cd4a (patch) | |
| tree | 33d5f0b1aec0faad29a18e8d9e40271486d8c59d /src/libstd/sys/unix/process/process_common.rs | |
| parent | 51879c3abaedb926739095d19a2af638ee6a07d8 (diff) | |
| parent | 218bcf2e01146eb87afbef608f00c8df1e54b415 (diff) | |
| download | rust-5a56e05abd34e1936df74625c1f40cb6fee0cd4a.tar.gz rust-5a56e05abd34e1936df74625c1f40cb6fee0cd4a.zip | |
Auto merge of #63744 - Centril:rollup-g4l3ra9, r=Centril
Rollup of 7 pull requests Successful merges: - #63216 (avoid unnecessary reservations in std::io::Take::read_to_end) - #63265 (Implement `nth_back` for ChunksExactMut) - #63691 (Fix bug in iter::Chain::size_hint) - #63722 (Don't use stage naming in RUSTFLAGS environment variables) - #63723 (Consolidate sigemptyset workarounds) - #63736 (Restore the rustc_plugin crate in the sysroot) - #63743 (Allow git to merge `Cargo.lock`) Failed merges: r? @ghost
Diffstat (limited to 'src/libstd/sys/unix/process/process_common.rs')
| -rw-r--r-- | src/libstd/sys/unix/process/process_common.rs | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index 6bb20bbe087..21fca23a8fe 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -20,6 +20,30 @@ cfg_if::cfg_if! { } } +// Android with api less than 21 define sig* functions inline, so it is not +// available for dynamic link. Implementing sigemptyset and sigaddset allow us +// to support older Android version (independent of libc version). +// The following implementations are based on https://git.io/vSkNf +cfg_if::cfg_if! { + if #[cfg(target_os = "android")] { + pub unsafe fn sigemptyset(set: *mut libc::sigset_t) -> libc::c_int { + set.write_bytes(0u8, 1); + return 0; + } + #[allow(dead_code)] + pub unsafe fn sigaddset(set: *mut libc::sigset_t, signum: libc::c_int) -> libc::c_int { + use crate::{slice, mem}; + + let raw = slice::from_raw_parts_mut(set as *mut u8, mem::size_of::<libc::sigset_t>()); + let bit = (signum - 1) as usize; + raw[bit / 8] |= 1 << (bit % 8); + return 0; + } + } else { + pub use libc::{sigemptyset, sigaddset}; + } +} + //////////////////////////////////////////////////////////////////////////////// // Command //////////////////////////////////////////////////////////////////////////////// @@ -429,36 +453,6 @@ mod tests { } } - // Android with api less than 21 define sig* functions inline, so it is not - // available for dynamic link. Implementing sigemptyset and sigaddset allow us - // to support older Android version (independent of libc version). - // The following implementations are based on https://git.io/vSkNf - - #[cfg(not(target_os = "android"))] - extern { - #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")] - fn sigemptyset(set: *mut libc::sigset_t) -> libc::c_int; - - #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")] - fn sigaddset(set: *mut libc::sigset_t, signum: libc::c_int) -> libc::c_int; - } - - #[cfg(target_os = "android")] - unsafe fn sigemptyset(set: *mut libc::sigset_t) -> libc::c_int { - set.write_bytes(0u8, 1); - return 0; - } - - #[cfg(target_os = "android")] - unsafe fn sigaddset(set: *mut libc::sigset_t, signum: libc::c_int) -> libc::c_int { - use crate::slice; - - let raw = slice::from_raw_parts_mut(set as *mut u8, mem::size_of::<libc::sigset_t>()); - let bit = (signum - 1) as usize; - raw[bit / 8] |= 1 << (bit % 8); - return 0; - } - // See #14232 for more information, but it appears that signal delivery to a // newly spawned process may just be raced in the macOS, so to prevent this // test from being flaky we ignore it on macOS. |
