Skip to content
This repository was archived by the owner on Jan 1, 2024. It is now read-only.

Commit d1a1ac7

Browse files
committed
Remove doors_alloc
With the current Rust nightly (2023-06-01 as of this writing), using `-Zbuild-std` to recompile the `core` and `alloc` crates while enabling the `no_global_oom_handling` cfg now works properly. Therefore there is no further need for the `doors_alloc` hack, which involved manually copying the source for `alloc` and adding it as a Cargo dependency. It is still not clear what change on the Rust/Cargo end fixed the bug that previously blocked using `-Zbuild-std` to set the cfg (at the time, trying to enable the cfg resulted in large numbers of mysterious "duplicate lang item" errors). Maybe rust-lang/rust#110649 is related.
1 parent abe1522 commit d1a1ac7

File tree

12 files changed

+14
-19
lines changed

12 files changed

+14
-19
lines changed

doors_alloc

Submodule doors_alloc deleted from 32e0d10

kernel/.cargo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[build]
22
target = "x86_64-unknown-none"
33
rustflags = "-C relocation-model=static -C link-arg=-Tlink.ld --cfg no_global_oom_handling"
4+
5+
[unstable]
6+
build-std = ["core", "alloc"]

kernel/Cargo.lock

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kernel/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,4 @@ rustflags = ["--cfg", "doors_test"]
2727
lock_api = "0.4.9"
2828
x86_64 = "0.14.10"
2929
linked_list_allocator = { version = "0.10.5", default-features = false }
30-
doors_alloc = { path = "../doors_alloc" }
3130
paste = "1.0.12"

kernel/src/errno.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ impl From<core::alloc::AllocError> for Errno {
178178
}
179179
}
180180

181-
impl From<doors_alloc::collections::TryReserveError> for Errno {
182-
fn from(_value: doors_alloc::collections::TryReserveError) -> Self {
181+
impl From<alloc::collections::TryReserveError> for Errno {
182+
fn from(_value: alloc::collections::TryReserveError) -> Self {
183183
Errno::ENOMEM
184184
}
185185
}

kernel/src/fs/filesystem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Defines the basic interface provided by filesystem implementations.
22
3-
use doors_alloc::sync::{Arc, Weak};
3+
use alloc::sync::Weak;
44

55
use crate::errno::Errno;
66
use crate::sync::Spinlock;

kernel/src/fs/initrd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl FsImpl for Initrd {
144144
mod tests {
145145
use crate::errno::Errno;
146146
use crate::fs::filesystem;
147-
use doors_alloc::sync::Arc;
147+
use crate::util::alloc::*;
148148
fn check_file_contents(f: filesystem::FsTreePtr, s: &str) {
149149
let mut buffer: [u8; 1024] = [0; 1024];
150150
f.read_exact(0, &mut buffer[..s.len()]).unwrap();

kernel/src/hw/abstraction/timer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ pub static TIMER: Timer<PIT> = Timer {
182182

183183
declare_test!(timer_basic, {
184184
use core::sync::atomic::*;
185-
use doors_alloc::sync::Arc;
186185
let counter = Arc::try_new(AtomicI32::new(0)).unwrap();
187186
for i in (0..10).rev() {
188187
let copy = Arc::clone(&counter);

kernel/src/loader.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! The program loader.
22
3-
use doors_alloc::sync::Arc;
43
use x86_64::structures::paging::{Page, PageTableFlags, Size4KiB};
54
use x86_64::VirtAddr;
65

kernel/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
//!
1212
//! The Doors kernel.
1313
14+
extern crate alloc;
15+
1416
use core::panic::PanicInfo;
1517
use core::sync::atomic::{AtomicI32, Ordering};
1618

kernel/src/thread.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ use crate::mm::virt::PageDirectory;
88
use crate::sync::{InterruptSafeSpinlock, Spinlock};
99
use crate::util::alloc::*;
1010
use crate::util::singleton::InterruptSafeSingleton;
11+
use alloc::alloc::{alloc, alloc_zeroed, Layout};
1112
use core::arch::global_asm;
1213
use core::cell::UnsafeCell;
1314
use core::ptr::NonNull;
1415
use core::sync::atomic::*;
1516
use core::{mem, ptr};
16-
use doors_alloc::alloc::{alloc, alloc_zeroed, Layout};
17-
use doors_alloc::sync::Arc;
1817
use x86_64::instructions::interrupts::are_enabled as interrupts_are_enabled;
1918
use x86_64::VirtAddr;
2019

kernel/src/util/alloc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
//! This will automatically bring [`String`], [`Vec`], [`Box`], and [`Arc`] into scope as well.
99
1010
use crate::errno::Errno;
11-
pub use doors_alloc::boxed::Box;
12-
pub use doors_alloc::string::String;
13-
pub use doors_alloc::sync::Arc;
14-
pub use doors_alloc::vec::Vec;
11+
pub use alloc::boxed::Box;
12+
pub use alloc::string::String;
13+
pub use alloc::sync::Arc;
14+
pub use alloc::vec::Vec;
1515

1616
/// Represents an error that occurred with the [`try_push`](VecExt::try_push) method.
1717
#[derive(Clone, Copy, Debug, PartialEq, Eq)]

0 commit comments

Comments
 (0)