Skip to content

Commit e1c3d67

Browse files
committed
Revert "moving out sched_getaffinity interception from linux'shim, FreeBSD supporting it too."
This reverts commit c1a3f8576ea12b0bed68ad3dedf4069ca3d9816f.
1 parent 9d4eea1 commit e1c3d67

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

src/tools/miri/src/shims/unix/foreign_items.rs

-19
Original file line numberDiff line numberDiff line change
@@ -724,25 +724,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
724724
}
725725
}
726726

727-
"sched_getaffinity" => {
728-
// FreeBSD supports it as well since 13.1 (as a wrapper of cpuset_getaffinity)
729-
if !matches!(&*this.tcx.sess.target.os, "linux" | "freebsd") {
730-
throw_unsup_format!(
731-
"`sched_getaffinity` is not supported on {}",
732-
this.tcx.sess.target.os
733-
);
734-
}
735-
let [pid, cpusetsize, mask] =
736-
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
737-
this.read_scalar(pid)?.to_i32()?;
738-
this.read_target_usize(cpusetsize)?;
739-
this.deref_pointer_as(mask, this.libc_ty_layout("cpu_set_t"))?;
740-
// FIXME: we just return an error; `num_cpus` then falls back to `sysconf`.
741-
let einval = this.eval_libc("EINVAL");
742-
this.set_last_error(einval)?;
743-
this.write_scalar(Scalar::from_i32(-1), dest)?;
744-
}
745-
746727
// Platform-specific shims
747728
_ => {
748729
let target_os = &*this.tcx.sess.target.os;

src/tools/miri/src/shims/unix/linux/foreign_items.rs

+13
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,19 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
195195

196196
this.write_scalar(Scalar::from_i32(SIGRTMAX), dest)?;
197197
}
198+
"sched_getaffinity" => {
199+
// This shim isn't useful, aside from the fact that it makes `num_cpus`
200+
// fall back to `sysconf` where it will successfully determine the number of CPUs.
201+
let [pid, cpusetsize, mask] =
202+
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
203+
this.read_scalar(pid)?.to_i32()?;
204+
this.read_target_usize(cpusetsize)?;
205+
this.deref_pointer_as(mask, this.libc_ty_layout("cpu_set_t"))?;
206+
// FIXME: we just return an error.
207+
let einval = this.eval_libc("EINVAL");
208+
this.set_last_error(einval)?;
209+
this.write_scalar(Scalar::from_i32(-1), dest)?;
210+
}
198211

199212
// Incomplete shims that we "stub out" just to get pre-main initialization code to work.
200213
// These shims are enabled only when the caller is in the standard library.

0 commit comments

Comments
 (0)