Skip to content

Switch "native" check from being x86_64 only to checking HOST #369

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
Dec 29, 2021
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
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ use std::{env, fs};

fn main() {
let target = env::var("TARGET").unwrap();
let host_triple = env::var("HOST").unwrap();
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let name = env::var("CARGO_PKG_NAME").unwrap();

if host_triple == target {
println!("cargo:rustc-cfg=native");
}

if target.starts_with("thumb") {
let suffix = if env::var_os("CARGO_FEATURE_LINKER_PLUGIN_LTO").is_some() {
"-lto"
Expand Down
6 changes: 3 additions & 3 deletions src/peripheral/icb.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Implementation Control Block

#[cfg(any(armv7m, armv8m, target_arch = "x86_64"))]
#[cfg(any(armv7m, armv8m, native))]
use volatile_register::RO;
use volatile_register::RW;

Expand All @@ -12,12 +12,12 @@ pub struct RegisterBlock {
/// The bottom four bits of this register give the number of implemented
/// interrupt lines, divided by 32. So a value of `0b0010` indicates 64
/// interrupts.
#[cfg(any(armv7m, armv8m, target_arch = "x86_64"))]
#[cfg(any(armv7m, armv8m, native))]
pub ictr: RO<u32>,

/// The ICTR is not defined in the ARMv6-M Architecture Reference manual, so
/// we replace it with this.
#[cfg(not(any(armv7m, armv8m, target_arch = "x86_64")))]
#[cfg(not(any(armv7m, armv8m, native)))]
_reserved: u32,

/// Auxiliary Control Register
Expand Down
8 changes: 4 additions & 4 deletions src/peripheral/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ pub mod dcb;
pub mod dwt;
#[cfg(not(armv6m))]
pub mod fpb;
// NOTE(target_arch) is for documentation purposes
#[cfg(any(has_fpu, target_arch = "x86_64"))]
// NOTE(native) is for documentation purposes
#[cfg(any(has_fpu, native))]
pub mod fpu;
pub mod icb;
#[cfg(all(not(armv6m), not(armv8m_base)))]
Expand Down Expand Up @@ -411,7 +411,7 @@ pub struct FPU {

unsafe impl Send for FPU {}

#[cfg(any(has_fpu, target_arch = "x86_64"))]
#[cfg(any(has_fpu, native))]
impl FPU {
/// Pointer to the register block
pub const PTR: *const fpu::RegisterBlock = 0xE000_EF30 as *const _;
Expand All @@ -423,7 +423,7 @@ impl FPU {
}
}

#[cfg(any(has_fpu, target_arch = "x86_64"))]
#[cfg(any(has_fpu, native))]
impl ops::Deref for FPU {
type Target = self::fpu::RegisterBlock;

Expand Down
10 changes: 5 additions & 5 deletions src/peripheral/scb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl SCB {
5 => VectActive::Exception(Exception::BusFault),
#[cfg(not(armv6m))]
6 => VectActive::Exception(Exception::UsageFault),
#[cfg(any(armv8m, target_arch = "x86_64"))]
#[cfg(any(armv8m, native))]
7 => VectActive::Exception(Exception::SecureFault),
11 => VectActive::Exception(Exception::SVCall),
#[cfg(not(armv6m))]
Expand Down Expand Up @@ -218,7 +218,7 @@ pub enum Exception {
UsageFault,

/// Secure fault interrupt (only on ARMv8-M)
#[cfg(any(armv8m, target_arch = "x86_64"))]
#[cfg(any(armv8m, native))]
SecureFault,

/// SV call interrupt
Expand Down Expand Up @@ -250,7 +250,7 @@ impl Exception {
Exception::BusFault => -11,
#[cfg(not(armv6m))]
Exception::UsageFault => -10,
#[cfg(any(armv8m, target_arch = "x86_64"))]
#[cfg(any(armv8m, native))]
Exception::SecureFault => -9,
Exception::SVCall => -5,
#[cfg(not(armv6m))]
Expand Down Expand Up @@ -293,7 +293,7 @@ impl VectActive {
5 => VectActive::Exception(Exception::BusFault),
#[cfg(not(armv6m))]
6 => VectActive::Exception(Exception::UsageFault),
#[cfg(any(armv8m, target_arch = "x86_64"))]
#[cfg(any(armv8m, native))]
7 => VectActive::Exception(Exception::SecureFault),
11 => VectActive::Exception(Exception::SVCall),
#[cfg(not(armv6m))]
Expand Down Expand Up @@ -934,7 +934,7 @@ pub enum SystemHandler {
UsageFault = 6,

/// Secure fault interrupt (only on ARMv8-M)
#[cfg(any(armv8m, target_arch = "x86_64"))]
#[cfg(any(armv8m, native))]
SecureFault = 7,

/// SV call interrupt
Expand Down