Skip to content

Commit

Permalink
Merge #66
Browse files Browse the repository at this point in the history
66: Move allocator module to crate root r=mkroening a=mkroening



Co-authored-by: Martin Kröning <[email protected]>
  • Loading branch information
bors[bot] and mkroening authored May 12, 2022
2 parents 94d4d1d + 5ca0888 commit 9868268
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/mm/allocator.rs → src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
use core::alloc::GlobalAlloc;
use core::alloc::Layout;

#[global_allocator]
static ALLOCATOR: Allocator = Allocator;

/// Size of the preallocated space for the Bootstrap Allocator.
const BOOTSTRAP_HEAP_SIZE: usize = 2 * 1024 * 1024;

Expand Down
5 changes: 1 addition & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ extern crate bitflags;
#[macro_use]
pub mod macros;

pub mod allocator;
pub mod arch;
pub mod console;
pub mod kernel;
pub mod mm;
mod runtime_glue;

use core::ptr;

#[global_allocator]
static ALLOCATOR: mm::allocator::Allocator = mm::allocator::Allocator;

// FUNCTIONS
pub unsafe fn sections_init() {
extern "C" {
Expand Down
10 changes: 0 additions & 10 deletions src/mm/mod.rs

This file was deleted.

7 changes: 7 additions & 0 deletions src/runtime_glue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ fn panic(info: &PanicInfo<'_>) -> ! {

loop {}
}

#[cfg(not(test))]
#[alloc_error_handler]
fn rust_oom(layout: core::alloc::Layout) -> ! {
let size = layout.size();
panic!("memory allocation of {size} bytes failed")
}

0 comments on commit 9868268

Please sign in to comment.