Skip to content

Commit

Permalink
feat(threading): remove support for riot_main
Browse files Browse the repository at this point in the history
  • Loading branch information
ROMemories authored and kaspar030 committed Feb 13, 2024
1 parent 199136c commit 4372796
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 50 deletions.
6 changes: 4 additions & 2 deletions examples/benchmark/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#![no_main]
#![no_std]
#![feature(type_alias_impl_trait)]
#![feature(used_with_arg)]

use riot_rs::rt::debug::println;

#[no_mangle]
fn riot_main() {
#[riot_rs::thread]
fn main() {
match riot_rs::rt::benchmark(10000, || {
//
}) {
Expand Down
11 changes: 6 additions & 5 deletions examples/core-sizes/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#![no_main]
#![no_std]
#![feature(type_alias_impl_trait)]
#![feature(used_with_arg)]

use riot_rs as _;
use riot_rs::rt::debug::{exit, println, EXIT_SUCCESS};

#[no_mangle]
fn riot_main() {
#[riot_rs::thread]
fn main() {
println!(
"riot_rs::thread::lock::Lock: {}",
core::mem::size_of::<riot_rs::thread::lock::Lock>()
core::mem::size_of::<riot_rs::thread::lock::Lock>(),
);
println!(
"riot_rs::thread::Thread: {}",
core::mem::size_of::<riot_rs::thread::Thread>()
core::mem::size_of::<riot_rs::thread::Thread>(),
);

exit(EXIT_SUCCESS);
Expand Down
13 changes: 6 additions & 7 deletions examples/embassy/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#![no_main]
#![no_std]
#![feature(type_alias_impl_trait)]

use riot_rs as _;
#![feature(used_with_arg)]

use riot_rs::rt::debug::exit;
use riot_rs::rt::debug::println;
Expand All @@ -28,13 +27,13 @@ async fn async_task() {
}
}

#[no_mangle]
fn riot_main() {
#[riot_rs::thread]
fn main() {
use embassy_time::Instant;

println!(
"Hello from riot_main()! Running on a {} board.",
riot_rs::buildinfo::BOARD
"Hello from main()! Running on a {} board.",
riot_rs::buildinfo::BOARD,
);

let spawner = EXECUTOR.spawner();
Expand All @@ -45,7 +44,7 @@ fn riot_main() {
println!(
"now={}ms threadtest() val={}",
Instant::now().as_millis(),
val
val,
);
}

Expand Down
1 change: 0 additions & 1 deletion examples/hello-world/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ publish = false
[dependencies]
riot-rs = { path = "../../src/riot-rs", features = [ "threading" ] }
riot-rs-boards = { path = "../../src/riot-rs-boards" }
riot-wrappers = { workspace = true, optional = true }
21 changes: 8 additions & 13 deletions examples/hello-world/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
#![no_main]
#![no_std]
#![feature(type_alias_impl_trait)]
#![feature(used_with_arg)]

use riot_rs as _;
use riot_rs::rt::debug::{exit, println};

#[cfg(not(feature = "riot-wrappers"))]
use riot_rs::rt::debug::println;

#[cfg(feature = "riot-wrappers")]
use riot_wrappers::println;

use riot_rs::rt::debug::exit;

#[no_mangle]
fn riot_main() {
#[riot_rs::thread]
fn main() {
println!(
"Hello from riot_main()! Running on a {} board.",
riot_rs::buildinfo::BOARD
"Hello from main()! Running on a {} board.",
riot_rs::buildinfo::BOARD,
);

exit(Ok(()));
}
2 changes: 1 addition & 1 deletion examples/minimal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ edition = "2021"
publish = false

[dependencies]
riot-rs = { path = "../../src/riot-rs" }
riot-rs = { path = "../../src/riot-rs", features = ["threading"] }
riot-rs-boards = { path = "../../src/riot-rs-boards" }
8 changes: 4 additions & 4 deletions examples/minimal/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![no_main]
#![no_std]
#![feature(type_alias_impl_trait)]
#![feature(used_with_arg)]

use riot_rs as _;

#[no_mangle]
fn riot_main() {}
#[riot_rs::thread]
fn main() {}
18 changes: 1 addition & 17 deletions src/riot-rs-rt/src/threading.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
use riot_rs_threads::{start_threading, thread_create, THREAD_FNS};

const MAIN_STACK_SIZE: usize = 2048;

extern "Rust" {
fn riot_main();
}

fn main_trampoline(_arg: usize) {
// SAFETY: FFI call to a Rust function
unsafe {
riot_main();
}
}
use riot_rs_threads::{start_threading, THREAD_FNS};

/// # Safety
///
Expand All @@ -21,9 +8,6 @@ pub unsafe fn start() -> ! {
thread_fn();
}

let mut main_stack: [u8; MAIN_STACK_SIZE] = [0; MAIN_STACK_SIZE];
thread_create(main_trampoline, 0, &mut main_stack, 0);

// SAFETY: this function must only be called once, enforced by caller
unsafe {
start_threading();
Expand Down

0 comments on commit 4372796

Please sign in to comment.