Skip to content

Commit cf47019

Browse files
committed
Move all cleanup to sys::cleanup
1 parent 5b30662 commit cf47019

File tree

13 files changed

+7
-24
lines changed

13 files changed

+7
-24
lines changed

library/std/src/sys/hermit/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ pub unsafe fn init() {
102102
}
103103

104104
// SAFETY: must be called only once during runtime cleanup.
105-
pub unsafe fn cleanup() {}
105+
pub unsafe fn cleanup() {
106+
args::cleanup();
107+
}
106108

107109
#[cfg(not(test))]
108110
#[no_mangle]
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
#[inline]
22
pub unsafe fn init() {}
3-
4-
#[inline]
5-
pub unsafe fn cleanup() {}

library/std/src/sys/sgx/args.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ pub unsafe fn init(argc: isize, argv: *const *const u8) {
2222
}
2323
}
2424

25-
pub unsafe fn cleanup() {}
26-
2725
pub fn args() -> Args {
2826
let args = unsafe { (ARGS.load(Ordering::Relaxed) as *const ArgsStore).as_ref() };
2927
if let Some(args) = args { Args(args.iter()) } else { Args([].iter()) }
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
#[cfg_attr(test, allow(dead_code))]
22
pub unsafe fn init() {}
3-
4-
pub unsafe fn cleanup() {}

library/std/src/sys/unix/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ pub unsafe fn init() {
126126
}
127127

128128
// SAFETY: must be called only once during runtime cleanup.
129-
pub unsafe fn cleanup() {}
129+
pub unsafe fn cleanup() {
130+
args::cleanup();
131+
stack_overflow::cleanup();
132+
}
130133

131134
#[cfg(target_os = "android")]
132135
pub use crate::sys::android::signal;

library/std/src/sys/unsupported/args.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::ffi::OsString;
22

33
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}
4-
pub unsafe fn cleanup() {}
54

65
pub struct Args {}
76

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
pub unsafe fn init() {}
2-
3-
pub unsafe fn cleanup() {}

library/std/src/sys/wasi/args.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ use crate::vec;
77

88
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}
99

10-
pub unsafe fn cleanup() {}
11-
1210
pub struct Args {
1311
iter: vec::IntoIter<OsString>,
1412
_dont_send_or_sync_me: PhantomData<*mut ()>,

library/std/src/sys/wasm/args.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
66
// On wasm these should always be null, so there's nothing for us to do here
77
}
88

9-
pub unsafe fn cleanup() {}
10-
119
pub fn args() -> Args {
1210
Args { iter: Vec::new().into_iter(), _dont_send_or_sync_me: PhantomData }
1311
}

library/std/src/sys/windows/args.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ use core::iter;
1616

1717
pub unsafe fn init(_argc: isize, _argv: *const *const u8) {}
1818

19-
pub unsafe fn cleanup() {}
20-
2119
pub fn args() -> Args {
2220
unsafe {
2321
let lp_cmd_line = c::GetCommandLineW();

library/std/src/sys/windows/stack_overflow.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,3 @@ pub unsafe fn init() {
3737
// Set the thread stack guarantee for the main thread.
3838
let _h = Handler::new();
3939
}
40-
41-
pub unsafe fn cleanup() {}

library/std/src/sys/windows/stack_overflow_uwp.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@ impl Handler {
99
}
1010

1111
pub unsafe fn init() {}
12-
13-
pub unsafe fn cleanup() {}

library/std/src/sys_common/rt.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ pub fn cleanup() {
3636
CLEANUP.call_once(|| unsafe {
3737
// SAFETY: Only called once during runtime cleanup.
3838
sys::cleanup();
39-
sys::args::cleanup();
40-
sys::stack_overflow::cleanup();
4139
// Flush stdout and disable buffering.
4240
crate::io::cleanup();
4341
});

0 commit comments

Comments
 (0)