Skip to content

Fix duplicated exception handlers. #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ environment:
global:
CRATE_NAME: svd2rust
RUST_VERSION: stable
# workaround for AppVeyor issues (2017-07-21)
RUSTUP_USE_HYPER: 1
CARGO_HTTP_CHECK_REVOKE: false


matrix:
# MinGW
Expand Down
57 changes: 24 additions & 33 deletions src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ pub fn device(

if *target != Target::None {
items.push(quote! {
#![cfg_attr(feature = "rt", feature(asm))]
#![cfg_attr(feature = "rt", feature(core_intrinsics))]
#![cfg_attr(feature = "rt", feature(global_asm))]
#![cfg_attr(feature = "rt", feature(linkage))]
#![cfg_attr(feature = "rt", feature(macro_reexport))]
#![cfg_attr(feature = "rt", feature(naked_functions))]
#![cfg_attr(feature = "rt", feature(used))]
});
}
Expand Down Expand Up @@ -234,52 +232,45 @@ pub fn interrupt(
names.push(name_uc);
}

let aliases = names.iter()
.map(|n| format!("
.weak {0}
{0} = DEFAULT_HANDLER", n))
.collect::<Vec<_>>()
.concat();

let n = util::unsuffixed(u64(pos));
match *target {
Target::CortexM => {
mod_items.push(quote! {
#(
#[allow(non_snake_case)]
#[allow(private_no_mangle_fns)]
#[cfg(feature = "rt")]
#[linkage = "weak"]
#[naked]
#[no_mangle]
extern "C" fn #names() {
unsafe {
asm!("b DEFAULT_HANDLER" :::: "volatile");
::core::intrinsics::unreachable()
}
}
)*
#[cfg(feature = "rt")]
global_asm!(#aliases);

#[cfg(feature = "rt")]
extern "C" {
#(fn #names();)*
}

#[allow(private_no_mangle_statics)]
#[cfg(feature = "rt")]
#[doc(hidden)]
#[link_section = ".vector_table.interrupts"]
#[no_mangle]
#[used]
pub static INTERRUPTS: [Option<extern "C" fn()>; #n] = [
pub static INTERRUPTS: [Option<unsafe extern "C" fn()>; #n] = [
#(#elements,)*
];
});
}
Target::Msp430 => {
mod_items.push(quote! {
#(
#[allow(non_snake_case)]
#[allow(private_no_mangle_fns)]
#[cfg(feature = "rt")]
#[linkage = "weak"]
#[naked]
#[no_mangle]
extern "msp430-interrupt" fn #names() {
unsafe {
asm!("jmp DEFAULT_HANDLER" :::: "volatile");
::core::intrinsics::unreachable()
}
}
)*
#[cfg(feature = "rt")]
global_asm!(#aliases);

#[cfg(feature = "rt")]
extern "msp430-interrupt" {
#(fn #names();)*
}

#[allow(private_no_mangle_statics)]
#[cfg(feature = "rt")]
Expand All @@ -288,7 +279,7 @@ pub fn interrupt(
#[no_mangle]
#[used]
pub static INTERRUPTS:
[Option<extern "msp430-interrupt" fn()>; #n] = [
[Option<unsafe extern "msp430-interrupt" fn()>; #n] = [
#(#elements,)*
];
});
Expand Down