solarish platform add supports for available-parallelism.

This commit is contained in:
David Carlier 2024-05-24 21:56:00 +00:00
parent 8e861c6c4c
commit 887c130863
2 changed files with 32 additions and 2 deletions

View file

@ -148,8 +148,8 @@ case $HOST_TARGET in
UNIX="panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there
TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname libc-time fs
TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname libc-time fs
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX threadname pthread-sync libc-time
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX threadname pthread-sync libc-time
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX threadname pthread-sync available-parallelism libc-time
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX threadname pthread-sync available-parallelism libc-time
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX
TEST_TARGET=wasm32-wasip2 run_tests_minimal empty_main wasm heap_alloc libc-mem
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal empty_main wasm

View file

@ -69,6 +69,36 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
this.write_null(dest)?;
}
"pset_info" => {
let [pset, tpe, cpus, list] =
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
// We do not need to handle the current process cpu mask, available_parallelism
// implementation pass null anyway. We only care for the number of
// cpus.
// https://docs.oracle.com/cd/E88353_01/html/E37841/pset-info-2.html
let ps_myid = this.eval_libc_i32("PS_MYID");
let pset = this.read_scalar(pset)?.to_i32()?;
let tpe = this.read_pointer(tpe)?;
let list = this.read_pointer(list)?;
if ps_myid != pset {
throw_unsup_format!("pset_info is only supported with pset==PS_MYID");
}
if !this.ptr_is_null(tpe)? {
throw_unsup_format!("pset_info is only supported with type==NULL");
}
if !this.ptr_is_null(list)? {
throw_unsup_format!("pset_info is only supported with list==NULL");
}
let cpus = this.deref_pointer(cpus)?;
this.write_scalar(Scalar::from_u32(this.machine.num_cpus), &cpus)?;
this.write_null(dest)?;
}
_ => return Ok(EmulateItemResult::NotSupported),
}
Ok(EmulateItemResult::NeedsReturn)