Move pthread::Errno to separate module.

This commit is contained in:
4lDO2
2024-09-07 12:46:16 +02:00
parent e73b891e77
commit 4bd0d2a1ef
21 changed files with 77 additions and 80 deletions
+11 -10
View File
@@ -3,15 +3,16 @@
use core::{cell::Cell, ptr::NonNull};
use crate::{
error::Errno,
header::{sched::*, time::timespec},
platform::{types::*, Pal, Sys},
pthread,
};
pub fn e(result: Result<(), pthread::Errno>) -> i32 {
pub fn e(result: Result<(), Errno>) -> i32 {
match result {
Ok(()) => 0,
Err(pthread::Errno(error)) => error,
Err(Errno(error)) => error,
}
}
@@ -75,7 +76,7 @@ pub use self::barrier::*;
pub unsafe extern "C" fn pthread_cancel(thread: pthread_t) -> c_int {
match pthread::cancel(&*thread.cast()) {
Ok(()) => 0,
Err(pthread::Errno(error)) => error,
Err(Errno(error)) => error,
}
}
@@ -96,7 +97,7 @@ pub unsafe extern "C" fn pthread_create(
core::ptr::write(pthread, ptr);
0
}
Err(pthread::Errno(code)) => code,
Err(Errno(code)) => code,
}
}
@@ -104,7 +105,7 @@ pub unsafe extern "C" fn pthread_create(
pub unsafe extern "C" fn pthread_detach(pthread: pthread_t) -> c_int {
match pthread::detach(&*pthread.cast()) {
Ok(()) => 0,
Err(pthread::Errno(errno)) => errno,
Err(Errno(errno)) => errno,
}
}
@@ -134,7 +135,7 @@ pub unsafe extern "C" fn pthread_getcpuclockid(
clock_out.write(clock);
0
}
Err(pthread::Errno(error)) => error,
Err(Errno(error)) => error,
}
}
@@ -151,7 +152,7 @@ pub unsafe extern "C" fn pthread_getschedparam(
0
}
Err(pthread::Errno(error)) => error,
Err(Errno(error)) => error,
}
}
@@ -167,7 +168,7 @@ pub unsafe extern "C" fn pthread_join(thread: pthread_t, retval: *mut *mut c_voi
}
0
}
Err(pthread::Errno(error)) => error,
Err(Errno(error)) => error,
}
}
@@ -195,7 +196,7 @@ pub unsafe extern "C" fn pthread_setcancelstate(state: c_int, oldstate: *mut c_i
}
0
}
Err(pthread::Errno(error)) => error,
Err(Errno(error)) => error,
}
}
#[no_mangle]
@@ -209,7 +210,7 @@ pub unsafe extern "C" fn pthread_setcanceltype(ty: c_int, oldty: *mut c_int) ->
}
0
}
Err(pthread::Errno(error)) => error,
Err(Errno(error)) => error,
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
use super::*;
use crate::pthread::Errno;
use crate::error::Errno;
// PTHREAD_MUTEX_INITIALIZER is defined in bits_pthread/cbindgen.toml
+2 -2
View File
@@ -5,9 +5,9 @@ use core::{mem, ptr};
use cbitset::BitSet;
use crate::{
error::{self, Errno, ResultExt},
header::{errno, time::timespec},
platform::{self, types::*, Pal, PalSignal, Sys},
pthread::{self, Errno, ResultExt},
};
pub use self::sys::*;
@@ -81,7 +81,7 @@ pub extern "C" fn killpg(pgrp: pid_t, sig: c_int) -> c_int {
#[no_mangle]
pub unsafe extern "C" fn pthread_kill(thread: pthread_t, sig: c_int) -> c_int {
let os_tid = {
let pthread = &*(thread as *const pthread::Pthread);
let pthread = &*(thread as *const crate::pthread::Pthread);
pthread.os_tid.get().read()
};
crate::header::pthread::e(Sys::rlct_kill(os_tid, sig as usize))
+1 -1
View File
@@ -9,6 +9,7 @@ use core::{
use crate::{
c_str::CStr,
error::ResultExt,
header::{
crypt::{crypt_data, crypt_r},
errno, fcntl, limits,
@@ -17,7 +18,6 @@ use crate::{
time::timespec,
},
platform::{self, types::*, Pal, Sys},
pthread::ResultExt,
};
use alloc::collections::LinkedList;