misc(pthread): remove the need for tid_mutex
Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
use core::{arch::asm, num::NonZeroU64, ptr};
|
||||
|
||||
use super::{ERRNO, Pal, types::*};
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
use crate::ld_so::tcb::OsSpecific;
|
||||
use crate::{
|
||||
c_str::CStr,
|
||||
header::{
|
||||
@@ -623,7 +625,10 @@ impl Pal for Sys {
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
unsafe fn rlct_clone(stack: *mut usize) -> Result<crate::pthread::OsTid> {
|
||||
unsafe fn rlct_clone(
|
||||
stack: *mut usize,
|
||||
_os_specific: &mut OsSpecific,
|
||||
) -> Result<crate::pthread::OsTid> {
|
||||
let flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD;
|
||||
let pid;
|
||||
asm!("
|
||||
@@ -678,7 +683,10 @@ impl Pal for Sys {
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
unsafe fn rlct_clone(stack: *mut usize) -> Result<crate::pthread::OsTid> {
|
||||
unsafe fn rlct_clone(
|
||||
stack: *mut usize,
|
||||
_os_specific: &mut OsSpecific,
|
||||
) -> Result<crate::pthread::OsTid> {
|
||||
todo!("rlct_clone not implemented for aarch64 yet")
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ use crate::{
|
||||
sys_utsname::utsname,
|
||||
time::{itimerspec, timespec},
|
||||
},
|
||||
ld_so::tcb::OsSpecific,
|
||||
out::Out,
|
||||
pthread,
|
||||
};
|
||||
@@ -221,7 +222,10 @@ pub trait Pal {
|
||||
|
||||
fn posix_getdents(fildes: c_int, buf: &mut [u8]) -> Result<usize>;
|
||||
|
||||
unsafe fn rlct_clone(stack: *mut usize) -> Result<pthread::OsTid, Errno>;
|
||||
unsafe fn rlct_clone(
|
||||
stack: *mut usize,
|
||||
os_specific: &mut OsSpecific,
|
||||
) -> Result<pthread::OsTid, Errno>;
|
||||
unsafe fn rlct_kill(os_tid: pthread::OsTid, signal: usize) -> Result<()>;
|
||||
|
||||
fn current_os_tid() -> pthread::OsTid;
|
||||
|
||||
@@ -48,6 +48,7 @@ use crate::{
|
||||
unistd::{F_OK, R_OK, SEEK_CUR, SEEK_SET, W_OK, X_OK},
|
||||
},
|
||||
io::{self, BufReader, prelude::*},
|
||||
ld_so::tcb::{OsSpecific, Tcb},
|
||||
out::Out,
|
||||
platform::sys::{
|
||||
libredox::RawResult,
|
||||
@@ -926,15 +927,17 @@ impl Pal for Sys {
|
||||
Ok(bytes_read)
|
||||
}
|
||||
|
||||
unsafe fn rlct_clone(stack: *mut usize) -> Result<crate::pthread::OsTid> {
|
||||
unsafe fn rlct_clone(
|
||||
stack: *mut usize,
|
||||
os_specific: &mut OsSpecific,
|
||||
) -> Result<crate::pthread::OsTid> {
|
||||
let _guard = CLONE_LOCK.read();
|
||||
let res = clone::rlct_clone_impl(stack);
|
||||
let res = clone::rlct_clone_impl(stack, os_specific);
|
||||
|
||||
res.map(|mut fd| crate::pthread::OsTid {
|
||||
thread_fd: fd.take(),
|
||||
})
|
||||
.map_err(|error| Errno(error.errno))
|
||||
res.map(|thread_fd| crate::pthread::OsTid { thread_fd })
|
||||
.map_err(|error| Errno(error.errno))
|
||||
}
|
||||
|
||||
unsafe fn rlct_kill(os_tid: crate::pthread::OsTid, signal: usize) -> Result<()> {
|
||||
redox_rt::sys::posix_kill_thread(os_tid.thread_fd, signal as u32)?;
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user