fix(runtime): support older stable Rust atomic updates
Intrepid/Prometeu/Runtime/pipeline/head This commit looks good

This commit is contained in:
2026-11-05 09:00:19 +00:00
parent 1aa939eca8
commit 09d8778f04
3 changed files with 13 additions and 5 deletions
@@ -18,9 +18,11 @@ impl ControlledWallClock {
} }
/// Advance civil time explicitly, saturating at the largest timestamp. /// Advance civil time explicitly, saturating at the largest timestamp.
// `try_update` requires Rust 1.95; keep older stable CI toolchains compatible.
#[allow(deprecated)]
pub fn advance(&self, seconds: u64) { pub fn advance(&self, seconds: u64) {
// Harness control may retry on a concurrent update; reads remain a single load. // Harness control may retry on a concurrent update; reads remain a single load.
let _ = self.seconds.try_update(Ordering::Relaxed, Ordering::Relaxed, |current| { let _ = self.seconds.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |current| {
Some(current.saturating_add(seconds)) Some(current.saturating_add(seconds))
}); });
} }
@@ -7,11 +7,15 @@ use std::time::{Duration, Instant};
pub const GUEST_BYTES: usize = 4096; pub const GUEST_BYTES: usize = 4096;
static NEXT_CONTEXT: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1); static NEXT_CONTEXT: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1);
// `try_update` requires Rust 1.95; keep older stable CI toolchains compatible.
#[allow(deprecated)]
fn next_context() -> Result<u64> { fn next_context() -> Result<u64> {
NEXT_CONTEXT NEXT_CONTEXT
.try_update(std::sync::atomic::Ordering::SeqCst, std::sync::atomic::Ordering::SeqCst, |n| { .fetch_update(
n.checked_add(1).filter(|&next| next <= i64::MAX as u64) std::sync::atomic::Ordering::SeqCst,
}) std::sync::atomic::Ordering::SeqCst,
|n| n.checked_add(1).filter(|&next| next <= i64::MAX as u64),
)
.map_err(|_| Error::CounterExhausted) .map_err(|_| Error::CounterExhausted)
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -16,9 +16,11 @@ impl PublicationControl {
pub fn publication_attempted(&self) -> bool { pub fn publication_attempted(&self) -> bool {
self.0.load(Ordering::SeqCst) & 1 != 0 self.0.load(Ordering::SeqCst) & 1 != 0
} }
// `try_update` requires Rust 1.95; keep older stable CI toolchains compatible.
#[allow(deprecated)]
fn enter(&self) -> Result<()> { fn enter(&self) -> Result<()> {
self.0 self.0
.try_update(Ordering::SeqCst, Ordering::SeqCst, |state| { .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |state| {
if state & 2 == 0 { Some(state | 1) } else { None } if state & 2 == 0 { Some(state | 1) } else { None }
}) })
.map(|_| ()) .map(|_| ())