Skip to content

Commit f8850e1

Browse files
committed
add visionos to sleep_until + check mach_wait_until result
1 parent 05f1cad commit f8850e1

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

library/std/src/sys/pal/unix/thread.rs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,13 @@ impl Thread {
355355
}
356356
}
357357

358-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
358+
#[cfg(any(
359+
target_os = "macos",
360+
target_os = "ios",
361+
target_os = "tvos",
362+
target_os = "watchos",
363+
target_os = "visionos"
364+
))]
359365
pub fn sleep_until(deadline: crate::time::Instant) {
360366
use core::mem::MaybeUninit;
361367

@@ -372,7 +378,7 @@ impl Thread {
372378
let info = info.assume_init();
373379
let ticks = nanos * (info.denom as u64) / (info.numer as u64);
374380

375-
mach_wait_until(ticks);
381+
let ret = mach_wait_until(ticks);
376382
assert_eq!(ret, KERN_SUCCESS);
377383
}
378384
}
@@ -392,17 +398,35 @@ impl Thread {
392398
}
393399
}
394400

395-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
401+
#[cfg(any(
402+
target_os = "macos",
403+
target_os = "ios",
404+
target_os = "tvos",
405+
target_os = "watchos",
406+
target_os = "visionos"
407+
))]
396408
const KERN_SUCCESS: libc::c_int = 0;
397409

398-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
410+
#[cfg(any(
411+
target_os = "macos",
412+
target_os = "ios",
413+
target_os = "tvos",
414+
target_os = "watchos",
415+
target_os = "visionos"
416+
))]
399417
#[repr(C)]
400418
struct mach_timebase_info_type {
401419
numer: u32,
402420
denom: u32,
403421
}
404422

405-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
423+
#[cfg(any(
424+
target_os = "macos",
425+
target_os = "ios",
426+
target_os = "tvos",
427+
target_os = "watchos",
428+
target_os = "visionos"
429+
))]
406430
extern "C" {
407431
fn mach_wait_until(deadline: u64) -> libc::c_int;
408432
fn mach_timebase_info(info: *mut mach_timebase_info_type) -> libc::c_int;

0 commit comments

Comments
 (0)