Skip to content

Commit 90e140e

Browse files
committed
fix interrupt macro
1 parent 9ac2ec9 commit 90e140e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

riscv-rt/macros/src/lib.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,16 @@ pub fn interrupt_riscv64(args: TokenStream, input: TokenStream) -> TokenStream {
331331
fn interrupt(args: TokenStream, input: TokenStream, _arch: RiscvArch) -> TokenStream {
332332
let f = parse_macro_input!(input as ItemFn);
333333

334+
// check the function arguments
335+
if !f.sig.inputs.is_empty() {
336+
return parse::Error::new(
337+
f.sig.inputs.first().unwrap().span(),
338+
"`#[interrupt]` function should not have arguments",
339+
)
340+
.to_compile_error()
341+
.into();
342+
}
343+
334344
// check the function signature
335345
let valid_signature = f.sig.constness.is_none()
336346
&& f.sig.asyncness.is_none()
@@ -362,6 +372,7 @@ fn interrupt(args: TokenStream, input: TokenStream, _arch: RiscvArch) -> TokenSt
362372
// XXX should we blacklist other attributes?
363373
let attrs = f.attrs;
364374
let ident = f.sig.ident;
375+
let export_name = format!("{:#}", ident);
365376
let block = f.block;
366377

367378
#[cfg(not(feature = "v-trap"))]
@@ -371,7 +382,7 @@ fn interrupt(args: TokenStream, input: TokenStream, _arch: RiscvArch) -> TokenSt
371382

372383
quote!(
373384
#start_trap
374-
#[export_name = #ident]
385+
#[export_name = #export_name]
375386
#(#attrs)*
376387
pub unsafe fn #ident() #block
377388
)

0 commit comments

Comments
 (0)