diff --git a/src/helpers.rs b/src/helpers.rs
index b494e85075c4..134f556bf120 100644
--- a/src/helpers.rs
+++ b/src/helpers.rs
@@ -493,6 +493,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
)
}
+ /// Helper function used inside the shims of foreign functions to assert that the target OS
+ /// is part of the UNIX family. It panics showing a message with the `name` of the foreign function
+ /// if this is not the case.
+ fn assert_target_os_is_unix(&self, name: &str) {
+ assert!(
+ target_os_is_unix(self.eval_context_ref().tcx.sess.target.os.as_ref()),
+ "`{}` is only available for supported UNIX family targets",
+ name,
+ );
+ }
+
/// Get last error variable as a place, lazily allocating thread-local storage for it if
/// necessary.
fn last_error_place(&mut self) -> InterpResult<'tcx, MPlaceTy<'tcx, Tag>> {
diff --git a/src/shims/env.rs b/src/shims/env.rs
index 91acff40fe16..85ecd2b719f2 100644
--- a/src/shims/env.rs
+++ b/src/shims/env.rs
@@ -114,11 +114,7 @@ impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mi
pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> {
fn getenv(&mut self, name_op: &OpTy<'tcx, Tag>) -> InterpResult<'tcx, Pointer