Skip to content
Snippets Groups Projects
Verified Commit 42c24dd7 authored by Jacob Lorentzon's avatar Jacob Lorentzon
Browse files

Successfully run more userspace.

parent 7fcf5a1a
No related branches found
No related tags found
No related merge requests found
......@@ -78,7 +78,11 @@ asmfunction!(__relibc_internal_fork_wrapper -> usize: ["
mov rdi, rsp
call __relibc_internal_fork_impl
jmp 2f
add rsp, 80
pop rbp
ret
"] <= []);
asmfunction!(__relibc_internal_fork_ret: ["
......@@ -91,8 +95,6 @@ asmfunction!(__relibc_internal_fork_ret: ["
xor rax, rax
.p2align 4
2:
add rsp, 32
pop r15
pop r14
......
......@@ -129,16 +129,17 @@ pub fn sigaction(signal: u8, new: Option<&Sigaction>, old: Option<&mut Sigaction
let _sigguard = tmp_disable_signals();
let ctl = current_sigctl();
let guard = SIGACTIONS.lock();
let mut guard = SIGACTIONS.lock();
let old_ignmask = IGNMASK.load(Ordering::Relaxed);
if let Some(old) = old {
// TODO
*old = guard[usize::from(signal)];
}
let Some(new) = new else {
return Ok(());
};
guard[usize::from(signal)] = *new;
let sig_group = usize::from(signal) / 32;
let sig_bit32 = 1 << ((signal - 1) % 32);
......
......@@ -2,7 +2,7 @@
use core::cell::UnsafeCell;
use core::ops::{Deref, DerefMut};
use core::sync::atomic::AtomicU32;
use core::sync::atomic::{AtomicU32, Ordering};
pub struct Mutex<T> {
pub lockword: AtomicU32,
......@@ -24,6 +24,9 @@ impl<T> Mutex<T> {
}
}
pub fn lock(&self) -> MutexGuard<'_, T> {
while self.lockword.compare_exchange(UNLOCKED, LOCKED, Ordering::Acquire, Ordering::Relaxed).is_err() {
core::hint::spin_loop();
}
MutexGuard { lock: self }
}
}
......@@ -44,5 +47,6 @@ impl<T> DerefMut for MutexGuard<'_, T> {
}
impl<T> Drop for MutexGuard<'_, T> {
fn drop(&mut self) {
self.lock.lockword.store(UNLOCKED, Ordering::Release);
}
}
......@@ -56,6 +56,13 @@ pub struct Tcb {
pub pthread: Pthread,
}
#[cfg(target_os = "redox")]
const _: () = {
if mem::size_of::<Tcb>() > syscall::PAGE_SIZE {
panic!("too large TCB!");
}
};
impl Tcb {
/// Create a new TCB
pub unsafe fn new(size: usize) -> Result<&'static mut Self> {
......@@ -223,7 +230,7 @@ impl Tcb {
syscall!(ARCH_PRCTL, ARCH_SET_FS, tls_end);
}
#[cfg(all(target_os = "redox"))]
#[cfg(target_os = "redox")]
unsafe fn os_arch_activate(tls_end: usize, tls_len: usize) {
redox_rt::tcb_activate(tls_end, tls_len)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment