Skip to content

Commit c8df017

Browse files
committed
Move functions to eval libc constants to helpers
1 parent 976c976 commit c8df017

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/helpers.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
291291
}
292292
}
293293
}
294+
/// Helper function to get a `libc` constant as a `Scalar`.
295+
fn eval_libc(&mut self, name: &str) -> InterpResult<'tcx, Scalar<Tag>> {
296+
self.eval_context_mut()
297+
.eval_path_scalar(&["libc", name])?
298+
.ok_or_else(|| err_unsup_format!("Path libc::{} cannot be resolved.", name).into())
299+
.and_then(|scalar| scalar.not_undef())
300+
}
301+
/// Helper function to get a `libc` constant as an `i32`.
302+
fn eval_libc_i32(&mut self, name: &str) -> InterpResult<'tcx, i32> {
303+
self.eval_libc(name).and_then(|scalar| scalar.to_i32())
304+
}
294305
}

src/shims/foreign_items.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -981,17 +981,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
981981
return Ok(None);
982982
}
983983

984-
fn eval_libc(&mut self, name: &str) -> InterpResult<'tcx, Scalar<Tag>> {
985-
self.eval_context_mut()
986-
.eval_path_scalar(&["libc", name])?
987-
.ok_or_else(|| err_unsup_format!("Path libc::{} cannot be resolved.", name).into())
988-
.and_then(|scalar| scalar.not_undef())
989-
}
990-
991-
fn eval_libc_i32(&mut self, name: &str) -> InterpResult<'tcx, i32> {
992-
self.eval_libc(name).and_then(|scalar| scalar.to_i32())
993-
}
994-
995984
fn set_last_error(&mut self, scalar: Scalar<Tag>) -> InterpResult<'tcx> {
996985
let this = self.eval_context_mut();
997986
let tcx = &{ this.tcx.tcx };

0 commit comments

Comments
 (0)