From ff392a029a14c20a3afe41ecf4523851c2195519 Mon Sep 17 00:00:00 2001 From: auronandace Date: Fri, 13 Feb 2026 12:14:04 +0000 Subject: [PATCH 1/4] remove pthread_atfork from unistd and tackle some lints --- Cargo.toml | 1 + src/header/locale/mod.rs | 2 +- src/header/sys_syslog/logger.rs | 2 +- src/header/unistd/mod.rs | 13 +------------ src/platform/allocator/mod.rs | 2 +- src/platform/allocator/sys.rs | 2 +- src/pthread/mod.rs | 2 +- 7 files changed, 7 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 933c72a572..25fcd2da5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ zero_ptr = "warn" # must allow on public constants due to cbindgen issue [workspace.lints.rust] dangling_pointers_from_temporaries = "deny" +internal_features = "allow" # core_intrinsics and lang_items irrefutable_let_patterns = "deny" mismatched_lifetime_syntaxes = "deny" non_camel_case_types = "allow" diff --git a/src/header/locale/mod.rs b/src/header/locale/mod.rs index 34bbe74448..98bd4b34cf 100644 --- a/src/header/locale/mod.rs +++ b/src/header/locale/mod.rs @@ -166,7 +166,7 @@ pub unsafe extern "C" fn duplocale(loc: locale_t) -> locale_t { } } -pub fn load_locale_file(name: &str) -> Result, Errno> { +pub(crate) fn load_locale_file(name: &str) -> Result, Errno> { let mut path = String::from("/usr/share/i18n/locales/"); path.push_str(name); diff --git a/src/header/sys_syslog/logger.rs b/src/header/sys_syslog/logger.rs index c16a0f0ba3..1a004f05c5 100644 --- a/src/header/sys_syslog/logger.rs +++ b/src/header/sys_syslog/logger.rs @@ -30,7 +30,7 @@ use super::{ pub(super) static LOGGER: Mutex> = Mutex::new(LogParams::new(None)); -pub struct LogParams { +pub(super) struct LogParams { /// Identity prepended to each log message. POSIX does not specific what to do when it's empty, /// but the program name is a common default. ident: String, diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index d64255d128..0d5f82ba66 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -115,17 +115,6 @@ pub const _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS: c_int = 1145; pub const _CS_POSIX_V7_LPBIG_OFFBIG_LIBS: c_int = 1146; pub const _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS: c_int = 1147; -// Re-exported from pthread.h. `pthread_atfork` should be in pthread.h according to the -// standard, but glibc exports it here as well. We ONLY exported it in unistd.h till recently. -unsafe extern "C" { - #[unsafe(no_mangle)] - pub fn pthread_atfork( - prepare: Option, - parent: Option, - child: Option, - ) -> c_int; -} - /// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn _Fork() -> pid_t { @@ -583,7 +572,7 @@ pub unsafe extern "C" fn gethostname(mut name: *mut c_char, mut len: size_t) -> .map(|()| 0) .or_minus_one_errno(); if err < 0 { - mem::forget(uts); + mem::forget(uts); // forget does nothing with Copy types return err; } for c in unsafe { uts.assume_init() }.nodename.iter() { diff --git a/src/platform/allocator/mod.rs b/src/platform/allocator/mod.rs index 002c6082a1..06de784db8 100644 --- a/src/platform/allocator/mod.rs +++ b/src/platform/allocator/mod.rs @@ -82,7 +82,7 @@ unsafe impl GlobalAlloc for Allocator { unsafe { copy_nonoverlapping(ptr, new, size) }; } - drop((old_size, old_align)); + drop((old_size, old_align)); // drop does nothing with Copy types unsafe { (*self.get()).lock().free(ptr) }; new diff --git a/src/platform/allocator/sys.rs b/src/platform/allocator/sys.rs index fc7bb572b3..ff01eea87b 100644 --- a/src/platform/allocator/sys.rs +++ b/src/platform/allocator/sys.rs @@ -1,7 +1,7 @@ use crate::{ header::{ + pthread::pthread_atfork, sys_mman::{self, MREMAP_MAYMOVE}, - unistd::pthread_atfork, }, platform::{Pal, Sys}, sync::Mutex, diff --git a/src/pthread/mod.rs b/src/pthread/mod.rs index cc21330dc3..0f39be3772 100644 --- a/src/pthread/mod.rs +++ b/src/pthread/mod.rs @@ -190,7 +190,7 @@ pub(crate) unsafe fn create( push(arg as usize); push(start_routine as usize); - push(new_thread_shim as usize); + push(new_thread_shim as *const () as usize); } let Ok(os_tid) = (unsafe { Sys::rlct_clone(stack, &mut new_tcb.os_specific) }) else { From 5d6ae8fd3f3b34f7c2f99a0d704a9daa3ea55188 Mon Sep 17 00:00:00 2001 From: auronandace Date: Fri, 13 Feb 2026 12:31:59 +0000 Subject: [PATCH 2/4] add pthread.h to unistd fork test --- tests/unistd/fork.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unistd/fork.c b/tests/unistd/fork.c index eb9b84ac2d..225ead36e2 100644 --- a/tests/unistd/fork.c +++ b/tests/unistd/fork.c @@ -1,3 +1,4 @@ +#include #include #include #include From 955179ab6f4c0366f6db85cb1f5e5048e5f72b87 Mon Sep 17 00:00:00 2001 From: auronandace Date: Fri, 13 Feb 2026 13:22:05 +0000 Subject: [PATCH 3/4] remove code as per feedback --- src/header/unistd/mod.rs | 1 - src/platform/allocator/mod.rs | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index 0d5f82ba66..4e3e6a95f9 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -572,7 +572,6 @@ pub unsafe extern "C" fn gethostname(mut name: *mut c_char, mut len: size_t) -> .map(|()| 0) .or_minus_one_errno(); if err < 0 { - mem::forget(uts); // forget does nothing with Copy types return err; } for c in unsafe { uts.assume_init() }.nodename.iter() { diff --git a/src/platform/allocator/mod.rs b/src/platform/allocator/mod.rs index 06de784db8..e6c9244a35 100644 --- a/src/platform/allocator/mod.rs +++ b/src/platform/allocator/mod.rs @@ -75,14 +75,12 @@ unsafe impl GlobalAlloc for Allocator { let new = unsafe { self.alloc(Layout::from_size_align_unchecked(new_size, layout.align())) }; let old_size = layout.size(); - let old_align = layout.align(); if !new.is_null() { let size = cmp::min(old_size, new_size); unsafe { copy_nonoverlapping(ptr, new, size) }; } - drop((old_size, old_align)); // drop does nothing with Copy types unsafe { (*self.get()).lock().free(ptr) }; new From 0da732be98fe6e0c68b68af4961e8c8279143644 Mon Sep 17 00:00:00 2001 From: auronandace Date: Sat, 14 Feb 2026 08:40:15 +0000 Subject: [PATCH 4/4] remove Copy from utsname --- src/header/sys_utsname/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/header/sys_utsname/mod.rs b/src/header/sys_utsname/mod.rs index f9031c7b95..49653883e1 100644 --- a/src/header/sys_utsname/mod.rs +++ b/src/header/sys_utsname/mod.rs @@ -15,7 +15,7 @@ pub const UTSLENGTH: usize = 65; /// See . #[repr(C)] -#[derive(Clone, Copy, Debug, OutProject)] +#[derive(Clone, Debug, OutProject)] pub struct utsname { pub sysname: [c_char; UTSLENGTH], pub nodename: [c_char; UTSLENGTH],