llt/
lib.rs

1use std::sync::atomic::{AtomicBool, Ordering};
2
3#[unsafe(no_mangle)]
4pub unsafe extern "C" fn add_one(x: u32) -> u32 {
5    println!(
6        "add one called, and constructors were run? {}",
7        WAS_CTOR_RUN.load(Ordering::SeqCst)
8    );
9    x + 1
10}
11
12static WAS_CTOR_RUN: AtomicBool = AtomicBool::new(false);
13
14#[used]
15#[doc(hidden)]
16#[allow(non_upper_case_globals)]
17#[unsafe(link_section = ".init_array")]
18static ___cons_test___ctor: unsafe extern "C" fn() = {
19    #[allow(non_snake_case)]
20    #[unsafe(link_section = ".text.startup")]
21    unsafe extern "C" fn ___cons_test___ctor() {
22        unsafe { cons_test() }
23    }
24    ___cons_test___ctor
25};
26unsafe fn cons_test() {
27    WAS_CTOR_RUN.store(true, Ordering::SeqCst);
28}