Skip to content

Commit 66dba6a

Browse files
committed
remove likely and fix build script
1 parent 518bddd commit 66dba6a

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

flc-asm/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ edition = "2021"
77
crate-type = ["staticlib"]
88

99
[dependencies]
10-
likely_stable = "0.1.3"
1110
max78000 = { git = "https://github.com/slugsecurity/max78000" }

flc-asm/src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
use core::{arch::asm, panic::PanicInfo, ptr::read_volatile};
2323

24-
use likely_stable::likely;
2524
use max78000::{FLC, GCR, ICC0};
2625

2726
/// A macro for ensuring that code never exits, even in cases of fault-injection attacks.
@@ -132,7 +131,7 @@ impl FlashController<'_, '_> {
132131
/// - The FLC must be in its ready state after [`Self::wait_until_ready`]
133132
#[inline(always)]
134133
unsafe fn set_clock_divisor(&self, sys_clk_freq: u32) {
135-
if likely(sys_clk_freq % 1_000_000 != 0) {
134+
if sys_clk_freq % 1_000_000 != 0 {
136135
panic()
137136
}
138137

@@ -275,14 +274,14 @@ impl FlashController<'_, '_> {
275274
/// - `address` must be aligned to 128 bits
276275
#[inline(always)]
277276
unsafe fn write128(&self, address: u32, data: &[u32; 4], sys_clk_freq: u32) {
278-
if likely(!check_address_bounds(address..address + 16)) {
277+
if !check_address_bounds(address..address + 16) {
279278
panic();
280279
}
281280
#[allow(
282281
clippy::cast_possible_truncation,
283282
reason = "the target pointer width is 32, so this will not truncate"
284283
)]
285-
if likely(address % size_of::<[u32; 4]>() as u32 != 0) {
284+
if address % size_of::<[u32; 4]>() as u32 != 0 {
286285
panic();
287286
}
288287

@@ -324,7 +323,7 @@ impl FlashController<'_, '_> {
324323
clippy::range_plus_one,
325324
reason = "the caller takes a Range struct, not an `impl RangeBounds`"
326325
)]
327-
if likely(!check_address_bounds(address..address + 1)) {
326+
if !check_address_bounds(address..address + 1) {
328327
panic()
329328
}
330329
// SAFETY: the caller must guarantee that `sys_clk_freq` is valid per this function's
@@ -353,10 +352,10 @@ impl FlashController<'_, '_> {
353352
#[export_name = "flc_read32_primitive"]
354353
#[link_section = ".analogsucks"]
355354
pub unsafe extern "C" fn read32(address: *const u32) -> u32 {
356-
if likely(!address.is_aligned()) {
355+
if !address.is_aligned() {
357356
panic();
358357
}
359-
if likely(!check_address_bounds(address as u32..(address as u32 + 4))) {
358+
if !check_address_bounds(address as u32..(address as u32 + 4)) {
360359
panic();
361360
}
362361
// SAFETY: the caller must guarantee that `address` is aligned and is within

hal/build.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use std::{env, fs::File, io::Write, path::PathBuf};
1+
#[cfg(feature = "flc-ram")]
2+
fn compile_flc_asm() {
3+
use std::{env, fs::File, io::Write, path::PathBuf};
24

3-
fn main() {
45
let out = PathBuf::from(env::var_os("OUT_DIR").unwrap());
5-
66
let flc_asm_path = out.join("flc_asm.s");
77
File::create(&flc_asm_path)
88
.unwrap()
@@ -11,6 +11,12 @@ fn main() {
1111

1212
cc::Build::new().file(&flc_asm_path).compile("flc_asm");
1313

14-
println!("cargo:rerun-if-changed=build.rs");
1514
println!("cargo:rerun-if-changed=flc_asm.s");
1615
}
16+
17+
fn main() {
18+
#[cfg(feature = "flc-ram")]
19+
compile_flc_asm();
20+
21+
println!("cargo:rerun-if-changed=build.rs");
22+
}

0 commit comments

Comments
 (0)