From b052b16e6aa5ea805a36f3ce429784e0303965cf Mon Sep 17 00:00:00 2001 From: Leesoo Ahn Date: Sat, 18 Jul 2026 16:42:12 +0900 Subject: [PATCH] Clean up deprecations (#8300) * vm: replace fetch_update() with try_update() fetch_update() in atomic namespace is in the deprecation stage. * host_env: replace libc::RLIM_NLIMITS with const RLIM_NLIMITS Define a new const, RLIM_NLIMITS instead of libc::RLIM_NLIMITS in order to clean up the deprecated const and to prevent breaking API where the const is still used. --- crates/host_env/src/resource.rs | 6 +++--- crates/vm/src/builtins/function.rs | 2 +- crates/vm/src/builtins/type.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/host_env/src/resource.rs b/crates/host_env/src/resource.rs index a0ba79b1b..fdf4e1e62 100644 --- a/crates/host_env/src/resource.rs +++ b/crates/host_env/src/resource.rs @@ -7,9 +7,6 @@ pub use libc::{ RLIMIT_NOFILE, RLIMIT_NPROC, RLIMIT_RSS, RLIMIT_STACK, c_long, rlim_t, rlimit, timeval, }; -#[cfg(target_os = "android")] -pub use libc::RLIM_NLIMITS; - #[cfg(any(target_os = "linux", target_os = "android", target_os = "emscripten"))] pub use libc::{RLIMIT_MSGQUEUE, RLIMIT_NICE, RLIMIT_RTPRIO, RLIMIT_SIGPENDING}; @@ -36,6 +33,9 @@ pub use libc::RUSAGE_THREAD; #[cfg(not(any(target_os = "windows", target_os = "redox")))] pub use libc::{RUSAGE_CHILDREN, RUSAGE_SELF}; +#[cfg(target_os = "android")] +pub const RLIM_NLIMITS: libc::c_int = 16; + #[derive(Debug, Clone, Copy)] pub struct RUsage { pub ru_utime: libc::timeval, diff --git a/crates/vm/src/builtins/function.rs b/crates/vm/src/builtins/function.rs index 47fda2994..af359f111 100644 --- a/crates/vm/src/builtins/function.rs +++ b/crates/vm/src/builtins/function.rs @@ -87,7 +87,7 @@ static FUNC_VERSION_COUNTER: AtomicU32 = AtomicU32::new(1); /// Once the counter wraps to 0, it stays at 0 permanently. fn next_func_version() -> u32 { FUNC_VERSION_COUNTER - .fetch_update(Relaxed, Relaxed, |v| (v != 0).then(|| v.wrapping_add(1))) + .try_update(Relaxed, Relaxed, |v| (v != 0).then(|| v.wrapping_add(1))) .unwrap_or(0) } diff --git a/crates/vm/src/builtins/type.rs b/crates/vm/src/builtins/type.rs index 3d9228b80..c27c6475f 100644 --- a/crates/vm/src/builtins/type.rs +++ b/crates/vm/src/builtins/type.rs @@ -680,7 +680,7 @@ impl PyType { let flags_bits = flags.bits(); let _ = self .abc_tpflags - .fetch_update(Ordering::AcqRel, Ordering::Acquire, |old| { + .try_update(Ordering::AcqRel, Ordering::Acquire, |old| { Some((old & !collection_bits) | flags_bits) }); self.modified();