mirror of
https://github.com/Noratrieb/portability.git
synced 2026-01-14 15:55:04 +01:00
30 lines
662 B
Rust
30 lines
662 B
Rust
#![feature(thread_local)]
|
|
#![no_std]
|
|
#![no_main]
|
|
#![windows_subsystem = "console"]
|
|
|
|
#[panic_handler]
|
|
fn handle_panic(_: &core::panic::PanicInfo<'_>) -> ! {
|
|
loop {}
|
|
}
|
|
|
|
#[thread_local]
|
|
static mut A_THREAD_LOCAL: u32 = 50;
|
|
#[thread_local]
|
|
static mut ANOTHER_THREAD_LOCAL: u32 = 55;
|
|
|
|
#[inline(never)]
|
|
fn set_tls(value: u32) {
|
|
unsafe { A_THREAD_LOCAL = value; }
|
|
unsafe { ANOTHER_THREAD_LOCAL = value; }
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub extern "stdcall" fn mainCRTStartup() -> u32 {
|
|
// Use some indirection to actually force TLS to happen
|
|
set_tls(14);
|
|
unsafe { A_THREAD_LOCAL + ANOTHER_THREAD_LOCAL }
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub extern "stdcall" fn _tls_index() {}
|