#![cfg_attr(test, allow(dead_code))]
-use self::imp::{make_handler, drop_handler};
+use self::imp::{drop_handler, make_handler};
pub use self::imp::cleanup;
pub use self::imp::init;
pub struct Handler {
- _data: *mut libc::c_void
+ _data: *mut libc::c_void,
}
impl Handler {
}
}
-#[cfg(any(target_os = "linux",
- target_os = "macos",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "solaris",
- all(target_os = "netbsd", not(target_vendor = "rumprun")),
- target_os = "openbsd"))]
+#[cfg(any(
+ target_os = "linux",
+ target_os = "macos",
+ target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "solaris",
+ all(target_os = "netbsd", not(target_vendor = "rumprun")),
+ target_os = "openbsd"
+))]
mod imp {
use super::Handler;
use crate::mem;
use crate::ptr;
- use libc::{sigaltstack, SIGSTKSZ, SS_DISABLE};
- use libc::{sigaction, SIGBUS, SIG_DFL,
- SA_SIGINFO, SA_ONSTACK, sighandler_t};
- use libc::{mmap, munmap};
- use libc::{SIGSEGV, PROT_READ, PROT_WRITE, MAP_PRIVATE, MAP_ANON};
use libc::MAP_FAILED;
+ use libc::{mmap, munmap};
+ use libc::{sigaction, sighandler_t, SA_ONSTACK, SA_SIGINFO, SIGBUS, SIG_DFL};
+ use libc::{sigaltstack, SIGSTKSZ, SS_DISABLE};
+ use libc::{MAP_ANON, MAP_PRIVATE, PROT_READ, PROT_WRITE, SIGSEGV};
use crate::sys_common::thread_info;
-
#[cfg(any(target_os = "linux", target_os = "android"))]
unsafe fn siginfo_si_addr(info: *mut libc::siginfo_t) -> usize {
#[repr(C)]
// out many large systems and all implementations allow returning from a
// signal handler to work. For a more detailed explanation see the
// comments on #26458.
- unsafe extern fn signal_handler(signum: libc::c_int,
- info: *mut libc::siginfo_t,
- _data: *mut libc::c_void) {
+ unsafe extern "C" fn signal_handler(
+ signum: libc::c_int,
+ info: *mut libc::siginfo_t,
+ _data: *mut libc::c_void,
+ ) {
use crate::sys_common::util::report_overflow;
let guard = thread_info::stack_guard().unwrap_or(0..0);
}
unsafe fn get_stackp() -> *mut libc::c_void {
- let stackp = mmap(ptr::null_mut(),
- SIGSTKSZ,
- PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANON,
- -1,
- 0);
+ let stackp =
+ mmap(ptr::null_mut(), SIGSTKSZ, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
if stackp == MAP_FAILED {
panic!("failed to allocate an alternative stack");
}
stackp
}
- #[cfg(any(target_os = "linux",
- target_os = "macos",
- target_os = "freebsd",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris"))]
+ #[cfg(any(
+ target_os = "linux",
+ target_os = "macos",
+ target_os = "freebsd",
+ target_os = "netbsd",
+ target_os = "openbsd",
+ target_os = "solaris"
+ ))]
unsafe fn get_stack() -> libc::stack_t {
libc::stack_t { ss_sp: get_stackp(), ss_flags: 0, ss_size: SIGSTKSZ }
}
pub unsafe fn drop_handler(handler: &mut Handler) {
if !handler._data.is_null() {
- let stack = libc::stack_t {
+ let stack = libc::stack_t {
ss_sp: ptr::null_mut(),
ss_flags: SS_DISABLE,
// Workaround for bug in macOS implementation of sigaltstack
}
}
-#[cfg(not(any(target_os = "linux",
- target_os = "macos",
- target_os = "dragonfly",
- target_os = "freebsd",
- target_os = "solaris",
- all(target_os = "netbsd", not(target_vendor = "rumprun")),
- target_os = "openbsd")))]
+#[cfg(not(any(
+ target_os = "linux",
+ target_os = "macos",
+ target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "solaris",
+ all(target_os = "netbsd", not(target_vendor = "rumprun")),
+ target_os = "openbsd"
+)))]
mod imp {
use crate::ptr;
- pub unsafe fn init() {
- }
+ pub unsafe fn init() {}
- pub unsafe fn cleanup() {
- }
+ pub unsafe fn cleanup() {}
pub unsafe fn make_handler() -> super::Handler {
super::Handler { _data: ptr::null_mut() }
}
- pub unsafe fn drop_handler(_handler: &mut super::Handler) {
- }
+ pub unsafe fn drop_handler(_handler: &mut super::Handler) {}
}