about summary refs log tree commit diff
path: root/library/std/src/sys_common/mod.rs
diff options
context:
space:
mode:
authorChristiaan Dirkx <christiaan@dirkx.email>2021-04-11 07:05:39 +0200
committerChristiaan Dirkx <christiaan@dirkx.email>2021-04-22 10:34:48 +0200
commit5b30662741afdb59865ecefe3026fcaf1f853c7d (patch)
tree02989ef53129cd47e844479dc397dc61ea78e6de /library/std/src/sys_common/mod.rs
parent71965ab4d05b023cd29c914ef1262a72cac02e01 (diff)
downloadrust-5b30662741afdb59865ecefe3026fcaf1f853c7d.tar.gz
rust-5b30662741afdb59865ecefe3026fcaf1f853c7d.zip
Rework `at_exit` to `cleanup`
Diffstat (limited to 'library/std/src/sys_common/mod.rs')
-rw-r--r--library/std/src/sys_common/mod.rs55
1 files changed, 2 insertions, 53 deletions
diff --git a/library/std/src/sys_common/mod.rs b/library/std/src/sys_common/mod.rs
index 23a3a0e907d..449ce509d25 100644
--- a/library/std/src/sys_common/mod.rs
+++ b/library/std/src/sys_common/mod.rs
@@ -20,35 +20,6 @@
 #[cfg(test)]
 mod tests;
 
-use crate::sync::Once;
-use crate::sys;
-
-macro_rules! rtabort {
-    ($($t:tt)*) => (crate::sys_common::util::abort(format_args!($($t)*)))
-}
-
-macro_rules! rtassert {
-    ($e:expr) => {
-        if !$e {
-            rtabort!(concat!("assertion failed: ", stringify!($e)));
-        }
-    };
-}
-
-#[allow(unused_macros)] // not used on all platforms
-macro_rules! rtunwrap {
-    ($ok:ident, $e:expr) => {
-        match $e {
-            $ok(v) => v,
-            ref err => {
-                let err = err.as_ref().map(drop); // map Ok/Some which might not be Debug
-                rtabort!(concat!("unwrap failed: ", stringify!($e), " = {:?}"), err)
-            }
-        }
-    };
-}
-
-pub mod at_exit_imp;
 pub mod backtrace;
 pub mod bytestring;
 pub mod condvar;
@@ -62,6 +33,8 @@ pub mod os_str_bytes;
 pub mod poison;
 pub mod process;
 pub mod remutex;
+#[macro_use]
+pub mod rt;
 pub mod rwlock;
 pub mod thread;
 pub mod thread_info;
@@ -109,30 +82,6 @@ pub trait FromInner<Inner> {
     fn from_inner(inner: Inner) -> Self;
 }
 
-/// Enqueues a procedure to run when the main thread exits.
-///
-/// Currently these closures are only run once the main *Rust* thread exits.
-/// Once the `at_exit` handlers begin running, more may be enqueued, but not
-/// infinitely so. Eventually a handler registration will be forced to fail.
-///
-/// Returns `Ok` if the handler was successfully registered, meaning that the
-/// closure will be run once the main thread exits. Returns `Err` to indicate
-/// that the closure could not be registered, meaning that it is not scheduled
-/// to be run.
-pub fn at_exit<F: FnOnce() + Send + 'static>(f: F) -> Result<(), ()> {
-    if at_exit_imp::push(Box::new(f)) { Ok(()) } else { Err(()) }
-}
-
-/// One-time runtime cleanup.
-pub fn cleanup() {
-    static CLEANUP: Once = Once::new();
-    CLEANUP.call_once(|| unsafe {
-        sys::args::cleanup();
-        sys::stack_overflow::cleanup();
-        at_exit_imp::cleanup();
-    });
-}
-
 // Computes (value*numer)/denom without overflow, as long as both
 // (numer*denom) and the overall result fit into i64 (which is the case
 // for our time conversions).