Skip to content

Commit ed2aec0

Browse files
committed
Fixed target OS condition in gettid
1 parent 2efcdf4 commit ed2aec0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/helpers.rs

+14
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,20 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
741741
)
742742
}
743743

744+
/// Helper function used inside the shims of foreign functions to assert that the target OS
745+
/// is one of `target_oses`. It panics showing a message with the `name` of the foreign function
746+
/// if this is not the case.
747+
fn assert_target_os_is_one_of(&self, target_oses: &[&str], name: &str) {
748+
assert!(
749+
target_oses.contains(&self.eval_context_ref().tcx.sess.target.os.as_ref()),
750+
"`{name}` is only available on the {} target OS's",
751+
target_oses.iter().enumerate().map(|(i, t)| match i {
752+
0 => format!("`{t}`"),
753+
_ => format!(", `{t}`"),
754+
}).collect::<String>()
755+
)
756+
}
757+
744758
/// Helper function used inside the shims of foreign functions to assert that the target OS
745759
/// is part of the UNIX family. It panics showing a message with the `name` of the foreign function
746760
/// if this is not the case.

src/shims/unix/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
284284

285285
fn linux_gettid(&mut self) -> InterpResult<'tcx, Scalar> {
286286
let this = self.eval_context_ref();
287-
this.assert_target_os("linux", "gettid");
287+
this.assert_target_os_is_one_of(&["linux", "android"], "gettid");
288288

289289
let index = this.machine.threads.active_thread().to_u32();
290290

0 commit comments

Comments
 (0)