From de5dd40a4f898f206387ead5af81c11147a0011a Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Sun, 6 Aug 2023 13:27:01 +0100 Subject: [PATCH] Add ABI-compatibility assertion --- src/abi.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/abi.rs b/src/abi.rs index 7e1529b..12766c1 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -118,7 +118,18 @@ macro_rules! binding { }; } -#[cfg(not(feature = "unwinder"))] +#[cfg(feature = "unwinder")] +macro_rules! binding { + () => {}; + (unsafe extern $abi: literal fn $name: ident ($($arg: ident : $arg_ty: ty),*$(,)?) $(-> $ret: ty)?; $($rest: tt)*) => { + const _: unsafe extern $abi fn($($arg_ty),*) $(-> $ret)? = $name; + }; + + (extern $abi: literal fn $name: ident ($($arg: ident : $arg_ty: ty),*$(,)?) $(-> $ret: ty)?; $($rest: tt)*) => { + const _: extern $abi fn($($arg_ty),*) $(-> $ret)? = $name; + }; +} + binding! { extern "C" fn _Unwind_GetGR(unwind_ctx: &UnwindContext<'_>, index: c_int) -> usize; extern "C" fn _Unwind_GetCFA(unwind_ctx: &UnwindContext<'_>) -> usize;