Skip to content

Commit 8905742

Browse files
Use deref_pointer_as instead of deref_pointer
1 parent c2a3761 commit 8905742

File tree

9 files changed

+15
-15
lines changed

9 files changed

+15
-15
lines changed

src/shims/alloc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
102102
size: &OpTy<'tcx>,
103103
) -> InterpResult<'tcx, Scalar> {
104104
let this = self.eval_context_mut();
105-
let memptr = this.deref_pointer(memptr)?;
105+
let memptr = this.deref_pointer_as(memptr, this.machine.layouts.mut_raw_ptr)?;
106106
let align = this.read_target_usize(align)?;
107107
let size = this.read_target_usize(size)?;
108108

src/shims/foreign_items.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
865865
"lgammaf_r" => {
866866
let [x, signp] = this.check_shim(abi, Conv::C, link_name, args)?;
867867
let x = this.read_scalar(x)?.to_f32()?;
868-
let signp = this.deref_pointer(signp)?;
868+
let signp = this.deref_pointer_as(signp, this.machine.layouts.i32)?;
869869

870870
// Using host floats (but it's fine, these operations do not have guaranteed precision).
871871
let (res, sign) = x.to_host().ln_gamma();
@@ -876,7 +876,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
876876
"lgamma_r" => {
877877
let [x, signp] = this.check_shim(abi, Conv::C, link_name, args)?;
878878
let x = this.read_scalar(x)?.to_f64()?;
879-
let signp = this.deref_pointer(signp)?;
879+
let signp = this.deref_pointer_as(signp, this.machine.layouts.i32)?;
880880

881881
// Using host floats (but it's fine, these operations do not have guaranteed precision).
882882
let (res, sign) = x.to_host().ln_gamma();

src/shims/time.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
132132
this.assert_target_os_is_unix("localtime_r");
133133
this.check_no_isolation("`localtime_r`")?;
134134

135-
let timep = this.deref_pointer(timep)?;
135+
let timep = this.deref_pointer_as(timep, this.libc_ty_layout("time_t"))?;
136136
let result = this.deref_pointer_as(result_op, this.libc_ty_layout("tm"))?;
137137

138138
// The input "represents the number of seconds elapsed since the Epoch,
@@ -254,7 +254,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
254254
let qpc = i64::try_from(duration.as_nanos()).map_err(|_| {
255255
err_unsup_format!("programs running longer than 2^63 nanoseconds are not supported")
256256
})?;
257-
this.write_scalar(Scalar::from_i64(qpc), &this.deref_pointer(lpPerformanceCount_op)?)?;
257+
this.write_scalar(Scalar::from_i64(qpc), &this.deref_pointer_as(lpPerformanceCount_op, this.machine.layouts.i64)?)?;
258258
interp_ok(Scalar::from_i32(-1)) // return non-zero on success
259259
}
260260

src/shims/unix/foreign_items.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -866,8 +866,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
866866
// These shims are enabled only when the caller is in the standard library.
867867
"pthread_attr_getguardsize" if this.frame_in_std() => {
868868
let [_attr, guard_size] = this.check_shim(abi, Conv::C, link_name, args)?;
869-
let guard_size = this.deref_pointer(guard_size)?;
870869
let guard_size_layout = this.libc_ty_layout("size_t");
870+
let guard_size = this.deref_pointer_as(guard_size, guard_size_layout)?;
871871
this.write_scalar(
872872
Scalar::from_uint(this.machine.page_size, guard_size_layout.size),
873873
&guard_size,
@@ -894,7 +894,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
894894
let _attr_place =
895895
this.deref_pointer_as(attr_place, this.libc_ty_layout("pthread_attr_t"))?;
896896
let addr_place = this.deref_pointer(addr_place)?;
897-
let size_place = this.deref_pointer(size_place)?;
897+
let size_place = this.deref_pointer_as(size_place, this.libc_ty_layout("size_t"))?;
898898

899899
this.write_scalar(
900900
Scalar::from_uint(this.machine.stack_addr, this.pointer_size()),
@@ -928,7 +928,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
928928
let pwd = this.deref_pointer_as(pwd, this.libc_ty_layout("passwd"))?;
929929
let buf = this.read_pointer(buf)?;
930930
let buflen = this.read_target_usize(buflen)?;
931-
let result = this.deref_pointer(result)?;
931+
let result = this.deref_pointer_as(result, this.machine.layouts.mut_raw_ptr)?;
932932

933933
// Must be for "us".
934934
if uid != UID {

src/shims/unix/fs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,15 +1253,15 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
12531253
}
12541254
_ => unreachable!(),
12551255
}
1256-
1257-
let result_place = this.deref_pointer(result_op)?;
1256+
let result_place = this.deref_pointer_as(result_op, this.machine.layouts.mut_raw_ptr)?;
12581257
this.write_scalar(this.read_scalar(entry_op)?, &result_place)?;
12591258

12601259
Scalar::from_i32(0)
12611260
}
12621261
None => {
12631262
// end of stream: return 0, assign *result=NULL
1264-
this.write_null(&this.deref_pointer(result_op)?)?;
1263+
let result_place = this.deref_pointer_as(result_op, this.machine.layouts.mut_raw_ptr)?;
1264+
this.write_null(&result_place)?;
12651265
Scalar::from_i32(0)
12661266
}
12671267
Some(Err(e)) => {

src/shims/unix/macos/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
3030
'tcx: 'a,
3131
{
3232
let this = self.eval_context_mut();
33-
let lock = this.deref_pointer(lock_ptr)?;
33+
let lock = this.deref_pointer_as(lock_ptr, this.libc_ty_layout("os_unfair_lock_s"))?;
3434
this.lazy_sync_get_data(
3535
&lock,
3636
Size::ZERO, // offset for init tracking

src/shims/unix/solarish/foreign_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
163163
throw_unsup_format!("pset_info is only supported with list==NULL");
164164
}
165165

166-
let cpus = this.deref_pointer(cpus)?;
166+
let cpus = this.deref_pointer_as(cpus, this.machine.layouts.u32)?;
167167
this.write_scalar(Scalar::from_u32(this.machine.num_cpus), &cpus)?;
168168
this.write_null(dest)?;
169169
}

src/shims/unix/unnamed_socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
362362
let domain = this.read_scalar(domain)?.to_i32()?;
363363
let mut flags = this.read_scalar(type_)?.to_i32()?;
364364
let protocol = this.read_scalar(protocol)?.to_i32()?;
365-
let sv = this.deref_pointer(sv)?;
365+
let sv = this.deref_pointer_as(sv, this.machine.layouts.i32)?;
366366

367367
let mut is_sock_nonblock = false;
368368

src/shims/windows/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
2929
let thread = if this.ptr_is_null(this.read_pointer(thread_op)?)? {
3030
None
3131
} else {
32-
let thread_info_place = this.deref_pointer(thread_op)?;
32+
let thread_info_place = this.deref_pointer_as(thread_op, this.machine.layouts.u32)?;
3333
Some(thread_info_place)
3434
};
3535

0 commit comments

Comments
 (0)