use crate::util::etx;
use anyhow::{Context as _, Result};
use camino::Utf8Path;
use core::ffi::c_int;
use core::mem;
use libloading::os::unix as ll;
#[cfg(target_os = "linux")]
const DEEP_BIND: c_int = libc::RTLD_DEEPBIND;
#[cfg(not(target_os = "linux"))]
const DEEP_BIND: c_int = 0;
pub fn load(path: &Utf8Path) -> Result<()> {
let lib = unsafe { ll::Library::open(Some(path), ll::RTLD_GLOBAL | ll::RTLD_NOW | DEEP_BIND) };
let lib = lib.with_context(etx!("Failed to load {path:?}"))?;
mem::forget(lib);
Ok(())
}