Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
kiffie committed Jul 16, 2023
1 parent f00c3c1 commit 6bfb2c7
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions mips-rt/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,32 +153,33 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
},
};

if !valid_signature {
return parse::Error::new(
fspan,
"`#[exception]`exception handlers must have signature `unsafe fn(u32, u32) [-> !]`",
)
.to_compile_error()
.into();
}
if !valid_signature {
return parse::Error::new(
fspan,
"`#[exception]`exception handlers must have signature `unsafe fn(u32, u32) [-> !]`",
)
.to_compile_error()
.into();
}

f.sig.ident = Ident::new(&format!("__mips_rt_{}", f.sig.ident), Span::call_site());
let tramp_ident = Ident::new(&format!("{}_trampoline", f.sig.ident), Span::call_site());
let ident = &f.sig.ident;
f.sig.ident = Ident::new(&format!("__mips_rt_{}", f.sig.ident), Span::call_site());
let tramp_ident = Ident::new(&format!("{}_trampoline", f.sig.ident), Span::call_site());
let ident = &f.sig.ident;

let (ref cfgs, ref attrs) = extract_cfgs(f.attrs.clone());
let (ref cfgs, ref attrs) = extract_cfgs(f.attrs.clone());

quote!(
#(#cfgs)*
#(#attrs)*
#[doc(hidden)]
#[export_name = #export_name]
pub unsafe extern "C" fn #tramp_ident(cp0_cause: u32, cp0_status: u32) {
#ident(cp0_cause, cp0_status)
}
quote!(
#(#cfgs)*
#(#attrs)*
#[doc(hidden)]
#[export_name = #export_name]
pub unsafe extern "C" fn #tramp_ident(cp0_cause: u32, cp0_status: u32) {
#ident(cp0_cause, cp0_status)
}

#f
).into()
#f
)
.into()
}

#[proc_macro_attribute]
Expand Down

0 comments on commit 6bfb2c7

Please sign in to comment.