From 885118ccac3cf01cc9695682ff852c6dfc743b95 Mon Sep 17 00:00:00 2001 From: sourceturner <126549-sourceturner@users.noreply.gitlab.redox-os.org> Date: Sun, 19 Apr 2026 21:32:23 +0200 Subject: [PATCH 1/9] add missing #[deprecated] annotations add #[deprecated] annotation to functions that are marked as 'legacy' or 'obsolecent' (according to their comments) --- src/header/signal/mod.rs | 1 + src/header/stdio/mod.rs | 7 +++++++ src/header/stdlib/mod.rs | 1 + src/header/sys_time/mod.rs | 1 + src/header/sys_timeb/mod.rs | 2 ++ src/header/unistd/mod.rs | 5 ++++- src/header/wchar/mod.rs | 1 + 7 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/header/signal/mod.rs b/src/header/signal/mod.rs index 858d5ed474..a1913a0c09 100644 --- a/src/header/signal/mod.rs +++ b/src/header/signal/mod.rs @@ -292,6 +292,7 @@ pub extern "C" fn sigignore(sig: c_int) -> c_int { /// See . /// /// Marked obsolescent in issue 7. Removed in issue 8. +#[deprecated] #[unsafe(no_mangle)] pub extern "C" fn siginterrupt(sig: c_int, flag: c_int) -> c_int { let mut psa = mem::MaybeUninit::::uninit(); diff --git a/src/header/stdio/mod.rs b/src/header/stdio/mod.rs index 069d45562a..0ece8d2ed8 100644 --- a/src/header/stdio/mod.rs +++ b/src/header/stdio/mod.rs @@ -315,6 +315,7 @@ pub unsafe extern "C" fn ctermid(s: *mut c_char) -> *mut c_char { /// /// Marked legacy in SUS Version 2. // #[unsafe(no_mangle)] +#[deprecated] pub unsafe extern "C" fn cuserid(s: *mut c_char) -> *mut c_char { let mut buf: Vec = vec![0; 256]; let mut pwd: pwd::passwd = unsafe { mem::zeroed() }; @@ -894,6 +895,7 @@ pub unsafe extern "C" fn getchar_unlocked() -> c_int { /// `fgets` is recommended instead, which is what this implementation calls. /// /// Get a string from `stdin` +#[deprecated] #[unsafe(no_mangle)] pub unsafe extern "C" fn gets(s: *mut c_char) -> *mut c_char { unsafe { fgets(s, c_int::MAX, &raw mut *stdin) } @@ -904,6 +906,7 @@ pub unsafe extern "C" fn gets(s: *mut c_char) -> *mut c_char { /// Was marked legacy and removed in issue 6. /// /// Get an integer from `stream` +#[deprecated] #[unsafe(no_mangle)] pub unsafe extern "C" fn getw(stream: *mut FILE) -> c_int { let mut ret: c_int = 0; @@ -1125,6 +1128,7 @@ pub unsafe extern "C" fn puts(s: *const c_char) -> c_int { /// Marked legacy in SUS Version 2. /// /// Put an integer `w` into `stream` +#[deprecated] #[unsafe(no_mangle)] pub unsafe extern "C" fn putw(w: c_int, stream: *mut FILE) -> c_int { (unsafe { @@ -1258,6 +1262,7 @@ pub unsafe extern "C" fn setvbuf( /// See . /// /// Marked obsolescent in issue 7. +#[deprecated] #[unsafe(no_mangle)] pub unsafe extern "C" fn tempnam(dir: *const c_char, pfx: *const c_char) -> *mut c_char { unsafe fn is_appropriate(pos_dir: *const c_char) -> bool { @@ -1331,6 +1336,7 @@ pub unsafe extern "C" fn tmpfile() -> *mut FILE { /// See . /// /// Marked obsolescent in issue 7. +#[deprecated] #[unsafe(no_mangle)] pub unsafe extern "C" fn tmpnam(s: *mut c_char) -> *mut c_char { let buf = if s.is_null() { @@ -1343,6 +1349,7 @@ pub unsafe extern "C" fn tmpnam(s: *mut c_char) -> *mut c_char { unsafe { tmpnam_inner(buf, 1) } } +#[deprecated] unsafe extern "C" fn tmpnam_inner(buf: *mut c_char, offset: usize) -> *mut c_char { const TEMPLATE: &[u8] = b"XXXXXX\0"; diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs index 2afc7f627c..17132c9c53 100644 --- a/src/header/stdlib/mod.rs +++ b/src/header/stdlib/mod.rs @@ -1113,6 +1113,7 @@ pub unsafe extern "C" fn rand() -> c_int { /// # Deprecation /// The `rand_r()` function was marked as obsolescent in the Open Group Base /// Specifications Issue 7, and the function was removed in Issue 8. +#[deprecated] #[unsafe(no_mangle)] pub unsafe extern "C" fn rand_r(seed: *mut c_uint) -> c_int { if seed.is_null() { diff --git a/src/header/sys_time/mod.rs b/src/header/sys_time/mod.rs index 723ee1a48b..152f145318 100644 --- a/src/header/sys_time/mod.rs +++ b/src/header/sys_time/mod.rs @@ -117,6 +117,7 @@ pub unsafe extern "C" fn setitimer( /// # Deprecation /// The `utimes()` function was marked legacy in the Open Group Base /// Specifications Issue 6, and then unmarked in Issue 7. +#[deprecated] #[unsafe(no_mangle)] pub unsafe extern "C" fn utimes(path: *const c_char, times: *const timeval) -> c_int { let path = unsafe { CStr::from_ptr(path) }; diff --git a/src/header/sys_timeb/mod.rs b/src/header/sys_timeb/mod.rs index 85c0ff1ec9..b2294238e5 100644 --- a/src/header/sys_timeb/mod.rs +++ b/src/header/sys_timeb/mod.rs @@ -18,6 +18,7 @@ use crate::{ }; /// See . +#[deprecated] #[repr(C)] #[derive(Default)] pub struct timeb { @@ -32,6 +33,7 @@ pub struct timeb { /// # Safety /// The caller must ensure that `tp` is convertible to a `&mut /// MaybeUninit`. +#[deprecated] #[unsafe(no_mangle)] pub unsafe extern "C" fn ftime(tp: *mut timeb) -> c_int { // SAFETY: the caller is required to ensure that the pointer is valid. diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index 91158a0511..6c00d74964 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -38,7 +38,10 @@ pub use crate::header::pthread::fork_hooks; // Inclusion of ctermid() prototype marked as obsolescent since Issue 7, cf. // . // cuserid() marked legacy in Issue 5. -pub use crate::header::stdio::{ctermid, cuserid}; +#[deprecated] +pub use crate::header::stdio::ctermid; +#[allow(deprecated)] +pub use crate::header::stdio::cuserid; // TODO: implement and reexport fcntl functions: //pub use crate::header::fcntl::{faccessat, fchownat, fexecve, linkat, readlinkat, symlinkat, unlinkat}; diff --git a/src/header/wchar/mod.rs b/src/header/wchar/mod.rs index b29e71a218..fa4ff454f3 100644 --- a/src/header/wchar/mod.rs +++ b/src/header/wchar/mod.rs @@ -911,6 +911,7 @@ pub unsafe extern "C" fn wcstoull( /// /// Marked legacy in issue 6. /// Encouraged to use `wcsstr` instead, which this implementation simply forwards to. +#[deprecated] #[unsafe(no_mangle)] pub unsafe extern "C" fn wcswcs(ws1: *const wchar_t, ws2: *const wchar_t) -> *mut wchar_t { unsafe { wcsstr(ws1, ws2) } From 4ffd337b9be096436b0ebbc8f56c2ab7a81843c2 Mon Sep 17 00:00:00 2001 From: sourceturner <126549-sourceturner@users.noreply.gitlab.redox-os.org> Date: Sun, 19 Apr 2026 21:51:46 +0200 Subject: [PATCH 2/9] add #[allow(deprecated)] annotations allow using deprecated functions and data structures in deprecated functions --- src/header/arpa_inet/mod.rs | 5 ++++- src/header/netdb/mod.rs | 6 +++++- src/header/stdio/mod.rs | 17 ++++++++++++++--- src/header/sys_time/mod.rs | 2 ++ src/header/sys_timeb/mod.rs | 15 ++++++++++----- src/header/time/mod.rs | 15 ++++++++++++--- src/header/unistd/mod.rs | 8 ++++++-- src/header/utime/mod.rs | 1 + src/io/error.rs | 1 - src/platform/linux/signal.rs | 6 +++++- src/platform/pal/signal.rs | 5 ++++- src/platform/redox/signal.rs | 5 ++++- 12 files changed, 67 insertions(+), 19 deletions(-) diff --git a/src/header/arpa_inet/mod.rs b/src/header/arpa_inet/mod.rs index 838f71f2ff..e982353f71 100644 --- a/src/header/arpa_inet/mod.rs +++ b/src/header/arpa_inet/mod.rs @@ -145,7 +145,10 @@ pub extern "C" fn inet_netof(r#in: in_addr) -> in_addr_t { #[deprecated] #[unsafe(no_mangle)] pub unsafe extern "C" fn inet_network(cp: *const c_char) -> in_addr_t { - ntohl(unsafe { inet_addr(cp) }) + ntohl(unsafe { + #[allow(deprecated)] + inet_addr(cp) + }) } /// See . diff --git a/src/header/netdb/mod.rs b/src/header/netdb/mod.rs index 72ca178836..424270b907 100644 --- a/src/header/netdb/mod.rs +++ b/src/header/netdb/mod.rs @@ -348,7 +348,10 @@ pub unsafe extern "C" fn gethostbyname(name: *const c_char) -> *mut hostent { // Some implementations just skip resolution and copy the address to h_name if let Some(s_addr) = parse_ipv4_string(name_str) { let addr = in_addr { s_addr }; - return unsafe { gethostbyaddr(ptr::from_ref(&addr).cast::(), 4, AF_INET) }; + return unsafe { + #[allow(deprecated)] + gethostbyaddr(ptr::from_ref(&addr).cast::(), 4, AF_INET) + }; } // check the hosts file first @@ -1137,6 +1140,7 @@ pub extern "C" fn herror(prefix: *const c_char) { let code = H_ERRNO.get(); // Safety: `hstrerror` handles every error code case and always returns a valid C string let error = unsafe { + #[allow(deprecated)] let msg_cstr = CStr::from_ptr(hstrerror(code)); str::from_utf8_unchecked(msg_cstr.to_bytes()) }; diff --git a/src/header/stdio/mod.rs b/src/header/stdio/mod.rs index 0ece8d2ed8..a1d43be6c4 100644 --- a/src/header/stdio/mod.rs +++ b/src/header/stdio/mod.rs @@ -1299,7 +1299,12 @@ pub unsafe extern "C" fn tempnam(dir: *const c_char, pfx: *const c_char) -> *mut }; // use the same mechanism as tmpnam to get the file name - if unsafe { tmpnam_inner(out_buf, dirname_len + 1 + prefix_len) }.is_null() { + if unsafe { + #[allow(deprecated)] + tmpnam_inner(out_buf, dirname_len + 1 + prefix_len) + } + .is_null() + { // failed to find a valid file name, so we need to free the buffer unsafe { platform::free(out_buf.cast()) }; out_buf = ptr::null_mut(); @@ -1346,7 +1351,10 @@ pub unsafe extern "C" fn tmpnam(s: *mut c_char) -> *mut c_char { }; unsafe { *buf = b'/' as _ }; - unsafe { tmpnam_inner(buf, 1) } + unsafe { + #[allow(deprecated)] + tmpnam_inner(buf, 1) + } } #[deprecated] @@ -1359,7 +1367,10 @@ unsafe extern "C" fn tmpnam_inner(buf: *mut c_char, offset: usize) -> *mut c_cha }; let err = platform::ERRNO.get(); - unsafe { stdlib::mktemp(buf) }; + unsafe { + #[allow(deprecated)] + stdlib::mktemp(buf) + }; platform::ERRNO.set(err); if unsafe { *buf } == 0 { diff --git a/src/header/sys_time/mod.rs b/src/header/sys_time/mod.rs index 152f145318..43b27324a9 100644 --- a/src/header/sys_time/mod.rs +++ b/src/header/sys_time/mod.rs @@ -69,6 +69,7 @@ pub struct timezone { /// The `getitimer()` function was marked obsolescent in the Open Group Base /// Specifications Issue 7, and removed in Issue 8. #[deprecated] +#[allow(deprecated)] #[unsafe(no_mangle)] pub unsafe extern "C" fn getitimer(which: c_int, value: *mut itimerval) -> c_int { Sys::getitimer(which, unsafe { &mut *value }) @@ -100,6 +101,7 @@ pub unsafe extern "C" fn gettimeofday(tp: *mut timeval, tzp: *mut timezone) -> c /// The `setitimer()` function was marked obsolescent in the Open Group Base /// Specifications Issue 7, and removed in Issue 8. #[deprecated] +#[allow(deprecated)] #[unsafe(no_mangle)] pub unsafe extern "C" fn setitimer( which: c_int, diff --git a/src/header/sys_timeb/mod.rs b/src/header/sys_timeb/mod.rs index b2294238e5..8935f5b474 100644 --- a/src/header/sys_timeb/mod.rs +++ b/src/header/sys_timeb/mod.rs @@ -9,11 +9,10 @@ use core::ptr::NonNull; +#[allow(deprecated)] +use crate::header::sys_time::gettimeofday; use crate::{ - header::{ - sys_select::timeval, - sys_time::{gettimeofday, timezone}, - }, + header::{sys_select::timeval, sys_time::timezone}, platform::types::{c_int, c_short, c_ushort, time_t}, }; @@ -34,6 +33,7 @@ pub struct timeb { /// The caller must ensure that `tp` is convertible to a `&mut /// MaybeUninit`. #[deprecated] +#[allow(deprecated)] #[unsafe(no_mangle)] pub unsafe extern "C" fn ftime(tp: *mut timeb) -> c_int { // SAFETY: the caller is required to ensure that the pointer is valid. @@ -44,10 +44,15 @@ pub unsafe extern "C" fn ftime(tp: *mut timeb) -> c_int { // SAFETY: tv and tz are created above, and thus will coerce to valid // pointers. - if unsafe { gettimeofday(&raw mut tv, &raw mut tz) } < 0 { + if unsafe { + #[allow(deprecated)] + gettimeofday(&raw mut tv, &raw mut tz) + } < 0 + { return -1; } + #[allow(deprecated)] tp_maybe_uninit.write(timeb { time: tv.tv_sec, millitm: (tv.tv_usec / 1000) as c_ushort, diff --git a/src/header/time/mod.rs b/src/header/time/mod.rs index 2a7d4ca454..5260095f25 100644 --- a/src/header/time/mod.rs +++ b/src/header/time/mod.rs @@ -147,7 +147,10 @@ pub struct itimerspec { #[deprecated] #[unsafe(no_mangle)] pub unsafe extern "C" fn asctime(timeptr: *const tm) -> *mut c_char { - unsafe { asctime_r(timeptr, (&raw mut ASCTIME).cast()) } + unsafe { + #[allow(deprecated)] + asctime_r(timeptr, (&raw mut ASCTIME).cast()) + } } /// See . @@ -296,7 +299,10 @@ pub unsafe extern "C" fn clock_settime(clock_id: clockid_t, tp: *const timespec) #[deprecated] #[unsafe(no_mangle)] pub unsafe extern "C" fn ctime(clock: *const time_t) -> *mut c_char { - unsafe { asctime(localtime(clock)) } + unsafe { + #[allow(deprecated)] + asctime(localtime(clock)) + } } /// See . @@ -310,7 +316,10 @@ pub unsafe extern "C" fn ctime_r(clock: *const time_t, buf: *mut c_char) -> *mut // Using MaybeUninit seems to cause a panic during the build process let mut tm1 = blank_tm(); unsafe { localtime_r(clock, &raw mut tm1) }; - unsafe { asctime_r(&raw const tm1, buf) } + unsafe { + #[allow(deprecated)] + asctime_r(&raw const tm1, buf) + } } /// See . diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index 6c00d74964..21df741655 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -9,6 +9,8 @@ use core::{ ptr, slice, }; +#[allow(deprecated)] +use crate::platform::types::useconds_t; use crate::{ c_str::CStr, error::{Errno, ResultExt}, @@ -27,12 +29,12 @@ use crate::{ self, ERRNO, Pal, PalSignal, Sys, types::{ c_char, c_int, c_long, c_short, c_uint, c_ulonglong, c_void, gid_t, off_t, pid_t, - size_t, ssize_t, suseconds_t, time_t, uid_t, useconds_t, + size_t, ssize_t, suseconds_t, time_t, uid_t, }, }, }; -pub use self::{brk::*, getopt::*, getpass::getpass, pathconf::*, sysconf::*}; +pub use self::{brk::*, getopt::*, pathconf::*, sysconf::*}; pub use crate::header::pthread::fork_hooks; // Inclusion of ctermid() prototype marked as obsolescent since Issue 7, cf. @@ -1118,6 +1120,7 @@ pub extern "C" fn ttyname_r(fildes: c_int, name: *mut c_char, namesize: size_t) /// The `ualarm()` function was marked obsolescent in the Open Group Base /// Specifications Issue 6, and removed in Issue 7. #[deprecated] +#[allow(deprecated)] #[unsafe(no_mangle)] pub extern "C" fn ualarm(usecs: useconds_t, interval: useconds_t) -> useconds_t { // TODO setitimer is unimplemented on Redox and obsolete @@ -1167,6 +1170,7 @@ pub unsafe extern "C" fn unlinkat(fd: c_int, path: *const c_char, flags: c_int) /// The `usleep()` function was marked obsolescent in the Open Group Base /// Specifications Issue 6, and removed in Issue 7. #[deprecated] +#[allow(deprecated)] #[unsafe(no_mangle)] pub extern "C" fn usleep(useconds: useconds_t) -> c_int { #[cfg(not(target_arch = "x86"))] diff --git a/src/header/utime/mod.rs b/src/header/utime/mod.rs index 75f5238560..88e10e1062 100644 --- a/src/header/utime/mod.rs +++ b/src/header/utime/mod.rs @@ -26,6 +26,7 @@ pub struct utimbuf { /// See . #[deprecated] +#[allow(deprecated)] #[unsafe(no_mangle)] pub unsafe extern "C" fn utime(filename: *const c_char, times: *const utimbuf) -> c_int { let filename_cstr = unsafe { CStr::from_ptr(filename) }; diff --git a/src/io/error.rs b/src/io/error.rs index f72eb42c24..203f628a88 100644 --- a/src/io/error.rs +++ b/src/io/error.rs @@ -219,7 +219,6 @@ struct Custom { /// /// [`io::Error`]: struct.Error.html #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] -#[allow(deprecated)] #[non_exhaustive] pub enum ErrorKind { /// An entity was not found, often a file. diff --git a/src/platform/linux/signal.rs b/src/platform/linux/signal.rs index 8c571ffd67..d2b21fe1a2 100644 --- a/src/platform/linux/signal.rs +++ b/src/platform/linux/signal.rs @@ -10,18 +10,21 @@ use super::{ }, Sys, e_raw, }; +#[allow(deprecated)] +use crate::header::sys_time::itimerval; use crate::{ error::{Errno, Result}, header::{ bits_timespec::timespec, signal::{SA_RESTORER, SI_QUEUE, sigaction, siginfo_t, sigset_t, sigval, stack_t}, sys_select::timeval, - sys_time::{self, itimerval}, + sys_time, }, platform, }; impl PalSignal for Sys { + #[allow(deprecated)] fn getitimer(which: c_int, out: &mut itimerval) -> Result<()> { unsafe { e_raw(syscall!(GETITIMER, which, ptr::from_mut(out)))?; @@ -58,6 +61,7 @@ impl PalSignal for Sys { Ok(()) } + #[allow(deprecated)] fn setitimer(which: c_int, new: &itimerval, old: Option<&mut itimerval>) -> Result<()> { e_raw(unsafe { syscall!( diff --git a/src/platform/pal/signal.rs b/src/platform/pal/signal.rs index 8a8aaac346..94b3a3ae58 100644 --- a/src/platform/pal/signal.rs +++ b/src/platform/pal/signal.rs @@ -2,18 +2,20 @@ use super::super::{ Pal, types::{c_int, c_uint, pid_t}, }; +#[allow(deprecated)] +use crate::header::sys_time::itimerval; use crate::{ error::{Errno, Result}, header::{ bits_timespec::timespec, signal::{sigaction, siginfo_t, sigset_t, sigval, stack_t}, - sys_time::itimerval, }, }; /// Platform abstraction of signal-related functionality. pub trait PalSignal: Pal { /// Platform implementation of [`getitimer()`](crate::header::sys_time::getitimer) from [`sys/time.h`](crate::header::sys_time). + #[allow(deprecated)] fn getitimer(which: c_int, out: &mut itimerval) -> Result<()>; /// Platform implementation of [`kill()`](crate::header::signal::kill) from [`signal.h`](crate::header::signal). @@ -29,6 +31,7 @@ pub trait PalSignal: Pal { fn raise(sig: c_int) -> Result<()>; /// Platform implementation of [`setitimer()`](crate::header::sys_time::setitimer) from [`sys/time.h`](crate::header::sys_time). + #[allow(deprecated)] fn setitimer(which: c_int, new: &itimerval, old: Option<&mut itimerval>) -> Result<()>; /// Platform implementation of [`alarm()`](crate::header::unistd::alarm) from [`unistd.h`](crate::header::unistd). diff --git a/src/platform/redox/signal.rs b/src/platform/redox/signal.rs index e4b17865c1..7987528708 100644 --- a/src/platform/redox/signal.rs +++ b/src/platform/redox/signal.rs @@ -2,6 +2,8 @@ use super::{ super::{Pal, PalSignal, types::*}, Sys, }; +#[allow(deprecated)] +use crate::header::sys_time::{ITIMER_REAL, itimerval}; use crate::{ error::{Errno, Result}, header::{ @@ -12,7 +14,6 @@ use crate::{ SS_DISABLE, SS_ONSTACK, sigaction, sigevent, siginfo_t, sigset_t, sigval, stack_t, ucontext_t, }, - sys_time::{ITIMER_REAL, itimerval}, time::{itimerspec, timer_internal_t}, }, out::Out, @@ -58,6 +59,7 @@ const _: () = { }; impl PalSignal for Sys { + #[allow(deprecated)] fn getitimer(which: c_int, out: &mut itimerval) -> Result<()> { let path = match which { ITIMER_REAL => "/scheme/itimer/1", @@ -100,6 +102,7 @@ impl PalSignal for Sys { unsafe { Self::rlct_kill(Self::current_os_tid(), sig as _) } } + #[allow(deprecated)] fn setitimer(which: c_int, _new: &itimerval, old: Option<&mut itimerval>) -> Result<()> { // TODO: setitimer is no longer part of POSIX and should not be implemented in Redox // Change the platform-independent implementation to use POSIX timers. From 292fd9e50b3e77facf8e81ee3a98c193dd8291f6 Mon Sep 17 00:00:00 2001 From: sourceturner <126549-sourceturner@users.noreply.gitlab.redox-os.org> Date: Sun, 19 Apr 2026 21:53:20 +0200 Subject: [PATCH 3/9] replace deprecated memalign() with posix_memalign() --- src/header/stdlib/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs index 17132c9c53..78e64e8d18 100644 --- a/src/header/stdlib/mod.rs +++ b/src/header/stdlib/mod.rs @@ -146,9 +146,9 @@ pub unsafe extern "C" fn aligned_alloc(alignment: size_t, size: size_t) -> *mut platform::ERRNO.set(EINVAL); return ptr::null_mut(); } - /* The size-is-multiple-of-alignment requirement is the only - * difference between aligned_alloc() and memalign(). */ - unsafe { memalign(alignment, size) } + let mut pointer = ptr::null_mut(); + unsafe { posix_memalign(ptr::from_mut(&mut pointer), alignment, size) }; + pointer } /// See . From 1f584a39435feb52f8a28f3170dd9db8ea905c2c Mon Sep 17 00:00:00 2001 From: sourceturner <126549-sourceturner@users.noreply.gitlab.redox-os.org> Date: Sun, 19 Apr 2026 21:54:41 +0200 Subject: [PATCH 4/9] replace deprecated NaiveDateTime::from_timestamp --- src/header/time/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/header/time/mod.rs b/src/header/time/mod.rs index 5260095f25..1a432bf304 100644 --- a/src/header/time/mod.rs +++ b/src/header/time/mod.rs @@ -769,7 +769,9 @@ fn time_zone() -> Tz { fn now() -> NaiveDateTime { let mut now = timespec::default(); if Sys::clock_gettime(CLOCK_REALTIME, Out::from_mut(&mut now)).is_ok() {}; // TODO what to do if Err? - NaiveDateTime::from_timestamp(now.tv_sec, now.tv_nsec as _) + DateTime::from_timestamp(now.tv_sec, now.tv_nsec as _) + .unwrap_or_default() + .naive_local() } #[inline(always)] From 19e6e61c17a29c44660a7fe8a47be9ef4d772d6f Mon Sep 17 00:00:00 2001 From: sourceturner <126549-sourceturner@users.noreply.gitlab.redox-os.org> Date: Sun, 19 Apr 2026 21:57:28 +0200 Subject: [PATCH 5/9] replace deprecated atomic::spin_loop_hint() --- src/sync/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sync/mod.rs b/src/sync/mod.rs index a21cefa8a9..9edda90ece 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs @@ -27,10 +27,11 @@ use crate::{ platform::{Pal, Sys, types::c_int}, }; use core::{ + hint, mem::MaybeUninit, ops::Deref, ptr, - sync::atomic::{self, AtomicI32, AtomicI32 as AtomicInt, AtomicU32}, + sync::atomic::{AtomicI32, AtomicI32 as AtomicInt, AtomicU32}, }; const FUTEX_WAIT: c_int = 0; @@ -154,7 +155,7 @@ where { // First, try spinning for really short durations for _ in 0..999 { - atomic::spin_loop_hint(); + hint::spin_loop(); if attempt(word) == AttemptStatus::Desired { return; } From 138520d1c59b01fa619039ce6216c00d6ae25442 Mon Sep 17 00:00:00 2001 From: sourceturner <126549-sourceturner@users.noreply.gitlab.redox-os.org> Date: Sun, 19 Apr 2026 22:57:06 +0200 Subject: [PATCH 6/9] replace deprecated useconds_t type --- src/header/sys_stat/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/header/sys_stat/mod.rs b/src/header/sys_stat/mod.rs index d0db00eafe..0975a20dec 100644 --- a/src/header/sys_stat/mod.rs +++ b/src/header/sys_stat/mod.rs @@ -13,8 +13,8 @@ use crate::{ platform::{ Pal, Sys, types::{ - blkcnt_t, blksize_t, c_char, c_int, dev_t, gid_t, ino_t, mode_t, nlink_t, off_t, uid_t, - useconds_t, + blkcnt_t, blksize_t, c_char, c_int, c_long, dev_t, gid_t, ino_t, mode_t, nlink_t, + off_t, uid_t, }, }, }; @@ -52,8 +52,8 @@ pub const S_ISUID: c_int = 0o4_000; pub const S_ISGID: c_int = 0o2_000; pub const S_ISVTX: c_int = 0o1_000; -pub const UTIME_NOW: useconds_t = (1 << 30) - 1; -pub const UTIME_OMIT: useconds_t = (1 << 30) - 2; +pub const UTIME_NOW: c_long = (1 << 30) - 1; +pub const UTIME_OMIT: c_long = (1 << 30) - 2; /// See . #[repr(C)] From 2873086f3982c5beb739f3258423292a948d99f0 Mon Sep 17 00:00:00 2001 From: sourceturner <126549-sourceturner@users.noreply.gitlab.redox-os.org> Date: Sun, 19 Apr 2026 23:05:32 +0200 Subject: [PATCH 7/9] replace deprecated setitimer() in alarm() implementation --- src/platform/linux/signal.rs | 55 +++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/src/platform/linux/signal.rs b/src/platform/linux/signal.rs index d2b21fe1a2..3f511b6323 100644 --- a/src/platform/linux/signal.rs +++ b/src/platform/linux/signal.rs @@ -6,7 +6,7 @@ use core::{ use super::{ super::{ PalSignal, - types::{c_int, c_uint, pid_t, time_t}, + types::{c_int, c_uint, pid_t}, }, Sys, e_raw, }; @@ -16,11 +16,14 @@ use crate::{ error::{Errno, Result}, header::{ bits_timespec::timespec, - signal::{SA_RESTORER, SI_QUEUE, sigaction, siginfo_t, sigset_t, sigval, stack_t}, - sys_select::timeval, - sys_time, + signal::{ + SA_RESTORER, SI_QUEUE, SIGALRM, SIGEV_SIGNAL, sigaction, sigevent, siginfo_t, sigset_t, + sigval, stack_t, + }, + time, }, - platform, + out::Out, + platform::{self, Pal, types::timer_t}, }; impl PalSignal for Sys { @@ -76,22 +79,40 @@ impl PalSignal for Sys { /// See . fn alarm(seconds: c_uint) -> c_uint { - let timer = itimerval { - it_value: timeval { - tv_sec: time_t::from(seconds), - tv_usec: 0, - }, - ..Default::default() + let mut signal_event = sigevent { + sigev_value: sigval { sival_int: 0 }, + sigev_signo: SIGALRM as c_int, + sigev_notify: SIGEV_SIGNAL, + sigev_notify_attributes: ptr::null_mut(), + sigev_notify_function: None, }; - let mut otimer = itimerval::default(); + let mut timerid: timer_t = Default::default(); + let timer = unsafe { + time::timer_create( + time::CLOCK_REALTIME, + ptr::from_mut(&mut signal_event), + ptr::from_mut(&mut timerid), + ) + }; + let value = time::itimerspec { + it_value: timespec { + tv_sec: i64::from(seconds), + tv_nsec: 0, + }, + it_interval: timespec { + tv_sec: 0, + tv_nsec: 0, + }, + }; + let mut ovalue = Default::default(); + let errno_backup = platform::ERRNO.get(); - let secs = if Self::setitimer(sys_time::ITIMER_REAL, &timer, Some(&mut otimer)).is_err() { + if Sys::timer_settime(timerid, 0, &value, Some(Out::from_mut(&mut ovalue))).is_err() { + platform::ERRNO.set(errno_backup); 0 } else { - otimer.it_value.tv_sec as c_uint + if otimer.it_value.tv_usec > 0 { 1 } else { 0 } - }; - platform::ERRNO.set(errno_backup); - secs + ovalue.it_value.tv_sec as c_uint + if ovalue.it_value.tv_nsec > 0 { 1 } else { 0 } + } } fn sigaction( From 8b10cbfa1a12ddd167c7c7fd2e406a0450a33d67 Mon Sep 17 00:00:00 2001 From: sourceturner <126549-sourceturner@users.noreply.gitlab.redox-os.org> Date: Sun, 19 Apr 2026 21:58:20 +0200 Subject: [PATCH 8/9] set 'deprecated' flag to 'deny' --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f855dbfde7..1ab1b32510 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ zero_ptr = "warn" # must allow on public constants due to cbindgen issue [workspace.lints.rust] dangling_pointers_from_temporaries = "deny" dead_code = "allow" # TODO review occuurences -deprecated = "allow" # TODO review occuurences +deprecated = "deny" # TODO review occuurences improper_ctypes_definitions = "deny" internal_features = "allow" # core_intrinsics and lang_items irrefutable_let_patterns = "deny" From a886faff59837eb9f07717fc0d66a134e0a9495e Mon Sep 17 00:00:00 2001 From: sourceturner Date: Mon, 20 Apr 2026 18:54:28 +0000 Subject: [PATCH 9/9] remove obsolete comment thanks to Wildan Mubarok for the hint --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 1ab1b32510..c05f7f66f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ zero_ptr = "warn" # must allow on public constants due to cbindgen issue [workspace.lints.rust] dangling_pointers_from_temporaries = "deny" dead_code = "allow" # TODO review occuurences -deprecated = "deny" # TODO review occuurences +deprecated = "deny" improper_ctypes_definitions = "deny" internal_features = "allow" # core_intrinsics and lang_items irrefutable_let_patterns = "deny"