std: pass hint to id-based parking functions
This commit is contained in:
@@ -7,17 +7,17 @@ pub type ThreadId = fortanix_sgx_abi::Tcs;
|
||||
|
||||
pub use super::abi::thread::current;
|
||||
|
||||
pub fn park() {
|
||||
pub fn park(_hint: usize) {
|
||||
usercalls::wait(EV_UNPARK, WAIT_INDEFINITE).unwrap();
|
||||
}
|
||||
|
||||
pub fn park_timeout(dur: Duration) {
|
||||
pub fn park_timeout(dur: Duration, _hint: usize) {
|
||||
let timeout = u128::min(dur.as_nanos(), WAIT_INDEFINITE as u128 - 1) as u64;
|
||||
if let Err(e) = usercalls::wait(EV_UNPARK, timeout) {
|
||||
assert!(matches!(e.kind(), ErrorKind::TimedOut | ErrorKind::WouldBlock))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unpark(tid: ThreadId) {
|
||||
pub fn unpark(tid: ThreadId, _hint: usize) {
|
||||
let _ = usercalls::send(EV_UNPARK, Some(tid));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![cfg(target_os = "netbsd")]
|
||||
|
||||
use crate::ffi::{c_int, c_void};
|
||||
use crate::ptr::{null, null_mut};
|
||||
use crate::ptr;
|
||||
use crate::time::Duration;
|
||||
use libc::{_lwp_self, clockid_t, lwpid_t, time_t, timespec, CLOCK_MONOTONIC};
|
||||
|
||||
@@ -25,13 +25,13 @@ pub fn current() -> ThreadId {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn park() {
|
||||
pub fn park(hint: usize) {
|
||||
unsafe {
|
||||
___lwp_park60(0, 0, null_mut(), 0, null(), null());
|
||||
___lwp_park60(0, 0, ptr::null_mut(), 0, ptr::invalid(hint), ptr::null());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn park_timeout(dur: Duration) {
|
||||
pub fn park_timeout(dur: Duration, hint: usize) {
|
||||
let mut timeout = timespec {
|
||||
// Saturate so that the operation will definitely time out
|
||||
// (even if it is after the heat death of the universe).
|
||||
@@ -42,13 +42,13 @@ pub fn park_timeout(dur: Duration) {
|
||||
// Timeout needs to be mutable since it is modified on NetBSD 9.0 and
|
||||
// above.
|
||||
unsafe {
|
||||
___lwp_park60(CLOCK_MONOTONIC, 0, &mut timeout, 0, null(), null());
|
||||
___lwp_park60(CLOCK_MONOTONIC, 0, &mut timeout, 0, ptr::invalid(hint), ptr::null());
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn unpark(tid: ThreadId) {
|
||||
pub fn unpark(tid: ThreadId, hint: usize) {
|
||||
unsafe {
|
||||
_lwp_unpark(tid, null());
|
||||
_lwp_unpark(tid, ptr::invalid(hint));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user