From a1b75b6f4cdc0d3ca7697b0df1698867e1cc8bb4 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Tue, 22 Oct 2024 17:01:53 +0800 Subject: [PATCH] More edition 2024 preparation --- src/abi.rs | 13 ++++--------- src/panic_handler.rs | 2 +- src/unwinder/find_fde/fixed.rs | 2 +- src/unwinder/find_fde/gnu_eh_frame_hdr.rs | 2 +- test_crates/throw_and_catch/src/main.rs | 2 +- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/abi.rs b/src/abi.rs index 12766c1..7c48d74 100644 --- a/src/abi.rs +++ b/src/abi.rs @@ -99,20 +99,15 @@ pub type PersonalityRoutine = unsafe extern "C" fn( macro_rules! binding { () => {}; (unsafe extern $abi: literal fn $name: ident ($($arg: ident : $arg_ty: ty),*$(,)?) $(-> $ret: ty)?; $($rest: tt)*) => { - extern $abi { - pub fn $name($($arg: $arg_ty),*) $(-> $ret)?; + unsafe extern $abi { + pub unsafe fn $name($($arg: $arg_ty),*) $(-> $ret)?; } binding!($($rest)*); }; (extern $abi: literal fn $name: ident ($($arg: ident : $arg_ty: ty),*$(,)?) $(-> $ret: ty)?; $($rest: tt)*) => { - #[allow(non_snake_case)] - #[inline] - pub fn $name($($arg: $arg_ty),*) $(-> $ret)? { - extern $abi { - fn $name($($arg: $arg_ty),*) $(-> $ret)?; - } - unsafe { $name($($arg),*) } + unsafe extern $abi { + pub safe fn $name($($arg: $arg_ty),*) $(-> $ret)?; } binding!($($rest)*); }; diff --git a/src/panic_handler.rs b/src/panic_handler.rs index 1d07768..0d081e0 100644 --- a/src/panic_handler.rs +++ b/src/panic_handler.rs @@ -11,7 +11,7 @@ use core::sync::atomic::{AtomicI32, Ordering}; static PANIC_COUNT: Cell = Cell::new(0); #[link(name = "c")] -extern "C" {} +unsafe extern "C" {} pub(crate) fn drop_panic() { eprintln!("Rust panics must be rethrown"); diff --git a/src/unwinder/find_fde/fixed.rs b/src/unwinder/find_fde/fixed.rs index c9d6193..9e206ce 100644 --- a/src/unwinder/find_fde/fixed.rs +++ b/src/unwinder/find_fde/fixed.rs @@ -9,7 +9,7 @@ pub fn get_finder() -> &'static StaticFinder { &StaticFinder(()) } -extern "C" { +unsafe extern "C" { static __executable_start: u8; static __etext: u8; static __eh_frame: u8; diff --git a/src/unwinder/find_fde/gnu_eh_frame_hdr.rs b/src/unwinder/find_fde/gnu_eh_frame_hdr.rs index 0750769..0bd303a 100644 --- a/src/unwinder/find_fde/gnu_eh_frame_hdr.rs +++ b/src/unwinder/find_fde/gnu_eh_frame_hdr.rs @@ -9,7 +9,7 @@ pub fn get_finder() -> &'static StaticFinder { &StaticFinder(()) } -extern "C" { +unsafe extern "C" { static __executable_start: u8; static __etext: u8; static __GNU_EH_FRAME_HDR: u8; diff --git a/test_crates/throw_and_catch/src/main.rs b/test_crates/throw_and_catch/src/main.rs index c5295a3..a26b8c3 100644 --- a/test_crates/throw_and_catch/src/main.rs +++ b/test_crates/throw_and_catch/src/main.rs @@ -8,7 +8,7 @@ use alloc::{borrow::ToOwned, string::String}; use unwinding::print::*; #[link(name = "c")] -extern "C" {} +unsafe extern "C" {} struct PrintOnDrop(String);