#[macro_export]
macro_rules! global_ctors_object {
($var_name:ident, $func_name:ident = $func:block) => {
cfg_if! {
if #[cfg(target_os = "linux")] {
#[link_section = ".init_array"]
#[no_mangle]
pub static $var_name: fn() = $func_name;
} else if #[cfg(target_os = "windows")] {
#[no_mangle]
pub static $var_name: fn() = $func_name;
} else if #[cfg(target_os = "macos")] {
#[no_mangle]
pub static $var_name: fn() = $func_name;
} else {
}
}
#[no_mangle]
pub fn $func_name() {
{$func};
}
}
}
#[macro_export]
macro_rules! global_dtors_object {
($var_name:ident, $func_name:ident = $func:block) => {
cfg_if! {
if #[cfg(target_os = "linux")] {
#[link_section = ".fini_array"]
#[no_mangle]
pub static $var_name: fn() = $func_name;
} else if #[cfg(target_os = "windows")] {
#[no_mangle]
pub static $var_name: fn() = $func_name;
} else if #[cfg(target_os = "macos")] {
#[no_mangle]
pub static $var_name: fn() = $func_name;
} else {
}
}
#[no_mangle]
pub fn $func_name() {
{$func};
}
}
}