throw_ub_format!("incorrect number of arguments: got {}, expected {}", args.len(), N)
}
-/// Strip linker suffixes (seen on 32-bit macOS).
-pub fn strip_linker_suffix(link_name: &str) -> &str {
- link_name.trim_end_matches("$UNIX2003")
-}
-
pub fn isolation_abort_error(name: &str) -> InterpResult<'static> {
throw_machine_stop!(TerminationInfo::UnsupportedInIsolation(format!(
"{} not available when isolation is enabled",
use super::backtrace::EvalContextExt as _;
use crate::*;
-use helpers::strip_linker_suffix;
/// Returned by `emulate_foreign_item_by_name`.
pub enum EmulateByNameResult {
.first_attr_value_str_by_name(&attrs, sym::link_name)
.unwrap_or_else(|| this.tcx.item_name(def_id));
let link_name = link_name_sym.as_str();
- let link_name = strip_linker_suffix(&link_name);
let tcx = this.tcx.tcx;
// First: functions that diverge.
let (dest, ret) = match ret {
- None => match link_name {
+ None => match &*link_name {
"miri_start_panic" => {
// `check_shim` happens inside `handle_miri_start_panic`.
this.handle_miri_start_panic(abi, link_name_sym, args, unwind)?;
// Here we dispatch all the shims for foreign functions. If you have a platform specific
// shim, add it to the corresponding submodule.
- let shim_name = link_name.as_str();
- let shim_name = strip_linker_suffix(&shim_name);
- match shim_name {
+ match &*link_name.as_str() {
// Miri-specific extern functions
"miri_static_root" => {
let &[ref ptr] = this.check_shim(abi, Abi::Rust, link_name, args)?;
let &[ref f] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
// FIXME: Using host floats.
let f = f32::from_bits(this.read_scalar(f)?.to_u32()?);
- let f = match shim_name {
+ let f = match &*link_name.as_str() {
"cbrtf" => f.cbrt(),
"coshf" => f.cosh(),
"sinhf" => f.sinh(),
// FIXME: Using host floats.
let f1 = f32::from_bits(this.read_scalar(f1)?.to_u32()?);
let f2 = f32::from_bits(this.read_scalar(f2)?.to_u32()?);
- let n = match shim_name {
+ let n = match &*link_name.as_str() {
"_hypotf" | "hypotf" => f1.hypot(f2),
"atan2f" => f1.atan2(f2),
_ => bug!(),
let &[ref f] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
// FIXME: Using host floats.
let f = f64::from_bits(this.read_scalar(f)?.to_u64()?);
- let f = match shim_name {
+ let f = match &*link_name.as_str() {
"cbrt" => f.cbrt(),
"cosh" => f.cosh(),
"sinh" => f.sinh(),
// FIXME: Using host floats.
let f1 = f64::from_bits(this.read_scalar(f1)?.to_u64()?);
let f2 = f64::from_bits(this.read_scalar(f2)?.to_u64()?);
- let n = match shim_name {
+ let n = match &*link_name.as_str() {
"_hypot" | "hypot" => f1.hypot(f2),
"atan2" => f1.atan2(f2),
_ => bug!(),
use rustc_target::spec::abi::Abi;
use crate::*;
-use helpers::strip_linker_suffix;
use shims::foreign_items::EmulateByNameResult;
use shims::posix::fs::EvalContextExt as _;
use shims::posix::sync::EvalContextExt as _;
) -> InterpResult<'tcx, EmulateByNameResult> {
let this = self.eval_context_mut();
- match strip_linker_suffix(&link_name.as_str()) {
+ match &*link_name.as_str() {
// Environment related shims
"getenv" => {
let &[ref name] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
use rustc_target::spec::abi::Abi;
use crate::*;
-use helpers::strip_linker_suffix;
use shims::foreign_items::EmulateByNameResult;
use shims::posix::fs::EvalContextExt as _;
use shims::posix::linux::sync::futex;
) -> InterpResult<'tcx, EmulateByNameResult> {
let this = self.eval_context_mut();
- match strip_linker_suffix(&link_name.as_str()) {
+ match &*link_name.as_str() {
// errno
"__errno_location" => {
let &[] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
use rustc_target::spec::abi::Abi;
use crate::*;
-use helpers::strip_linker_suffix;
use shims::foreign_items::EmulateByNameResult;
use shims::posix::fs::EvalContextExt as _;
use shims::posix::thread::EvalContextExt as _;
) -> InterpResult<'tcx, EmulateByNameResult> {
let this = self.eval_context_mut();
- match strip_linker_suffix(&link_name.as_str()) {
+ match &*link_name.as_str() {
// errno
"__error" => {
let &[] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;