]> git.lizzy.rs Git - rust.git/blobdiff - src/shims/os_str.rs
Support `gettimeofday` on more than macos
[rust.git] / src / shims / os_str.rs
index 83bb344982c2a56aceed4e7248c803b7842ef0c8..d6669b21a731a8fde8b7e59d5d964bb7d3881b1e 100644 (file)
@@ -1,5 +1,4 @@
 use std::borrow::Cow;
-use std::convert::TryFrom;
 use std::ffi::{OsStr, OsString};
 use std::iter;
 use std::path::{Path, PathBuf};
@@ -9,7 +8,8 @@
 #[cfg(windows)]
 use std::os::windows::ffi::{OsStrExt, OsStringExt};
 
-use rustc_target::abi::{Align, LayoutOf, Size};
+use rustc_middle::ty::layout::LayoutOf;
+use rustc_target::abi::{Align, Size};
 
 use crate::*;
 
@@ -78,7 +78,7 @@ pub fn u16vec_to_osstring<'tcx, 'a>(u16_vec: Vec<u16>) -> InterpResult<'tcx, OsS
             Ok(OsString::from_wide(&u16_vec[..]))
         }
         #[cfg(not(windows))]
-        pub fn u16vec_to_osstring<'tcx, 'a>(u16_vec: Vec<u16>) -> InterpResult<'tcx, OsString> {
+        pub fn u16vec_to_osstring<'tcx>(u16_vec: Vec<u16>) -> InterpResult<'tcx, OsString> {
             let s = String::from_utf16(&u16_vec[..])
                 .map_err(|_| err_unsup_format!("{:?} is not a valid utf-16 string", u16_vec))?;
             Ok(s.into())
@@ -107,8 +107,7 @@ fn write_os_str_to_c_str(
             return Ok((false, string_length));
         }
         self.eval_context_mut()
-            .memory
-            .write_bytes(ptr, bytes.iter().copied().chain(iter::once(0u8)))?;
+            .write_bytes_ptr(ptr, bytes.iter().copied().chain(iter::once(0u8)))?;
         Ok((true, string_length))
     }
 
@@ -151,8 +150,7 @@ fn os_str_to_u16vec<'tcx>(os_str: &OsStr) -> InterpResult<'tcx, Vec<u16>> {
         let size2 = Size::from_bytes(2);
         let this = self.eval_context_mut();
         let mut alloc = this
-            .memory
-            .get_mut(ptr, size2 * string_length, Align::from_bytes(2).unwrap())?
+            .get_ptr_alloc_mut(ptr, size2 * string_length, Align::from_bytes(2).unwrap())?
             .unwrap(); // not a ZST, so we will get a result
         for (offset, wchar) in u16_vec.into_iter().chain(iter::once(0x0000)).enumerate() {
             let offset = u64::try_from(offset).unwrap();