File tree 2 files changed +9
-2
lines changed
library/std/src/sys/pal/windows
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -89,8 +89,16 @@ extern "system" {
89
89
// Either a non-null handle returned by `GetProcessHeap`, or null when not yet initialized or `GetProcessHeap` failed.
90
90
static HEAP : AtomicPtr < c_void > = AtomicPtr :: new ( ptr:: null_mut ( ) ) ;
91
91
92
+ // This initializer will be executed before `main` or `DllMain`.
93
+ //
94
+ // The linker will place this initializer before any CRT initializers. However, user code should
95
+ // use .CRT$XCU to store their initializers. See comments in `compat` mod.
96
+ #[ used]
97
+ #[ link_section = ".CRT$XCB" ]
98
+ static INIT_TABLE_ENTRY : unsafe extern "C" fn ( ) = init;
99
+
92
100
// Initialize `HEAP` when the app starts.
93
- pub fn init ( ) {
101
+ unsafe extern "C" fn init ( ) {
94
102
let heap = unsafe { GetProcessHeap ( ) } ;
95
103
// SAFETY: No locking is needed because within the same process,
96
104
// successful calls to `GetProcessHeap` will always return the same value, even on different threads.
Original file line number Diff line number Diff line change @@ -58,7 +58,6 @@ impl<T> IoResult<T> for Result<T, api::WinError> {
58
58
// SAFETY: must be called only once during runtime initialization.
59
59
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
60
60
pub unsafe fn init ( _argc : isize , _argv : * const * const u8 , _sigpipe : u8 ) {
61
- alloc:: init ( ) ;
62
61
stack_overflow:: init ( ) ;
63
62
64
63
// Normally, `thread::spawn` will call `Thread::set_name` but since this thread already
You can’t perform that action at this time.
0 commit comments