fmt
This commit is contained in:
parent
6280e267f0
commit
32d49680d6
@ -39,7 +39,8 @@ fn init_once_get_or_create_id(
|
||||
|ecx| &mut ecx.machine.sync.init_onces,
|
||||
|_| interp_ok(Default::default()),
|
||||
)?
|
||||
.ok_or_else(|| err_ub_format!("init_once has invalid ID")).into()
|
||||
.ok_or_else(|| err_ub_format!("init_once has invalid ID"))
|
||||
.into()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -307,7 +307,8 @@ fn mutex_get_or_create_id(
|
||||
|ecx| &mut ecx.machine.sync.mutexes,
|
||||
|ecx| initialize_data(ecx).map(|data| Mutex { data, ..Default::default() }),
|
||||
)?
|
||||
.ok_or_else(|| err_ub_format!("mutex has invalid ID")).into()
|
||||
.ok_or_else(|| err_ub_format!("mutex has invalid ID"))
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Retrieve the additional data stored for a mutex.
|
||||
@ -334,7 +335,8 @@ fn rwlock_get_or_create_id(
|
||||
|ecx| &mut ecx.machine.sync.rwlocks,
|
||||
|ecx| initialize_data(ecx).map(|data| RwLock { data, ..Default::default() }),
|
||||
)?
|
||||
.ok_or_else(|| err_ub_format!("rwlock has invalid ID")).into()
|
||||
.ok_or_else(|| err_ub_format!("rwlock has invalid ID"))
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Retrieve the additional data stored for a rwlock.
|
||||
@ -375,7 +377,8 @@ fn condvar_get_or_create_id(
|
||||
|ecx| &mut ecx.machine.sync.condvars,
|
||||
|ecx| initialize_data(ecx).map(|data| Condvar { data, ..Default::default() }),
|
||||
)?
|
||||
.ok_or_else(|| err_ub_format!("condvar has invalid ID")).into()
|
||||
.ok_or_else(|| err_ub_format!("condvar has invalid ID"))
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Retrieve the additional data stored for a condvar.
|
||||
|
@ -752,17 +752,19 @@ fn read_timespec(&mut self, tp: &MPlaceTy<'tcx>) -> InterpResult<'tcx, Option<Du
|
||||
let nanoseconds_scalar = this.read_scalar(&nanoseconds_place)?;
|
||||
let nanoseconds = nanoseconds_scalar.to_target_isize(this)?;
|
||||
|
||||
interp_ok(try {
|
||||
// tv_sec must be non-negative.
|
||||
let seconds: u64 = seconds.try_into().ok()?;
|
||||
// tv_nsec must be non-negative.
|
||||
let nanoseconds: u32 = nanoseconds.try_into().ok()?;
|
||||
if nanoseconds >= 1_000_000_000 {
|
||||
// tv_nsec must not be greater than 999,999,999.
|
||||
None?
|
||||
}
|
||||
Duration::new(seconds, nanoseconds)
|
||||
})
|
||||
interp_ok(
|
||||
try {
|
||||
// tv_sec must be non-negative.
|
||||
let seconds: u64 = seconds.try_into().ok()?;
|
||||
// tv_nsec must be non-negative.
|
||||
let nanoseconds: u32 = nanoseconds.try_into().ok()?;
|
||||
if nanoseconds >= 1_000_000_000 {
|
||||
// tv_nsec must not be greater than 999,999,999.
|
||||
None?
|
||||
}
|
||||
Duration::new(seconds, nanoseconds)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/// Read bytes from a byte slice.
|
||||
|
@ -11,7 +11,8 @@
|
||||
/// Returns the time elapsed between the provided time and the unix epoch as a `Duration`.
|
||||
pub fn system_time_to_duration<'tcx>(time: &SystemTime) -> InterpResult<'tcx, Duration> {
|
||||
time.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.map_err(|_| err_unsup_format!("times before the Unix epoch are not supported")).into()
|
||||
.map_err(|_| err_unsup_format!("times before the Unix epoch are not supported"))
|
||||
.into()
|
||||
}
|
||||
|
||||
impl<'tcx> EvalContextExt<'tcx> for crate::MiriInterpCx<'tcx> {}
|
||||
|
@ -517,7 +517,8 @@ fn fcntl(&mut self, args: &[OpTy<'tcx>]) -> InterpResult<'tcx, Scalar> {
|
||||
let start = this.read_scalar(&args[2])?.to_i32()?;
|
||||
|
||||
match this.machine.fds.get(fd_num) {
|
||||
Some(fd) => interp_ok(Scalar::from_i32(this.machine.fds.insert_with_min_num(fd, start))),
|
||||
Some(fd) =>
|
||||
interp_ok(Scalar::from_i32(this.machine.fds.insert_with_min_num(fd, start))),
|
||||
None => interp_ok(Scalar::from_i32(this.fd_not_found()?)),
|
||||
}
|
||||
} else if this.tcx.sess.target.os == "macos" && cmd == this.eval_libc_i32("F_FULLFSYNC") {
|
||||
|
@ -4,7 +4,7 @@
|
||||
// Two variants: the atomic store matches the size of the first or second atomic load.
|
||||
//@revisions: match_first_load match_second_load
|
||||
|
||||
use std::sync::atomic::{AtomicU16, AtomicU8, Ordering};
|
||||
use std::sync::atomic::{AtomicU8, AtomicU16, Ordering};
|
||||
use std::thread;
|
||||
|
||||
fn convert(a: &AtomicU16) -> &[AtomicU8; 2] {
|
||||
|
@ -4,7 +4,7 @@
|
||||
// Two revisions, depending on which access goes first.
|
||||
//@revisions: read_write write_read
|
||||
|
||||
use std::sync::atomic::{AtomicU16, AtomicU8, Ordering};
|
||||
use std::sync::atomic::{AtomicU8, AtomicU16, Ordering};
|
||||
use std::thread;
|
||||
|
||||
fn convert(a: &AtomicU16) -> &[AtomicU8; 2] {
|
||||
|
Loading…
Reference in New Issue
Block a user