From b625102e4715eea57349d0619bd5cc1434bcfc90 Mon Sep 17 00:00:00 2001 From: WANG rui Date: Fri, 7 Apr 2023 15:49:36 +0800 Subject: [PATCH] Add support for the loongarch64 architecture --- libffi-sys-rs/src/arch.rs | 20 ++++++++++++++++++++ libffi-sys-rs/src/lib.rs | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/libffi-sys-rs/src/arch.rs b/libffi-sys-rs/src/arch.rs index 0a1e5e4e..4ffe486a 100644 --- a/libffi-sys-rs/src/arch.rs +++ b/libffi-sys-rs/src/arch.rs @@ -343,3 +343,23 @@ mod s390x { #[cfg(target_arch = "s390x")] pub use s390x::*; + +/// From libffi:src/loongarch64/ffitarget.h. +/// See: +mod loongarch64 { + use crate::ffi_abi; + + pub const ffi_abi_FFI_FIRST_ABI: ffi_abi = 0; + pub const ffi_abi_FFI_LP64S: ffi_abi = 1; + pub const ffi_abi_FFI_LP64F: ffi_abi = 2; + pub const ffi_abi_FFI_LP64D: ffi_abi = 3; + pub const ffi_abi_FFI_LAST_ABI: ffi_abi = 4; + pub const ffi_abi_FFI_DEFAULT_ABI: ffi_abi = ffi_abi_FFI_LP64D; + + pub const FFI_GO_CLOSURES: u32 = 1; + pub const FFI_TRAMPOLINE_SIZE: usize = 24; + pub const FFI_NATIVE_RAW_API: u32 = 0; +} + +#[cfg(target_arch = "loongarch64")] +pub use loongarch64::*; diff --git a/libffi-sys-rs/src/lib.rs b/libffi-sys-rs/src/lib.rs index e652ce69..89029ed5 100644 --- a/libffi-sys-rs/src/lib.rs +++ b/libffi-sys-rs/src/lib.rs @@ -133,6 +133,10 @@ pub struct ffi_cif { pub riscv_nfixedargs: c_uint, #[cfg(any(target_arch = "riscv", target_arch = "riscv64"))] pub riscv_unused: c_uint, + #[cfg(all(target_arch = "loongarch64"))] + pub loongarch_nfixedargs: c_uint, + #[cfg(all(target_arch = "loongarch64"))] + pub loongarch_unused: c_uint, } impl Default for ffi_cif {