1b8a62b91Sopenharmony_ci//! Linux `futex`. 2b8a62b91Sopenharmony_ci//! 3b8a62b91Sopenharmony_ci//! # Safety 4b8a62b91Sopenharmony_ci//! 5b8a62b91Sopenharmony_ci//! Futex is a very low-level mechanism for implementing concurrency 6b8a62b91Sopenharmony_ci//! primitives. 7b8a62b91Sopenharmony_ci#![allow(unsafe_code)] 8b8a62b91Sopenharmony_ci 9b8a62b91Sopenharmony_ciuse crate::thread::Timespec; 10b8a62b91Sopenharmony_ciuse crate::{backend, io}; 11b8a62b91Sopenharmony_ci 12b8a62b91Sopenharmony_cipub use backend::thread::{FutexFlags, FutexOperation}; 13b8a62b91Sopenharmony_ci 14b8a62b91Sopenharmony_ci/// `futex(uaddr, op, val, utime, uaddr2, val3)` 15b8a62b91Sopenharmony_ci/// 16b8a62b91Sopenharmony_ci/// # References 17b8a62b91Sopenharmony_ci/// - [Linux `futex` system call] 18b8a62b91Sopenharmony_ci/// - [Linux `futex` feature] 19b8a62b91Sopenharmony_ci/// 20b8a62b91Sopenharmony_ci/// # Safety 21b8a62b91Sopenharmony_ci/// 22b8a62b91Sopenharmony_ci/// This is a very low-level feature for implementing synchronization 23b8a62b91Sopenharmony_ci/// primitives. See the references links above. 24b8a62b91Sopenharmony_ci/// 25b8a62b91Sopenharmony_ci/// [Linux `futex` system call]: https://man7.org/linux/man-pages/man2/futex.2.html 26b8a62b91Sopenharmony_ci/// [Linux `futex` feature]: https://man7.org/linux/man-pages/man7/futex.7.html 27b8a62b91Sopenharmony_ci#[inline] 28b8a62b91Sopenharmony_cipub unsafe fn futex( 29b8a62b91Sopenharmony_ci uaddr: *mut u32, 30b8a62b91Sopenharmony_ci op: FutexOperation, 31b8a62b91Sopenharmony_ci flags: FutexFlags, 32b8a62b91Sopenharmony_ci val: u32, 33b8a62b91Sopenharmony_ci utime: *const Timespec, 34b8a62b91Sopenharmony_ci uaddr2: *mut u32, 35b8a62b91Sopenharmony_ci val3: u32, 36b8a62b91Sopenharmony_ci) -> io::Result<usize> { 37b8a62b91Sopenharmony_ci backend::thread::syscalls::futex(uaddr, op, flags, val, utime, uaddr2, val3) 38b8a62b91Sopenharmony_ci} 39