platform -> target

This commit is contained in:
Ralf Jung 2020-03-22 08:51:15 +01:00
parent dece5bc4ee
commit d85f09c4e4
13 changed files with 33 additions and 33 deletions

View File

@ -190,7 +190,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
/// Returns `Some(return_code)` if program executed completed.
/// Returns `None` if an evaluation error occured.
pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) -> Option<i64> {
// FIXME: We always ignore leaks on some platforms where we do not
// FIXME: We always ignore leaks on some OSs where we do not
// correctly implement TLS destructors.
let target_os = tcx.sess.target.target.target_os.as_str();
let ignore_leaks = config.ignore_leaks || target_os == "windows" || target_os == "macos";

View File

@ -374,16 +374,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
}
Ok(())
}
/// Helper function used inside the shims of foreign functions to assert that the target
/// platform is `platform`. It panics showing a message with the `name` of the foreign function
/// Helper function used inside the shims of foreign functions to assert that the target OS
/// is `target_os`. It panics showing a message with the `name` of the foreign function
/// if this is not the case.
fn assert_platform(&self, platform: &str, name: &str) {
fn assert_target_os(&self, target_os: &str, name: &str) {
assert_eq!(
self.eval_context_ref().tcx.sess.target.target.target_os,
platform,
"`{}` is only available on the `{}` platform",
target_os,
"`{}` is only available on the `{}` target OS",
name,
platform,
target_os,
)
}

View File

@ -126,7 +126,7 @@ impl MemoryExtra {
.insert(Symbol::intern("environ"), this.machine.env_vars.environ.unwrap().ptr.assert_ptr().alloc_id)
.unwrap_none();
}
_ => {} // No "extern statics" supported on this platform
_ => {} // No "extern statics" supported on this target
}
Ok(())
}

View File

@ -437,7 +437,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
_ => match this.tcx.sess.target.target.target_os.as_str() {
"linux" | "macos" => return posix::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
"windows" => return windows::EvalContextExt::emulate_foreign_item_by_name(this, link_name, args, dest, ret),
target => throw_unsup_format!("the {} target platform is not supported", target),
target => throw_unsup_format!("the target `{}` is not supported", target),
}
};

View File

@ -66,9 +66,9 @@ impl FileHandler {
impl<'mir, 'tcx> EvalContextExtPrivate<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
trait EvalContextExtPrivate<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> {
/// Emulate `stat` or `lstat` on the `macos` platform. This function is not intended to be
/// Emulate `stat` or `lstat` on `macos`. This function is not intended to be
/// called directly from `emulate_foreign_item_by_name`, so it does not check if isolation is
/// disabled or if the target platform is the correct one. Please use `macos_stat` or
/// disabled or if the target OS is the correct one. Please use `macos_stat` or
/// `macos_lstat` instead.
fn macos_stat_or_lstat(
&mut self,
@ -114,7 +114,7 @@ trait EvalContextExtPrivate<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, '
let blksize_t_layout = this.libc_ty_layout("blksize_t")?;
let uint32_t_layout = this.libc_ty_layout("uint32_t")?;
// We need to add 32 bits of padding after `st_rdev` if we are on a 64-bit platform.
// We need to add 32 bits of padding after `st_rdev` if we are on a 64-bit target.
let pad_layout = if this.tcx.sess.target.ptr_width == 64 {
uint32_t_layout
} else {
@ -258,10 +258,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
let o_wronly = this.eval_libc_i32("O_WRONLY")?;
let o_rdwr = this.eval_libc_i32("O_RDWR")?;
// The first two bits of the flag correspond to the access mode in linux, macOS and
// windows. We need to check that in fact the access mode flags for the current platform
// only use these two bits, otherwise we are in an unsupported platform and should error.
// windows. We need to check that in fact the access mode flags for the current target
// only use these two bits, otherwise we are in an unsupported target and should error.
if (o_rdonly | o_wronly | o_rdwr) & !0b11 != 0 {
throw_unsup_format!("access mode flags on this platform are unsupported");
throw_unsup_format!("access mode flags on this target are unsupported");
}
let mut writable = true;
@ -574,7 +574,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
buf_op: OpTy<'tcx, Tag>,
) -> InterpResult<'tcx, i32> {
let this = self.eval_context_mut();
this.assert_platform("macos", "stat");
this.assert_target_os("macos", "stat");
this.check_no_isolation("stat")?;
// `stat` always follows symlinks.
this.macos_stat_or_lstat(true, path_op, buf_op)
@ -587,7 +587,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
buf_op: OpTy<'tcx, Tag>,
) -> InterpResult<'tcx, i32> {
let this = self.eval_context_mut();
this.assert_platform("macos", "lstat");
this.assert_target_os("macos", "lstat");
this.check_no_isolation("lstat")?;
this.macos_stat_or_lstat(false, path_op, buf_op)
}
@ -599,7 +599,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
) -> InterpResult<'tcx, i32> {
let this = self.eval_context_mut();
this.assert_platform("macos", "fstat");
this.assert_target_os("macos", "fstat");
this.check_no_isolation("fstat")?;
let fd = this.read_scalar(fd_op)?.to_i32()?;
@ -621,7 +621,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
) -> InterpResult<'tcx, i32> {
let this = self.eval_context_mut();
this.assert_platform("linux", "statx");
this.assert_target_os("linux", "statx");
this.check_no_isolation("statx")?;
let statxbuf_scalar = this.read_scalar(statxbuf_op)?.not_undef()?;
@ -685,7 +685,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
// the `_mask_op` paramter specifies the file information that the caller requested.
// However `statx` is allowed to return information that was not requested or to not
// return information that was requested. This `mask` represents the information we can
// actually provide in any host platform.
// actually provide for any target.
let mut mask =
this.eval_libc("STATX_TYPE")?.to_u32()? | this.eval_libc("STATX_SIZE")?.to_u32()?;
@ -880,7 +880,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
) -> InterpResult<'tcx, i32> {
let this = self.eval_context_mut();
this.assert_platform("linux", "readdir64_r");
this.assert_target_os("linux", "readdir64_r");
this.check_no_isolation("readdir64_r")?;
let dirp = this.read_scalar(dirp_op)?.to_machine_usize(this)?;
@ -967,7 +967,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
) -> InterpResult<'tcx, i32> {
let this = self.eval_context_mut();
this.assert_platform("macos", "readdir_r");
this.assert_target_os("macos", "readdir_r");
this.check_no_isolation("readdir_r")?;
let dirp = this.read_scalar(dirp_op)?.to_machine_usize(this)?;

View File

@ -32,11 +32,11 @@ pub struct CatchUnwindData<'tcx> {
impl<'mir, 'tcx> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> {
/// Check if panicking is supported on this platform, and give a good error otherwise.
/// Check if panicking is supported on this target, and give a good error otherwise.
fn check_panic_supported(&self) -> InterpResult<'tcx> {
match self.eval_context_ref().tcx.sess.target.target.target_os.as_str() {
"linux" | "macos" => Ok(()),
_ => throw_unsup_format!("panicking is not supported on this platform"),
_ => throw_unsup_format!("panicking is not supported on this target"),
}
}

View File

@ -20,7 +20,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
) -> InterpResult<'tcx, i32> {
let this = self.eval_context_mut();
this.assert_platform("linux", "clock_gettime");
this.assert_target_os("linux", "clock_gettime");
this.check_no_isolation("clock_gettime")?;
let clk_id = this.read_scalar(clk_id_op)?.to_i32()?;
@ -58,7 +58,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
) -> InterpResult<'tcx, i32> {
let this = self.eval_context_mut();
this.assert_platform("macos", "gettimeofday");
this.assert_target_os("macos", "gettimeofday");
this.check_no_isolation("gettimeofday")?;
// Using tz is obsolete and should always be null
@ -88,7 +88,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
fn mach_absolute_time(&self) -> InterpResult<'tcx, u64> {
let this = self.eval_context_ref();
this.assert_platform("macos", "mach_absolute_time");
this.assert_target_os("macos", "mach_absolute_time");
this.check_no_isolation("mach_absolute_time")?;
// This returns a u64, with time units determined dynamically by `mach_timebase_info`.

View File

@ -45,7 +45,7 @@ fn num_cpus() {
// FIXME: Remove this `cfg` once we fix https://github.com/rust-lang/miri/issues/1059.
// We cfg-gate the `should_panic` attribute and the `panic!` itself, so that the test
// stdout does not depend on the platform.
// stdout does not depend on the target.
#[test]
#[cfg_attr(not(windows), should_panic(expected="Explicit panic"))]
fn do_panic() { // In large, friendly letters :)

View File

@ -3,7 +3,7 @@
// Test that panics on Windows give a reasonable error message.
// error-pattern: panicking is not supported on this platform
// error-pattern: panicking is not supported on this target
fn main() {
core::panic!("this is {}", "Windows");
}

View File

@ -3,7 +3,7 @@
// Test that panics on Windows give a reasonable error message.
// error-pattern: panicking is not supported on this platform
// error-pattern: panicking is not supported on this target
fn main() {
std::panic!("this is Windows");
}

View File

@ -3,7 +3,7 @@
// Test that panics on Windows give a reasonable error message.
// error-pattern: panicking is not supported on this platform
// error-pattern: panicking is not supported on this target
#[allow(unconditional_panic)]
fn main() {
let _val = 1/0;

View File

@ -33,5 +33,5 @@ fn is_u64_aligned(u: &Tag<u64>) -> bool {
pub fn main() {
let x = mk_rec();
is_u64_aligned(&x.t); // the result of this is non-deterministic (even with a fixed seed, results vary between platforms)
is_u64_aligned(&x.t); // the result of this is non-deterministic (even with a fixed seed, results vary between targets)
}

View File

@ -2,7 +2,7 @@
use core::slice::memchr::{memchr, memrchr};
// test fallback implementations on all platforms
// test fallback implementations on all targets
fn matches_one() {
assert_eq!(Some(0), memchr(b'a', b"a"));
}