#[cfg(any(
windows,
target_os = "linux",
target_os = "macos",
target_os = "ios",
test
))]
pub(crate) const PTR_SIZE: usize = core::mem::size_of::<usize>();
#[cfg(any(windows, test))]
#[cfg_attr(not(target_arch = "x86_64"), allow(dead_code))]
pub(crate) const IMAGE_FILE_MACHINE_AMD64: u16 = 0x8664;
#[cfg(any(windows, test))]
#[cfg_attr(not(target_arch = "aarch64"), allow(dead_code))]
pub(crate) const IMAGE_FILE_MACHINE_ARM64: u16 = 0xAA64;
#[cfg(all(any(windows, test), target_arch = "x86_64"))]
pub(crate) const HOST_MACHINE: u16 = IMAGE_FILE_MACHINE_AMD64;
#[cfg(all(any(windows, test), target_arch = "aarch64"))]
pub(crate) const HOST_MACHINE: u16 = IMAGE_FILE_MACHINE_ARM64;
#[cfg(any(target_os = "linux", test))]
pub(crate) const EM_X86_64: u16 = 62;
#[cfg(any(target_os = "linux", test))]
pub(crate) const EM_AARCH64: u16 = 183;
#[cfg(any(target_os = "linux", test))]
#[derive(Debug, Clone, Copy)]
pub(crate) struct ElfRelocKinds {
pub(crate) jump_slot: u32,
pub(crate) glob_dat: u32,
}
#[cfg(any(target_os = "linux", test))]
pub(crate) const fn elf_reloc_kinds(e_machine: u16) -> Option<ElfRelocKinds> {
match e_machine {
EM_X86_64 => Some(ElfRelocKinds {
jump_slot: 7,
glob_dat: 6,
}),
EM_AARCH64 => Some(ElfRelocKinds {
jump_slot: 1026,
glob_dat: 1025,
}),
_ => None,
}
}
#[cfg(any(target_os = "macos", target_os = "ios", test))]
pub(crate) const CPU_ARCH_ABI64: u32 = 0x0100_0000;
#[cfg(any(target_os = "macos", target_os = "ios", test))]
pub(crate) const CPU_TYPE_X86_64: u32 = 0x7 | CPU_ARCH_ABI64;
#[cfg(any(target_os = "macos", target_os = "ios", test))]
pub(crate) const CPU_TYPE_ARM64: u32 = 0xc | CPU_ARCH_ABI64;
#[cfg(any(target_os = "macos", target_os = "ios", test))]
pub(crate) const CPU_SUBTYPE_MASK: u32 = 0xff00_0000;
#[cfg(any(target_os = "macos", target_os = "ios", test))]
pub(crate) const CPU_SUBTYPE_ARM64E: u32 = 2;
#[cfg(any(target_os = "macos", target_os = "ios", test))]
pub(crate) const fn macho_cpu_supported(cputype: u32) -> bool {
matches!(cputype, CPU_TYPE_X86_64 | CPU_TYPE_ARM64)
}