Skip to content
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

feat: introduce compile error if compiling with atomic on #8

Merged
merged 1 commit into from
Nov 3, 2024
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: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Prepare Rust Target
run: rustup target add riscv32imac-unknown-none-elf
run: rustup target add riscv32imc-unknown-none-elf
- name: Build
run: cargo build --all --target riscv32imac-unknown-none-elf
run: cargo build --all --target riscv32imc-unknown-none-elf
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ documentation = "https://docs.rs/qingke"
homepage = "https://github.com/ch32-rs/qingke"
categories = ["embedded", "no-std", "hardware-support"]
license = "MIT/Apache-2.0"
version = "0.4.0" # for rt and macros
version = "0.5.0" # for rt and macros
edition = "2021"

[package]
Expand Down Expand Up @@ -37,6 +37,7 @@ defmt = { version = "0.3.8", optional = true }
critical-section-impl = ["dep:critical-section"]
defmt = ["dep:defmt"]
v3 = []
unsafe-trust-wch-atomics = []

[package.metadata.docs.rs]
targets = ["riscv32imac-unknown-none-elf"]
4 changes: 2 additions & 2 deletions qingke-rt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ u-mode = []
highcode = []

[dependencies]
qingke-rt-macros = { path = "./macros", version = "0.4" }
qingke = { path = "../", version = "0.4", features = ["critical-section-impl"] }
qingke-rt-macros = { path = "./macros" }
qingke = { path = "../", features = ["critical-section-impl"] }

[package.metadata.docs.rs]
targets = ["riscv32imac-unknown-none-elf"]
17 changes: 17 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,22 @@ pub mod register;
// re-export
pub use riscv;

#[cfg(all(
any(
target_has_atomic = "8",
// target_has_atomic = "16",
// target_has_atomic = "32",
// target_has_atomic = "64",
// target_has_atomic = "128",
// target_has_atomic = "ptr"
),
not(feature = "unsafe-trust-wch-atomics")
))]
compile_error!(
"As tested on QingKe V4, most likely the atomics are broken,
please validate the atomic instruction on the hardware using
something like litmus test suite before trusting them."
);

#[cfg(feature = "critical-section-impl")]
mod critical_section_impl;