File tree Expand file tree Collapse file tree 6 files changed +13
-2
lines changed Expand file tree Collapse file tree 6 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -96,12 +96,14 @@ pub extern "C" fn __rust_abort() {
9696}
9797
9898// SAFETY: must be called only once during runtime initialization.
99+ // NOTE: this is not guaranteed to run, for example when Rust code is called externally.
99100pub unsafe fn init ( argc : isize , argv : * const * const u8 ) {
100101 let _ = net:: init ( ) ;
101102 args:: init ( argc, argv) ;
102103}
103104
104105// SAFETY: must be called only once during runtime cleanup.
106+ // NOTE: this is not guaranteed to run, for example when the program aborts.
105107pub unsafe fn cleanup ( ) {
106108 args:: cleanup ( ) ;
107109}
Original file line number Diff line number Diff line change @@ -40,13 +40,15 @@ pub mod time;
4040pub use crate :: sys_common:: os_str_bytes as os_str;
4141
4242// SAFETY: must be called only once during runtime initialization.
43+ // NOTE: this is not guaranteed to run, for example when Rust code is called externally.
4344pub unsafe fn init ( argc : isize , argv : * const * const u8 ) {
4445 unsafe {
4546 args:: init ( argc, argv) ;
4647 }
4748}
4849
4950// SAFETY: must be called only once during runtime cleanup.
51+ // NOTE: this is not guaranteed to run, for example when the program aborts.
5052pub unsafe fn cleanup ( ) { }
5153
5254/// This function is used to implement functionality that simply doesn't exist.
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ pub mod time;
4545pub use crate :: sys_common:: os_str_bytes as os_str;
4646
4747// SAFETY: must be called only once during runtime initialization.
48+ // NOTE: this is not guaranteed to run, for example when Rust code is called externally.
4849pub unsafe fn init ( argc : isize , argv : * const * const u8 ) {
4950 // The standard streams might be closed on application startup. To prevent
5051 // 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) {
120121}
121122
122123// SAFETY: must be called only once during runtime cleanup.
124+ // NOTE: this is not guaranteed to run, for example when the program aborts.
123125pub unsafe fn cleanup ( ) {
124126 args:: cleanup ( ) ;
125127 stack_overflow:: cleanup ( ) ;
Original file line number Diff line number Diff line change @@ -11,9 +11,11 @@ pub use crate::sys_common::os_str_bytes as os_str;
1111use crate :: os:: raw:: c_char;
1212
1313// SAFETY: must be called only once during runtime initialization.
14+ // NOTE: this is not guaranteed to run, for example when Rust code is called externally.
1415pub unsafe fn init ( _argc : isize , _argv : * const * const u8 ) { }
1516
1617// SAFETY: must be called only once during runtime cleanup.
18+ // NOTE: this is not guaranteed to run, for example when the program aborts.
1719pub unsafe fn cleanup ( ) { }
1820
1921pub fn unsupported < T > ( ) -> std_io:: Result < T > {
Original file line number Diff line number Diff line change @@ -50,11 +50,13 @@ cfg_if::cfg_if! {
5050}
5151
5252// SAFETY: must be called only once during runtime initialization.
53+ // NOTE: this is not guaranteed to run, for example when Rust code is called externally.
5354pub unsafe fn init ( _argc : isize , _argv : * const * const u8 ) {
5455 stack_overflow:: init ( ) ;
5556}
5657
5758// SAFETY: must be called only once during runtime cleanup.
59+ // NOTE: this is not guaranteed to run, for example when the program aborts.
5860pub unsafe fn cleanup ( ) {
5961 net:: cleanup ( ) ;
6062}
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use crate::thread::Thread;
55
66// One-time runtime initialization.
77// Runs before `main`.
8+ // NOTE: this is not guaranteed to run, for example when Rust code is called externally.
89#[ cfg_attr( test, allow( dead_code) ) ]
910pub fn init ( argc : isize , argv : * const * const u8 ) {
1011 static INIT : Once = Once :: new ( ) ;
@@ -23,8 +24,8 @@ pub fn init(argc: isize, argv: *const *const u8) {
2324}
2425
2526// One-time runtime cleanup.
26- // Runs after `main` or at program exit. Note however that this is not guaranteed to run,
27- // for example when the program aborts.
27+ // Runs after `main` or at program exit.
28+ // NOTE: this is not guaranteed to run, for example when the program aborts.
2829#[ cfg_attr( test, allow( dead_code) ) ]
2930pub fn cleanup ( ) {
3031 static CLEANUP : Once = Once :: new ( ) ;
You can’t perform that action at this time.
0 commit comments