Files
Simonas Kazlauskas f75a0d0606 Do not encourage use of libloading for TLS
On MSVC Windows loading a TLS symbol will give an address to the
initializer (which when overwritten simply changes the default value new
threads gain for the variable).

On macOS thread locals are misimplemented entirely.

On Linux things "just work", but unknown to what extent, really.

Since the behaviour of using thread local variables as if they were
plain global variables is mostly undefined, lets just not make any
claims of this working.
2020-08-22 19:53:18 +00:00

38 lines
747 B
Rust

//! This is a separate file containing helpers for tests of this library. It is built into a
//! dynamic library by the build.rs script.
#![crate_type="cdylib"]
#[no_mangle]
pub static mut TEST_STATIC_U32: u32 = 0;
#[no_mangle]
pub static mut TEST_STATIC_PTR: *mut () = 0 as *mut _;
#[no_mangle]
pub extern "C" fn test_identity_u32(x: u32) -> u32 {
x
}
#[repr(C)]
pub struct S {
a: u64,
b: u32,
c: u16,
d: u8
}
#[no_mangle]
pub extern "C" fn test_identity_struct(x: S) -> S {
x
}
#[no_mangle]
pub unsafe extern "C" fn test_get_static_u32() -> u32 {
TEST_STATIC_U32
}
#[no_mangle]
pub unsafe extern "C" fn test_check_static_ptr() -> bool {
TEST_STATIC_PTR == (&mut TEST_STATIC_PTR as *mut *mut _ as *mut _)
}