use libffi_sys::{ffi_abi_FFI_GNUW64, ffi_abi_FFI_WIN64};
#[cfg(not(docsrs))]
use super::Abi;
#[cfg(docsrs)]
pub struct Abi(libffi_sys::ffi_abi);
impl Abi {
pub const WIN64: Self = Abi(ffi_abi_FFI_WIN64);
pub const GNUW64: Self = Abi(ffi_abi_FFI_GNUW64);
pub const SYSTEM: Self = Self::WIN64;
#[cfg(test)]
#[doc(hidden)]
pub const ABIS: [Self; 3] = [Self::WIN64, Self::GNUW64, Self::SYSTEM];
}
impl Default for Abi {
fn default() -> Self {
#[cfg(target_env = "msvc")]
return Self::WIN64;
#[cfg(target_env = "gnu")]
return Self::GNUW64;
}
}
#[cfg(test)]
mod tests {
use super::super::test_utils::test_create_closure_and_call_with_abi;
use super::Abi;
#[test]
#[cfg_attr(miri, ignore)]
fn test_win64_abi_closure_call() {
test_create_closure_and_call_with_abi(Abi::WIN64);
}
#[test]
#[cfg_attr(miri, ignore)]
fn test_gnuw64_abi_closure_call() {
test_create_closure_and_call_with_abi(Abi::GNUW64);
}
#[test]
#[cfg_attr(miri, ignore)]
fn test_system_abi_closure_call() {
test_create_closure_and_call_with_abi(Abi::SYSTEM);
}
}