oscall 0.0.1

Low-level cross-platform interface to operating system services: files, memory mapping, networking and more, with no libc on Linux
Documentation
//! `sync` without a system: one thread, which nobody can wake and which
//! cannot sleep.

use core::sync::atomic::{AtomicU32, Ordering};
use core::time::Duration;

use crate::{ErrorKind, Result};

/// Whether the wait ended otherwise than by its timeout.
pub(crate) fn wait(atomic: &AtomicU32, expected: u32, timeout: Option<Duration>) -> Result<bool> {
    if atomic.load(Ordering::SeqCst) != expected {
        return Ok(true);
    }
    match timeout {
        // The wait could never end.
        None => Err(ErrorKind::Deadlock.into()),
        Some(Duration::ZERO) => Ok(false),
        // There is no clock to wait on.
        Some(_) => Err(ErrorKind::Unsupported.into()),
    }
}

pub(crate) fn wake(_atomic: &AtomicU32, _all: bool) {}