Skip to content

Commit bcf6db4

Browse files
committed
[Kernel - Rust] Only set global allocator / panic handler when targeting the axle kernel build
1 parent 6a1a079 commit bcf6db4

File tree

1 file changed

+4
-1
lines changed
  • rust_kernel_libs/ffi_bindings/src

1 file changed

+4
-1
lines changed

rust_kernel_libs/ffi_bindings/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![no_std]
1+
#![cfg_attr(target_os = "axle_kernel", no_std)]
22
#![feature(format_args_nl)]
33
#![feature(core_intrinsics)]
44
#![feature(panic_info_message)]
@@ -95,6 +95,7 @@ macro_rules! internal_println {
9595
})
9696
}
9797

98+
#[cfg(target_os = "axle_kernel")]
9899
#[panic_handler]
99100
pub fn panic(panic_info: &PanicInfo<'_>) -> ! {
100101
let msg = match panic_info.message() {
@@ -125,6 +126,7 @@ pub fn panic(panic_info: &PanicInfo<'_>) -> ! {
125126

126127
pub struct Dummy;
127128

129+
#[cfg(target_os = "axle_kernel")]
128130
unsafe impl GlobalAlloc for Dummy {
129131
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
130132
kmalloc(layout.size()) as *mut u8
@@ -134,6 +136,7 @@ unsafe impl GlobalAlloc for Dummy {
134136
}
135137
}
136138

139+
#[cfg(target_os = "axle_kernel")]
137140
#[global_allocator]
138141
pub static ALLOCATOR: Dummy = Dummy;
139142

0 commit comments

Comments
 (0)