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/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], diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index d64255d128..4e3e6a95f9 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,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); 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..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)); 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 { 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