Skip to content

Commit 245179f

Browse files
committed
fix interrupt macro
1 parent 9ac2ec9 commit 245179f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

riscv-rt/macros/src/lib.rs

Lines changed: 13 additions & 2 deletions
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
)
@@ -404,7 +415,7 @@ mod v_trap {
404415
"a7",
405416
];
406417

407-
pub fn start_interrupt_trap_asm(
418+
pub(crate) fn start_interrupt_trap_asm(
408419
ident: &syn::Ident,
409420
arch: RiscvArch,
410421
) -> proc_macro2::TokenStream {

0 commit comments

Comments
 (0)