diff --git a/src/header/fcntl/mod.rs b/src/header/fcntl/mod.rs index 442ed27a70..4abdb6baf0 100644 --- a/src/header/fcntl/mod.rs +++ b/src/header/fcntl/mod.rs @@ -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, diff --git a/src/header/pthread/mod.rs b/src/header/pthread/mod.rs index 7c75c0511c..e883230110 100644 --- a/src/header/pthread/mod.rs +++ b/src/header/pthread/mod.rs @@ -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, }; diff --git a/src/header/signal/mod.rs b/src/header/signal/mod.rs index d0ae5aa3cd..6a473258d6 100644 --- a/src/header/signal/mod.rs +++ b/src/header/signal/mod.rs @@ -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 diff --git a/src/header/time/mod.rs b/src/header/time/mod.rs index 8b7172c32a..9060918364 100644 --- a/src/header/time/mod.rs +++ b/src/header/time/mod.rs @@ -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)] diff --git a/src/pthread/mod.rs b/src/pthread/mod.rs index f0a016b5e4..970c92bfa4 100644 --- a/src/pthread/mod.rs +++ b/src/pthread/mod.rs @@ -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.