fix: resolve 6 compilation errors from patch absorption

- fcntl/mod.rs: Remove misplaced F_DUPFD_CLOEXEC fallback code from
  inside the flock struct definition (bad patch merge artifact)
- fcntl/mod.rs: Remove unused 'close' import
- signal/mod.rs: Remove duplicate 'mod signalfd' declaration
- pthread/mod.rs: Add Pal+Sys imports for sched_yield() in pthread_yield
- time/mod.rs: Remove duplicate From<&TimeSpec> impl (already in
  bits_timespec/mod.rs)
- pthread/mod.rs: Add FINISHED flag to PthreadFlags and set it on
  thread exit (referenced by pthread_kill in signal/mod.rs)
This commit is contained in:
Red Bear OS
2026-07-12 02:12:54 +03:00
parent fa54b985ff
commit f222c3464b
5 changed files with 6 additions and 33 deletions
-18
View File
@@ -7,7 +7,6 @@ use core::num::NonZeroU64;
use crate::{
c_str::CStr,
error::ResultExt,
header::unistd::close,
platform::{
Pal, Sys,
types::{c_char, c_int, c_short, c_ulonglong, mode_t, off_t, pid_t},
@@ -74,23 +73,6 @@ pub struct flock {
/// Type of lock; `F_RDLCK`, `F_WRLCK`, `F_UNLCK`.
pub l_type: c_short,
/// Flag for starting offset.
if cmd == F_DUPFD_CLOEXEC {
let new_fd = Sys::fcntl(fildes, F_DUPFD_CLOEXEC, arg).or_minus_one_errno();
if new_fd >= 0 {
return new_fd;
}
let new_fd = Sys::fcntl(fildes, F_DUPFD, arg).or_minus_one_errno();
if new_fd < 0 {
return -1;
}
if Sys::fcntl(new_fd, F_SETFD, FD_CLOEXEC as c_ulonglong).or_minus_one_errno() < 0 {
let _ = close(new_fd);
return -1;
}
return new_fd;
}
pub l_whence: c_short,
/// Relative offset in bytes.
pub l_start: off_t,
+2 -2
View File
@@ -8,11 +8,11 @@ use core::{cell::Cell, ptr::NonNull};
use crate::{
error::Errno,
header::{sched::sched_param, time::timespec},
platform::types::{
platform::{Pal, Sys, types::{
c_int, c_uchar, c_uint, c_void, clockid_t, pthread_attr_t, pthread_barrier_t,
pthread_barrierattr_t, pthread_key_t, pthread_mutex_t, pthread_mutexattr_t, pthread_once_t,
pthread_rwlock_t, pthread_rwlockattr_t, pthread_t, size_t,
},
}},
pthread,
};
-3
View File
@@ -40,9 +40,6 @@ pub mod sys;
mod signalfd;
pub use self::signalfd::*;
mod signalfd;
pub use self::signalfd::*;
type SigSet = BitSet<[u64; 1]>;
/// cbindgen:ignore
-10
View File
@@ -50,16 +50,6 @@ pub(crate) const NANOSECONDS: c_long = 1_000_000_000;
/// cbindgen:ignore
const UTC_STR: &core::ffi::CStr = c"UTC";
#[cfg(target_os = "redox")]
impl<'a> From<&'a syscall::TimeSpec> for timespec {
fn from(tp: &syscall::TimeSpec) -> Self {
Self {
tv_sec: tp.tv_sec as _,
tv_nsec: tp.tv_nsec as _,
}
}
}
/// timer_t internal data, ABI unstable
#[repr(C)]
#[derive(Clone)]
+4
View File
@@ -66,6 +66,7 @@ pub unsafe fn terminate_from_main_thread() {
bitflags::bitflags! {
pub struct PthreadFlags: usize {
const DETACHED = 1;
const FINISHED = 2;
}
}
@@ -316,6 +317,9 @@ pub unsafe fn exit_current_thread(retval: Retval) -> ! {
thread_fd.dup_into_upper(b"status").unwrap()
};
this.flags
.fetch_or(PthreadFlags::FINISHED.bits(), Ordering::AcqRel);
if this.flags.load(Ordering::Acquire) & PthreadFlags::DETACHED.bits() != 0 {
// When detached, the thread state no longer makes any sense, and can immediately be
// deallocated.