diff options
| author | Christiaan Dirkx <christiaan@dirkx.email> | 2021-04-18 07:19:39 +0200 |
|---|---|---|
| committer | Christiaan Dirkx <christiaan@dirkx.email> | 2021-04-22 18:00:18 +0200 |
| commit | e1b1081d2ff80f49129da2002ce3f5efa6186825 (patch) | |
| tree | dcc0b789e324332e48071fe55131a9d62e6ec03f /library/std/src/sys | |
| parent | 8aeea227daf4a78761c41bb32321e8b2e505d27e (diff) | |
| download | rust-e1b1081d2ff80f49129da2002ce3f5efa6186825.tar.gz rust-e1b1081d2ff80f49129da2002ce3f5efa6186825.zip | |
Document that `init` and `cleanup` are not guaranteed to run
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/hermit/mod.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/sgx/mod.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/unix/mod.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/unsupported/common.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/windows/mod.rs | 2 |
5 files changed, 10 insertions, 0 deletions
diff --git a/library/std/src/sys/hermit/mod.rs b/library/std/src/sys/hermit/mod.rs index 77c068e1a97..a70d1db7ca6 100644 --- a/library/std/src/sys/hermit/mod.rs +++ b/library/std/src/sys/hermit/mod.rs @@ -96,12 +96,14 @@ pub extern "C" fn __rust_abort() { } // SAFETY: must be called only once during runtime initialization. +// NOTE: this is not guaranteed to run, for example when Rust code is called externally. pub unsafe fn init(argc: isize, argv: *const *const u8) { let _ = net::init(); args::init(argc, argv); } // SAFETY: must be called only once during runtime cleanup. +// NOTE: this is not guaranteed to run, for example when the program aborts. pub unsafe fn cleanup() { args::cleanup(); } diff --git a/library/std/src/sys/sgx/mod.rs b/library/std/src/sys/sgx/mod.rs index 25250d060d0..059d6cb5ba1 100644 --- a/library/std/src/sys/sgx/mod.rs +++ b/library/std/src/sys/sgx/mod.rs @@ -40,6 +40,7 @@ pub mod time; pub use crate::sys_common::os_str_bytes as os_str; // SAFETY: must be called only once during runtime initialization. +// NOTE: this is not guaranteed to run, for example when Rust code is called externally. pub unsafe fn init(argc: isize, argv: *const *const u8) { unsafe { args::init(argc, argv); @@ -47,6 +48,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8) { } // SAFETY: must be called only once during runtime cleanup. +// NOTE: this is not guaranteed to run, for example when the program aborts. pub unsafe fn cleanup() {} /// This function is used to implement functionality that simply doesn't exist. diff --git a/library/std/src/sys/unix/mod.rs b/library/std/src/sys/unix/mod.rs index 8ae0c1120ff..a0ee69c2f72 100644 --- a/library/std/src/sys/unix/mod.rs +++ b/library/std/src/sys/unix/mod.rs @@ -45,6 +45,7 @@ pub mod time; pub use crate::sys_common::os_str_bytes as os_str; // SAFETY: must be called only once during runtime initialization. +// NOTE: this is not guaranteed to run, for example when Rust code is called externally. pub unsafe fn init(argc: isize, argv: *const *const u8) { // The standard streams might be closed on application startup. To prevent // std::io::{stdin, stdout,stderr} objects from using other unrelated file @@ -120,6 +121,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8) { } // SAFETY: must be called only once during runtime cleanup. +// NOTE: this is not guaranteed to run, for example when the program aborts. pub unsafe fn cleanup() { args::cleanup(); stack_overflow::cleanup(); diff --git a/library/std/src/sys/unsupported/common.rs b/library/std/src/sys/unsupported/common.rs index c60c2a9b8e8..6e72a7c632e 100644 --- a/library/std/src/sys/unsupported/common.rs +++ b/library/std/src/sys/unsupported/common.rs @@ -11,9 +11,11 @@ pub use crate::sys_common::os_str_bytes as os_str; use crate::os::raw::c_char; // SAFETY: must be called only once during runtime initialization. +// NOTE: this is not guaranteed to run, for example when Rust code is called externally. pub unsafe fn init(_argc: isize, _argv: *const *const u8) {} // SAFETY: must be called only once during runtime cleanup. +// NOTE: this is not guaranteed to run, for example when the program aborts. pub unsafe fn cleanup() {} pub fn unsupported<T>() -> std_io::Result<T> { diff --git a/library/std/src/sys/windows/mod.rs b/library/std/src/sys/windows/mod.rs index 21fec2aa01b..ddb6ac5f55c 100644 --- a/library/std/src/sys/windows/mod.rs +++ b/library/std/src/sys/windows/mod.rs @@ -50,11 +50,13 @@ cfg_if::cfg_if! { } // SAFETY: must be called only once during runtime initialization. +// NOTE: this is not guaranteed to run, for example when Rust code is called externally. pub unsafe fn init(_argc: isize, _argv: *const *const u8) { stack_overflow::init(); } // SAFETY: must be called only once during runtime cleanup. +// NOTE: this is not guaranteed to run, for example when the program aborts. pub unsafe fn cleanup() { net::cleanup(); } |
