also test pthread_condattr_getclock
This commit is contained in:
parent
86d7dff0b8
commit
9503c41ecc
@ -727,6 +727,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
) -> InterpResult<'tcx, Scalar<Provenance>> {
|
||||
let this = self.eval_context_mut();
|
||||
|
||||
// Does not exist on macOS!
|
||||
if !matches!(&*this.tcx.sess.target.os, "linux") {
|
||||
throw_unsup_format!(
|
||||
"`pthread_condattr_init` is not supported on {}",
|
||||
this.tcx.sess.target.os
|
||||
);
|
||||
}
|
||||
|
||||
let clock_id = this.read_scalar(clock_id_op)?.to_i32()?;
|
||||
if clock_id == this.eval_libc_i32("CLOCK_REALTIME")
|
||||
|| clock_id == this.eval_libc_i32("CLOCK_MONOTONIC")
|
||||
@ -747,6 +755,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
||||
) -> InterpResult<'tcx, Scalar<Provenance>> {
|
||||
let this = self.eval_context_mut();
|
||||
|
||||
// Does not exist on macOS!
|
||||
if !matches!(&*this.tcx.sess.target.os, "linux") {
|
||||
throw_unsup_format!(
|
||||
"`pthread_condattr_init` is not supported on {}",
|
||||
this.tcx.sess.target.os
|
||||
);
|
||||
}
|
||||
|
||||
let clock_id = condattr_get_clock_id(this, attr_op)?;
|
||||
this.write_scalar(Scalar::from_i32(clock_id), &this.deref_pointer(clk_id_op)?)?;
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
hello dup fd
|
@ -19,6 +19,7 @@ fn main() {
|
||||
check_rwlock_write();
|
||||
check_rwlock_read_no_deadlock();
|
||||
check_cond();
|
||||
check_condattr();
|
||||
}
|
||||
|
||||
fn test_mutex_libc_init_recursive() {
|
||||
@ -261,6 +262,31 @@ fn check_cond() {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_condattr() {
|
||||
unsafe {
|
||||
// Just smoke-testing that these functions can be called.
|
||||
let mut attr: MaybeUninit<libc::pthread_condattr_t> = MaybeUninit::uninit();
|
||||
assert_eq!(libc::pthread_condattr_init(attr.as_mut_ptr()), 0);
|
||||
|
||||
#[cfg(not(target_os = "macos"))] // setclock-getclock do not exist on macOS
|
||||
{
|
||||
let clock_id = libc::CLOCK_MONOTONIC;
|
||||
assert_eq!(libc::pthread_condattr_setclock(attr.as_mut_ptr(), clock_id), 0);
|
||||
let mut check_clock_id = MaybeUninit::<libc::clockid_t>::uninit();
|
||||
assert_eq!(
|
||||
libc::pthread_condattr_getclock(attr.as_mut_ptr(), check_clock_id.as_mut_ptr()),
|
||||
0
|
||||
);
|
||||
assert_eq!(check_clock_id.assume_init(), clock_id);
|
||||
}
|
||||
|
||||
let mut cond: MaybeUninit<libc::pthread_cond_t> = MaybeUninit::uninit();
|
||||
assert_eq!(libc::pthread_cond_init(cond.as_mut_ptr(), attr.as_ptr()), 0);
|
||||
assert_eq!(libc::pthread_condattr_destroy(attr.as_mut_ptr()), 0);
|
||||
assert_eq!(libc::pthread_cond_destroy(cond.as_mut_ptr()), 0);
|
||||
}
|
||||
}
|
||||
|
||||
// std::sync::RwLock does not even used pthread_rwlock any more.
|
||||
// Do some smoke testing of the API surface.
|
||||
fn test_rwlock_libc_static_initializer() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user