Skip to content

Commit

Permalink
More edition 2024 preparation
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Oct 22, 2024
1 parent f4b2326 commit a1b75b6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
13 changes: 4 additions & 9 deletions src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)*);
};
Expand Down
2 changes: 1 addition & 1 deletion src/panic_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use core::sync::atomic::{AtomicI32, Ordering};
static PANIC_COUNT: Cell<usize> = Cell::new(0);

#[link(name = "c")]
extern "C" {}
unsafe extern "C" {}

pub(crate) fn drop_panic() {
eprintln!("Rust panics must be rethrown");
Expand Down
2 changes: 1 addition & 1 deletion src/unwinder/find_fde/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/unwinder/find_fde/gnu_eh_frame_hdr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test_crates/throw_and_catch/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use alloc::{borrow::ToOwned, string::String};
use unwinding::print::*;

#[link(name = "c")]
extern "C" {}
unsafe extern "C" {}

struct PrintOnDrop(String);

Expand Down

0 comments on commit a1b75b6

Please sign in to comment.