Skip to content
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

Reduce reliance on unstable rustc features #61

Merged
merged 48 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
866557a
Fix dependency features for sel4-capdl-initializer-embed-spec
nspin Jan 7, 2024
0768b33
Remove #![feature(extract_if)]
nspin Jan 7, 2024
9aa5bf5
Remove #![feature(is_sorted)] and #![feature(iter_intersperse)]
nspin Jan 7, 2024
40f5488
Remove unused #![feature(maybe_uninit_slice)]
nspin Jan 7, 2024
8857fec
Remove unused #![feature(int_roundings)]
nspin Jan 7, 2024
26215ba
Remove #![feature(let_chains)]
nspin Jan 7, 2024
5c6a581
Remove unused #![feature(result_flattening)]
nspin Jan 7, 2024
ddf5233
Remove unused #![feature(async_fn_in_trait)]
nspin Jan 7, 2024
fa225d1
Remove unused #![feature(try_blocks)]
nspin Jan 7, 2024
b68bb82
Remove #![feature(lazy_cell)]
nspin Jan 7, 2024
782a579
Remove #![feature(error_in_core)]
nspin Jan 7, 2024
f115b25
Remove #![feature(exit_status_error)]
nspin Jan 7, 2024
994b35a
Remove #![feature(cell_update)]
nspin Jan 7, 2024
52d8e8a
Add hacking/unstable-feature-monitoring
nspin Jan 7, 2024
f2d81e9
Remove unused #![feature(const_trait_impl)] and #![feature(derive_con…
nspin Jan 7, 2024
7dd73b5
Remove #![feature(pattern)]
nspin Jan 7, 2024
4f0557b
Remove unused #![feature(const_slice_ptr_len)]
nspin Jan 7, 2024
1619fde
Remove unused #![feature(array_try_from_fn)]
nspin Jan 7, 2024
fc2b50e
Remove unused #![feature(c_size_t)]
nspin Jan 7, 2024
67e3f8e
Remove one use of #![feature(const_slice_from_raw_parts_mut)]
nspin Jan 7, 2024
d49d27b
Remove unused #![feature(const_ptr_is_null)]
nspin Jan 7, 2024
3b31806
Remove #![feature(const_pointer_is_aligned)]
nspin Jan 7, 2024
956711a
Remove unused #![feature(const_mut_refs)]
nspin Jan 7, 2024
e3aadad
Remove #![feature(concat_idents)]
nspin Jan 7, 2024
7c2b2e3
Remove unused #![feature(const_option)]
nspin Jan 7, 2024
3906314
Remove unused #![feature(slice_as_chunks)]
nspin Jan 8, 2024
4f14337
Remove unused instances of #![feature(slice_ptr_len)]
nspin Jan 8, 2024
cc9e335
Remove #![feature(atomic_from_mut)]
nspin Jan 8, 2024
e1268b5
Remove #![feature(ptr_metadata)]
nspin Jan 8, 2024
4594443
Remove unused instances of #![feature(slice_ptr_get)]
nspin Jan 8, 2024
8d0acb1
Remove #![feature(const_slice_from_raw_parts_mut)]
nspin Jan 8, 2024
d1e5e63
crates/sel4-dlmalloc: Refactor
nspin Jan 8, 2024
535652e
Remove #![feature(variant_count)]
nspin Jan 8, 2024
4f57e31
Remove #![feature(sync_unsafe_cell)]
nspin Jan 8, 2024
62a27d2
Remove #![feature(exclusive_wrapper)]
nspin Jan 8, 2024
ee74800
Remove unused #![feature(stdsimd)]
nspin Jan 8, 2024
9621742
Remove unused #![feature(alloc_error_handler)]
nspin Jan 8, 2024
0820ac7
Remove #![feature(array_methods)]
nspin Jan 8, 2024
00b0edf
Remove unused instances of #![feature(strict_provenance)]
nspin Jan 8, 2024
e99f79a
Remove #![feature(strict_provenance)] from crates/sel4
nspin Jan 8, 2024
c8ff0af
Add #![feature(strict_provenance)] to wishlist
nspin Jan 8, 2024
3b590b4
Remove #![feature(strict_provenance)]
nspin Jan 8, 2024
d3378b1
Remove #![feature(exposed_provenance)]
nspin Jan 8, 2024
2ca6dd9
Add #![feature(exposed_provenance)] to wishlist
nspin Jan 8, 2024
590d20c
Restore #![feature(stdsimd)] for kernel loader on riscv
nspin Jan 8, 2024
e77cb5d
Add list of extra used unstable features
nspin Jan 8, 2024
bb07ce1
Remove unused instances of unstable feature attributes
nspin Jan 8, 2024
20c78aa
Address clippy lints
nspin Jan 8, 2024
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 .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Files:
Cargo.lock
support/*.json
hacking/cargo-manifest-management/tool/Cargo.lock
hacking/unstable-feature-monitoring/wishlist/Cargo.lock
hacking/nix/scope/capdl-tool/capDL-tool.nix
hacking/nix/scope/capdl-tool/base-compat-0-11-2.nix
hacking/nix/scope/capdl-tool/base-compat-batteries-0-11-2.nix
Expand Down
2 changes: 0 additions & 2 deletions crates/examples/microkit/banscii/pds/artist/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

#![no_std]
#![no_main]
#![feature(const_trait_impl)]
#![feature(int_roundings)]
#![feature(never_type)]

extern crate alloc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// SPDX-License-Identifier: BSD-2-Clause
//

#![feature(int_roundings)]

use banscii_assistant_core::Draft;

fn main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#![no_std]
#![no_main]
#![feature(const_trait_impl)]
#![feature(never_type)]

extern crate alloc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
//

#![no_std]
#![feature(exposed_provenance)]
#![feature(ptr_metadata)]
#![feature(slice_ptr_get)]
#![feature(strict_provenance)]

use core::alloc::Layout;
use core::ptr::{self, NonNull};
Expand Down Expand Up @@ -43,8 +40,8 @@ pub struct HalImpl;

impl HalImpl {
pub fn init(dma_region_size: usize, dma_region_vaddr: usize, dma_region_paddr: usize) {
let dma_region_ptr = NonNull::new(ptr::from_raw_parts_mut(
ptr::from_exposed_addr_mut(dma_region_vaddr),
let dma_region_ptr = NonNull::new(ptr::slice_from_raw_parts_mut(
dma_region_vaddr as *mut _,
dma_region_size,
))
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//

#![no_std]
#![feature(pattern)]

extern crate alloc;

Expand Down Expand Up @@ -39,6 +38,7 @@ use server::Server;
const HTTP_PORT: u16 = 80;
const HTTPS_PORT: u16 = 443;

#[allow(clippy::too_many_arguments)] // TODO
pub async fn run_server<
T: BlockIO<ReadOnly, BlockSize = constant_block_sizes::BlockSize512> + Clone + 'static,
>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
// SPDX-License-Identifier: BSD-2-Clause
//

use core::str::pattern::Pattern;

pub(crate) fn content_type_from_name(name: &str) -> &'static str {
for (ext, ty) in MIME_ASSOCS {
if ext.is_suffix_of(name) {
if name.ends_with(ext) {
return ty;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use alloc::format;
use alloc::rc::Rc;
use alloc::string::{String, ToString};
use alloc::vec;
use core::str::pattern::Pattern;

use sel4_async_block_io_fat as fat;
use sel4_async_network_traits::{AsyncIO, AsyncIOExt, ClosedError};
Expand Down Expand Up @@ -202,10 +201,10 @@ impl<D: fat::BlockDevice + 'static, T: fat::TimeSource + 'static> Server<D, T> {

async fn lookup_request_path(&self, request_path: &str) -> RequestPathStatus {
let mut volume_manager = self.volume_manager.lock().await;
if !"/".is_prefix_of(request_path) {
if !request_path.starts_with('/') {
return RequestPathStatus::NotFound;
}
let has_trailing_slash = "/".is_suffix_of(request_path);
let has_trailing_slash = request_path.ends_with('/');
let mut cur = self.dir;
for seg in request_path.split('/') {
if seg.is_empty() {
Expand Down
6 changes: 0 additions & 6 deletions crates/examples/microkit/http-server/pds/server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@

#![no_std]
#![no_main]
#![feature(int_roundings)]
#![feature(never_type)]
#![feature(pattern)]
#![feature(ptr_metadata)]
#![feature(slice_ptr_get)]
#![feature(strict_provenance)]
#![feature(try_blocks)]

extern crate alloc;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
#![no_std]
#![no_main]
#![feature(core_intrinsics)]
#![feature(exclusive_wrapper)]
#![feature(never_type)]
#![feature(unwrap_infallible)]
#![allow(internal_features)]

use core::arch::global_asm;
use core::sync::Exclusive;

fn main(bootinfo: &sel4::BootInfo) -> sel4::Result<!> {
sel4::debug_println!("Hello, World!");
Expand Down Expand Up @@ -81,28 +79,36 @@ fn main(bootinfo: &sel4::BootInfo) -> sel4::Result<!> {

// minimal ad-hoc runtime

#[repr(C, align(16))]
pub struct Stack<const N: usize>([u8; N]);
mod stack {
use core::cell::UnsafeCell;

impl<const N: usize> Stack<N> {
pub const fn new() -> Self {
Self([0; N])
}
#[repr(C, align(16))]
pub struct Stack<const N: usize>(UnsafeCell<[u8; N]>);

unsafe impl<const N: usize> Sync for Stack<N> {}

pub const fn top(&self) -> StackTop {
StackTop(Exclusive::new(self.0.as_ptr_range().end.cast_mut()))
impl<const N: usize> Stack<N> {
pub const fn new() -> Self {
Self(UnsafeCell::new([0; N]))
}

pub const fn top(&self) -> StackTop {
StackTop(self.0.get().cast::<u8>().wrapping_add(N))
}
}
}

#[repr(transparent)]
pub struct StackTop(#[allow(dead_code)] Exclusive<*mut u8>);
#[repr(transparent)]
pub struct StackTop(#[allow(dead_code)] *mut u8);

const STACK_SIZE: usize = 0x4000;
unsafe impl Sync for StackTop {}

static mut STACK: Stack<STACK_SIZE> = Stack::new();
const STACK_SIZE: usize = 0x4000;

#[no_mangle]
static __stack_top: StackTop = unsafe { STACK.top() };
static STACK: Stack<STACK_SIZE> = Stack::new();

#[no_mangle]
static __stack_top: StackTop = STACK.top();
}

cfg_if::cfg_if! {
if #[cfg(target_arch = "aarch64")] {
Expand Down
1 change: 0 additions & 1 deletion crates/private/support/sel4-simple-task/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//

#![no_std]
#![feature(int_roundings)]

#[cfg(feature = "postcard")]
pub mod easy;
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
//

#![no_std]
#![feature(int_roundings)]
#![feature(result_flattening)]

#[cfg(feature = "alloc")]
extern crate alloc;
Expand Down
17 changes: 4 additions & 13 deletions crates/private/support/sel4-simple-task/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,8 @@
//

#![no_std]
#![feature(alloc_error_handler)]
#![feature(c_size_t)]
#![feature(const_trait_impl)]
#![feature(core_intrinsics)]
#![feature(exposed_provenance)]
#![feature(lang_items)]
#![feature(linkage)]
#![feature(never_type)]
#![feature(strict_provenance)]
#![feature(thread_local)]
#![feature(unwrap_infallible)]
#![allow(internal_features)]

#[cfg(feature = "alloc")]
Expand Down Expand Up @@ -84,9 +75,9 @@ pub unsafe extern "C" fn cont_fn(cont_arg: *mut c_void) -> ! {

THREAD_INDEX.set(thread_index).unwrap();

sel4::set_ipc_buffer(sel4::IPCBuffer::from_ptr(ptr::from_exposed_addr_mut(
thread_config.ipc_buffer_addr().try_into().unwrap(),
)));
sel4::set_ipc_buffer(sel4::IPCBuffer::from_ptr(
usize::try_from(thread_config.ipc_buffer_addr()).unwrap() as *mut _,
));

if thread_index == 0 {
CONFIG.set(config.clone()).unwrap();
Expand Down Expand Up @@ -146,7 +137,7 @@ fn panic_hook(info: &ExternalPanicInfo<'_>) {
fn get_static_heap_bounds() -> *mut [u8] {
let addrs = CONFIG.get().unwrap().static_heap().unwrap();
ptr::slice_from_raw_parts_mut(
ptr::from_exposed_addr_mut(addrs.start.try_into().unwrap()),
usize::try_from(addrs.start).unwrap() as *mut _,
(addrs.end - addrs.start).try_into().unwrap(),
)
}
Expand Down
7 changes: 3 additions & 4 deletions crates/private/tests/root-task/loader/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

#![no_std]
#![no_main]
#![feature(is_sorted)]
#![feature(iter_intersperse)]
#![feature(thread_local)]
#![allow(clippy::single_match)]

Expand Down Expand Up @@ -48,8 +46,9 @@ fn main(bootinfo: &sel4::BootInfo) -> ! {
match extra.id {
sel4::BootInfoExtraId::Fdt => {
let dt = fdt::Fdt::new(extra.content()).unwrap();
for s in dt.strings().intersperse(" ") {
debug_print!("{}", s);
debug_print!("device tree strings: ");
for s in dt.strings() {
debug_print!(" {}", s);
}
debug_println!("");
}
Expand Down
3 changes: 0 additions & 3 deletions crates/sel4-async/block-io/cpiofs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
//

#![no_std]
#![feature(async_fn_in_trait)]
#![feature(int_roundings)]
#![feature(slice_as_chunks)]

extern crate alloc;

Expand Down
3 changes: 0 additions & 3 deletions crates/sel4-async/block-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

#![no_std]
#![feature(associated_type_bounds)]
#![feature(const_option)]
#![feature(int_roundings)]
#![feature(never_type)]
#![feature(slice_as_chunks)]

#[cfg(feature = "alloc")]
extern crate alloc;
Expand Down
2 changes: 0 additions & 2 deletions crates/sel4-async/single-threaded-executor/src/enter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ impl fmt::Display for EnterError {
}
}

impl core::error::Error for EnterError {}

/// Marks the current thread as being within the dynamic extent of an
/// executor.
///
Expand Down
17 changes: 8 additions & 9 deletions crates/sel4-async/single-threaded-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
//

#![no_std]
#![feature(error_in_core)]
#![feature(lazy_cell)]
#![feature(thread_local)]

extern crate alloc;

use alloc::rc::{Rc, Weak};
use alloc::sync::Arc;
use alloc::vec::Vec;
use core::cell::{LazyCell, RefCell};
use core::cell::{OnceCell, RefCell};
use core::pin::Pin;
use core::sync::atomic::{AtomicBool, Ordering};

Expand Down Expand Up @@ -67,28 +65,29 @@ impl ThreadNotify {
}
}

#[thread_local]
static CURRENT_THREAD_NOTIFY: LazyCell<Arc<ThreadNotify>> =
LazyCell::new(|| Arc::new(ThreadNotify::new()));

impl ArcWake for ThreadNotify {
fn wake_by_ref(arc_self: &Arc<Self>) {
ThreadNotify::wake(arc_self);
}
}

fn run_executor_until_stalled<T, F: FnMut(&mut Context<'_>) -> Poll<T>>(mut f: F) -> Poll<T> {
#[thread_local]
static CURRENT_THREAD_NOTIFY: OnceCell<Arc<ThreadNotify>> = OnceCell::new();

let _enter =
enter::enter().expect("cannot execute `LocalPool` executor from within another executor");

let waker = waker_ref(&CURRENT_THREAD_NOTIFY);
let current_thread_notify = CURRENT_THREAD_NOTIFY.get_or_init(|| Arc::new(ThreadNotify::new()));

let waker = waker_ref(current_thread_notify);
let mut cx = Context::from_waker(&waker);
loop {
if let Poll::Ready(t) = f(&mut cx) {
return Poll::Ready(t);
}

if !CURRENT_THREAD_NOTIFY.take_wakeup() {
if !current_thread_notify.take_wakeup() {
return Poll::Pending;
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/sel4-bounce-buffer-allocator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#![feature(allocator_api)]
#![feature(btree_cursors)]
#![feature(btreemap_alloc)]
#![feature(int_roundings)]
#![feature(pointer_is_aligned)]

extern crate alloc;
Expand Down
1 change: 0 additions & 1 deletion crates/sel4-capdl-initializer/add-spec/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//

#![feature(associated_type_bounds)]
#![feature(int_roundings)]
#![feature(never_type)]
#![feature(unwrap_infallible)]

Expand Down
8 changes: 5 additions & 3 deletions crates/sel4-capdl-initializer/core/src/hold_slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
// SPDX-License-Identifier: BSD-2-Clause
//

use core::array;

use sel4::{AbsoluteCPtr, InitCSpaceSlot};

use crate::{CSlotAllocator, CapDLInitializerError};
Expand All @@ -25,7 +23,11 @@ impl<T> HoldSlots<T> {
relative_cptr_of: T,
) -> Result<Self, CapDLInitializerError> {
Ok(Self {
slots: array::try_from_fn(|_| cslot_allocator.alloc())?,
slots: {
// NOTE(rustc_wishlist) array_try_from_fn
let mut f = || cslot_allocator.alloc();
[f()?, f()?]
},
slots_occupied: [false; NUM_SLOTS],
which_slot: 0,
relative_cptr_of,
Expand Down
Loading