use glib::translate::*;
macro_rules! skip_assert_initialized {
() => {};
}
pub static INITIALIZED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
macro_rules! assert_initialized_main_thread {
() => {
if !$crate::rt::INITIALIZED.load(std::sync::atomic::Ordering::SeqCst) {
panic!("Mirage has not been initialized. Call `libmirage::init` first.");
}
};
}
#[doc(alias = "mirage_initialize")]
pub unsafe fn init() -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::mirage_initialize(&mut error);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
INITIALIZED.store(true, std::sync::atomic::Ordering::SeqCst);
Ok(())
} else {
Err(from_glib_full(error))
}
}
}