Skip to content

Commit

Permalink
Merge pull request #918 from mkroening/bump-hermit-sync
Browse files Browse the repository at this point in the history
chore: upgrade hermit-sync to 0.1.5
  • Loading branch information
mkroening authored Sep 18, 2023
2 parents fe8058d + 80e8482 commit 2a01a7b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 56 deletions.
57 changes: 9 additions & 48 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions src/syscalls/lwip.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use hermit_sync::{InterruptTicketMutexGuard, SpinMutex};
use lock_api::MutexGuard;

use crate::arch::core_local::core_scheduler;
use crate::{arch, console};

/// Enables lwIP's printf to print a whole string without being interrupted by
/// a message from the kernel.
static CONSOLE_GUARD: SpinMutex<Option<InterruptTicketMutexGuard<'_, console::Console>>> =
SpinMutex::new(None);

extern "C" fn __sys_lwip_get_errno() -> i32 {
core_scheduler().get_lwip_errno()
Expand All @@ -27,9 +26,9 @@ pub extern "C" fn sys_lwip_set_errno(errno: i32) {
}

extern "C" fn __sys_acquire_putchar_lock() {
let mut console_guard = CONSOLE_GUARD.lock();
assert!(console_guard.is_none());
*console_guard = Some(console::CONSOLE.lock());
// FIXME: use core-local storage instead
// better yet: remove and replace all of this
MutexGuard::leak(console::CONSOLE.lock());
}

#[no_mangle]
Expand All @@ -47,9 +46,9 @@ pub extern "C" fn sys_putchar(character: u8) {
}

extern "C" fn __sys_release_putchar_lock() {
let mut console_guard = CONSOLE_GUARD.lock();
assert!(console_guard.is_some());
drop(console_guard.take());
unsafe {
console::CONSOLE.force_unlock();
}
}

#[no_mangle]
Expand Down

0 comments on commit 2a01a7b

Please sign in to comment.