use alloc::boxed::Box;
use libc::{c_int, c_void};
#[no_mangle]
unsafe extern "C" fn __cxa_atexit(
func: unsafe extern "C" fn(*mut c_void),
arg: *mut c_void,
_dso: *mut c_void,
) -> c_int {
struct SendSync(*mut c_void);
unsafe impl Send for SendSync {}
unsafe impl Sync for SendSync {}
let arg = SendSync(arg);
origin::program::at_exit(Box::new(move || {
let arg: SendSync = arg;
func(arg.0);
}));
0
}
#[no_mangle]
unsafe extern "C" fn __cxa_finalize(_d: *mut c_void) {}
#[no_mangle]
unsafe extern "C" fn atexit(func: extern "C" fn()) -> c_int {
libc!(libc::atexit(func));
origin::program::at_exit(Box::new(move || func()));
0
}
#[no_mangle]
unsafe extern "C" fn exit(status: c_int) -> ! {
libc!(libc::exit(status));
origin::program::exit(status)
}
#[no_mangle]
unsafe extern "C" fn _Exit(status: c_int) -> ! {
origin::program::immediate_exit(status)
}
#[no_mangle]
unsafe extern "C" fn _exit(status: c_int) -> ! {
libc!(libc::_exit(status));
_Exit(status)
}
#[cold]
#[no_mangle]
unsafe extern "C" fn __stack_chk_fail() -> ! {
let message = b"*** stack smashing detected ***";
let _ = libc::write(libc::STDERR_FILENO, message.as_ptr().cast(), message.len());
libc::abort()
}
#[cold]
#[no_mangle]
unsafe extern "C" fn __stack_chk_fail_local() -> ! {
__stack_chk_fail()
}