Move all cleanup to sys::cleanup

This commit is contained in:
Christiaan Dirkx 2021-04-11 23:20:01 +02:00
parent 5b30662741
commit cf470197ad
13 changed files with 7 additions and 24 deletions

View File

@ -102,7 +102,9 @@ pub unsafe fn init() {
}
// SAFETY: must be called only once during runtime cleanup.
pub unsafe fn cleanup() {}
pub unsafe fn cleanup() {
args::cleanup();
}
#[cfg(not(test))]
#[no_mangle]

View File

@ -1,5 +1,2 @@
#[inline]
pub unsafe fn init() {}
#[inline]
pub unsafe fn cleanup() {}

View File

@ -22,8 +22,6 @@ pub unsafe fn init(argc: isize, argv: *const *const u8) {
}
}
pub unsafe fn cleanup() {}
pub fn args() -> Args {
let args = unsafe { (ARGS.load(Ordering::Relaxed) as *const ArgsStore).as_ref() };
if let Some(args) = args { Args(args.iter()) } else { Args([].iter()) }

View File

@ -1,4 +1,2 @@
#[cfg_attr(test, allow(dead_code))]
pub unsafe fn init() {}
pub unsafe fn cleanup() {}

View File

@ -126,7 +126,10 @@ pub unsafe fn init() {
}
// SAFETY: must be called only once during runtime cleanup.
pub unsafe fn cleanup() {}
pub unsafe fn cleanup() {
args::cleanup();
stack_overflow::cleanup();
}
#[cfg(target_os = "android")]
pub use crate::sys::android::signal;

View File

@ -1,7 +1,6 @@
use crate::ffi::OsString;
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}
pub unsafe fn cleanup() {}
pub struct Args {}

View File

@ -1,3 +1 @@
pub unsafe fn init() {}
pub unsafe fn cleanup() {}

View File

@ -7,8 +7,6 @@ use crate::vec;
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}
pub unsafe fn cleanup() {}
pub struct Args {
iter: vec::IntoIter<OsString>,
_dont_send_or_sync_me: PhantomData<*mut ()>,

View File

@ -6,8 +6,6 @@ pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
// On wasm these should always be null, so there's nothing for us to do here
}
pub unsafe fn cleanup() {}
pub fn args() -> Args {
Args { iter: Vec::new().into_iter(), _dont_send_or_sync_me: PhantomData }
}

View File

@ -16,8 +16,6 @@ use core::iter;
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}
pub unsafe fn cleanup() {}
pub fn args() -> Args {
unsafe {
let lp_cmd_line = c::GetCommandLineW();

View File

@ -37,5 +37,3 @@ pub unsafe fn init() {
// Set the thread stack guarantee for the main thread.
let _h = Handler::new();
}
pub unsafe fn cleanup() {}

View File

@ -9,5 +9,3 @@ impl Handler {
}
pub unsafe fn init() {}
pub unsafe fn cleanup() {}

View File

@ -36,8 +36,6 @@ pub fn cleanup() {
CLEANUP.call_once(|| unsafe {
// SAFETY: Only called once during runtime cleanup.
sys::cleanup();
sys::args::cleanup();
sys::stack_overflow::cleanup();
// Flush stdout and disable buffering.
crate::io::cleanup();
});