Skip to content

Commit 26f28c3

Browse files
authored
Merge pull request #762 from nbdd0121/rust
export `build_error` symbol if RUST_BUILD_ASSERT_DENY is not set
2 parents 9a87c30 + 7f7d4f9 commit 26f28c3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

rust/build_error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
/// Panics if executed in const context, or triggers a build error if not.
1818
#[inline(never)]
1919
#[cold]
20-
#[no_mangle]
20+
#[export_name = "rust_build_error"]
2121
#[track_caller]
2222
pub const fn build_error(msg: &'static str) -> ! {
2323
panic!("{}", msg);
2424
}
2525

2626
#[cfg(CONFIG_RUST_BUILD_ASSERT_WARN)]
27-
#[link_section = ".gnu.warning.build_error"]
27+
#[link_section = ".gnu.warning.rust_build_error"]
2828
#[used]
2929
static BUILD_ERROR_WARNING: [u8; 45] = *b"call to build_error present after compilation";

rust/kernel/io_mem.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ macro_rules! define_read {
6868
///
6969
/// If the offset is not known at compile time, the build will fail.
7070
$(#[$attr])*
71+
#[inline]
7172
pub fn $name(&self, offset: usize) -> $type_name {
7273
Self::check_offset::<$type_name>(offset);
7374
let ptr = self.ptr.wrapping_add(offset);
@@ -100,6 +101,7 @@ macro_rules! define_write {
100101
///
101102
/// If the offset is not known at compile time, the build will fail.
102103
$(#[$attr])*
104+
#[inline]
103105
pub fn $name(&self, value: $type_name, offset: usize) {
104106
Self::check_offset::<$type_name>(offset);
105107
let ptr = self.ptr.wrapping_add(offset);
@@ -164,6 +166,7 @@ impl<const SIZE: usize> IoMem<SIZE> {
164166
}
165167
}
166168

169+
#[inline]
167170
const fn offset_ok<T>(offset: usize) -> bool {
168171
let type_size = core::mem::size_of::<T>();
169172
if let Some(end) = offset.checked_add(type_size) {
@@ -183,6 +186,7 @@ impl<const SIZE: usize> IoMem<SIZE> {
183186
}
184187
}
185188

189+
#[inline]
186190
const fn check_offset<T>(offset: usize) {
187191
crate::build_assert!(Self::offset_ok::<T>(offset), "IoMem offset overflow");
188192
}

0 commit comments

Comments
 (0)