Skip to content

Commit 2119b7e

Browse files
authored
Merge pull request #4441 from RalfJung/nanosleep
nanosleep: fix argument name and add a missing argument read
2 parents 3c3f1e4 + 7ea812f commit 2119b7e

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/tools/miri/src/shims/time.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -330,18 +330,15 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
330330
interp_ok(Scalar::from_i32(0)) // KERN_SUCCESS
331331
}
332332

333-
fn nanosleep(
334-
&mut self,
335-
req_op: &OpTy<'tcx>,
336-
_rem: &OpTy<'tcx>, // Signal handlers are not supported, so rem will never be written to.
337-
) -> InterpResult<'tcx, Scalar> {
333+
fn nanosleep(&mut self, duration: &OpTy<'tcx>, rem: &OpTy<'tcx>) -> InterpResult<'tcx, Scalar> {
338334
let this = self.eval_context_mut();
339335

340336
this.assert_target_os_is_unix("nanosleep");
341337

342-
let req = this.deref_pointer_as(req_op, this.libc_ty_layout("timespec"))?;
338+
let duration = this.deref_pointer_as(duration, this.libc_ty_layout("timespec"))?;
339+
let _rem = this.read_pointer(rem)?; // Signal handlers are not supported, so rem will never be written to.
343340

344-
let duration = match this.read_timespec(&req)? {
341+
let duration = match this.read_timespec(&duration)? {
345342
Some(duration) => duration,
346343
None => {
347344
return this.set_last_error_and_return_i32(LibcError("EINVAL"));

src/tools/miri/src/shims/unix/foreign_items.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -963,8 +963,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
963963
this.write_null(dest)?;
964964
}
965965
"nanosleep" => {
966-
let [req, rem] = this.check_shim(abi, CanonAbi::C, link_name, args)?;
967-
let result = this.nanosleep(req, rem)?;
966+
let [duration, rem] = this.check_shim(abi, CanonAbi::C, link_name, args)?;
967+
let result = this.nanosleep(duration, rem)?;
968968
this.write_scalar(result, dest)?;
969969
}
970970
"sched_getaffinity" => {

0 commit comments

Comments
 (0)