Skip to content

A few improvements #184

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 4 commits into from
Apr 12, 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
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -15557,6 +15557,7 @@ W: https://github.com/Rust-for-Linux/linux
B: https://github.com/Rust-for-Linux/linux/issues
T: git https://github.com/Rust-for-Linux/linux.git rust-next
F: rust/
F: samples/rust/
F: Documentation/rust/
K: \b(?i:rust)\b

Expand Down
15 changes: 10 additions & 5 deletions rust/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# SPDX-License-Identifier: GPL-2.0

obj-$(CONFIG_RUST) += helpers.o exports.o
obj-$(CONFIG_RUST) += core.o compiler_builtins.o alloc.o kernel.o
extra-$(CONFIG_RUST) += bindings_generated.rs libmodule.so
extra-$(CONFIG_RUST) += exports_core_generated.h exports_alloc_generated.h
extra-$(CONFIG_RUST) += exports_kernel_generated.h
obj-$(CONFIG_RUST) += core.o compiler_builtins.o helpers.o
extra-$(CONFIG_RUST) += exports_core_generated.h

extra-$(CONFIG_RUST) += libmodule.so

extra-$(CONFIG_RUST) += bindings_generated.rs
obj-$(CONFIG_RUST) += alloc.o kernel.o
extra-$(CONFIG_RUST) += exports_alloc_generated.h exports_kernel_generated.h

obj-$(CONFIG_RUST) += exports.o

RUSTDOC = rustdoc

Expand Down
11 changes: 11 additions & 0 deletions rust/compiler_builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,14 @@ define_panicking_intrinsics!("`u128` should not be used", {
__udivti3,
__umodti3,
});

extern "C" {
fn rust_helper_BUG() -> !;
}

#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe {
rust_helper_BUG();
}
}
2 changes: 1 addition & 1 deletion rust/kernel/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use core::fmt;

/// A pre-allocated buffer that implements [`core::fmt::Write`].
///
/// Consequtive writes will append to what has already been written.
/// Consecutive writes will append to what has already been written.
/// Writes that don't fit in the buffer will fail.
pub struct Buffer<'a> {
slice: &'a mut [u8],
Expand Down
13 changes: 0 additions & 13 deletions rust/kernel/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#[cfg(not(CONFIG_RUST))]
compile_error!("Missing kernel configuration for conditional compilation");

use core::panic::PanicInfo;

mod allocator;

#[doc(hidden)]
Expand Down Expand Up @@ -130,17 +128,6 @@ impl<'a> Drop for KParamGuard<'a> {
}
}

extern "C" {
fn rust_helper_BUG() -> !;
}

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
unsafe {
rust_helper_BUG();
}
}

/// Calculates the offset of a field from the beginning of the struct it belongs to.
///
/// # Example
Expand Down