about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-05-26 20:45:36 +0000
committerbors <bors@rust-lang.org>2024-05-26 20:45:36 +0000
commitb531ca7ca809c3d393dfaf72f505c87ec36704da (patch)
tree51b11fee79aed9614889d8712d86610ea9bf4785 /src
parent09633536349491809d8e94dfbb9818f42e8bced2 (diff)
parentd3974fabfdfb58314d57ab96530b2e47b5eb110e (diff)
downloadrust-b531ca7ca809c3d393dfaf72f505c87ec36704da.tar.gz
rust-b531ca7ca809c3d393dfaf72f505c87ec36704da.zip
Auto merge of #3629 - devnexen:illumos_num_cpus, r=RalfJung
solarish platform: add support for available-parallelism.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/tools/miri/ci/ci.sh4
-rw-r--r--src/tools/miri/src/shims/unix/solarish/foreign_items.rs30
2 files changed, 32 insertions, 2 deletions
diff --git a/src/tools/miri/ci/ci.sh b/src/tools/miri/ci/ci.sh
index f97a611b364..67985f9b7d6 100755
--- a/src/tools/miri/ci/ci.sh
+++ b/src/tools/miri/ci/ci.sh
@@ -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
diff --git a/src/tools/miri/src/shims/unix/solarish/foreign_items.rs b/src/tools/miri/src/shims/unix/solarish/foreign_items.rs
index c4dfb147ed9..d852b3537aa 100644
--- a/src/tools/miri/src/shims/unix/solarish/foreign_items.rs
+++ b/src/tools/miri/src/shims/unix/solarish/foreign_items.rs
@@ -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 pset = this.read_scalar(pset)?.to_i32()?;
+                let tpe = this.read_pointer(tpe)?;
+                let list = this.read_pointer(list)?;
+
+                let ps_myid = this.eval_libc_i32("PS_MYID");
+                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)