From 508df227e5f4820f1d600b72e626a620b2c714af Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Sat, 12 Oct 2019 19:48:18 -0500 Subject: [PATCH] Group libc helper functions --- src/helpers.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/helpers.rs b/src/helpers.rs index 892ba7b2401b..3012b1a95541 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -308,8 +308,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx self.eval_libc(name)?.to_i32() } + /// Helper function to get the `TyLayout` of a `libc` type + fn libc_ty_layout(&mut self, name: &str) -> InterpResult<'tcx, TyLayout<'tcx>> { + let this = self.eval_context_mut(); + let tcx = &{ this.tcx.tcx }; + let ty = this.resolve_path(&["libc", name])?.ty(*tcx); + this.layout_of(ty) + } + // Writes several `ImmTy`s contiguosly into memory. This is useful when you have to pack - // different values into an struct. + // different values into a struct. fn write_immediates( &mut self, ptr: &Pointer, @@ -335,11 +343,4 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx Ok(()) } - - fn libc_ty_layout(&mut self, name: &str) -> InterpResult<'tcx, TyLayout<'tcx>> { - let this = self.eval_context_mut(); - let tcx = &{ this.tcx.tcx }; - let ty = this.resolve_path(&["libc", name])?.ty(*tcx); - this.layout_of(ty) - } }