From 03742ea6c2dfd6f3d415cfe54873c596add3c70e Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 4 May 2024 18:24:44 +0100 Subject: [PATCH] changes from feedback --- README.md | 2 +- ci/ci.sh | 2 +- src/shims/unix/sync.rs | 13 +++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5898bffd92..33485c3785 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ degree documented below): - We have unofficial support (not maintained by the Miri team itself) for some further operating systems. - `freebsd`: **maintainer wanted**. Supports `std::env` and parts of `std::{thread, fs}`, but not `std::sync`. - `android`: **maintainer wanted**. Support very incomplete, but a basic "hello world" works. - - `solaris/illumos`: @devnexen. Support very incomplete, but a basic "hello world" works. + - `solaris/illumos`: maintained by @devnexen. Support very incomplete, but a basic "hello world" works. - `wasm`: **maintainer wanted**. Support very incomplete, not even standard output works, but an empty `main` function works. - For targets on other operating systems, Miri might fail before even reaching the `main` function. diff --git a/ci/ci.sh b/ci/ci.sh index 0cc326ca87..98dc3f7920 100755 --- a/ci/ci.sh +++ b/ci/ci.sh @@ -146,7 +146,7 @@ case $HOST_TARGET in MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-getentropy libc-getrandom libc-misc fs env num_cpus MIRI_TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-getentropy libc-getrandom libc-misc fs env num_cpus MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal $VERY_BASIC hello panic/panic - MIRI_TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $VERY_BASIC hello panic/panic + MIRI_TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $VERY_BASIC hello panic/panic pthread-sync MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal $VERY_BASIC wasm MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal $VERY_BASIC wasm MIRI_TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std diff --git a/src/shims/unix/sync.rs b/src/shims/unix/sync.rs index 65d0f8b0a4..9acac60209 100644 --- a/src/shims/unix/sync.rs +++ b/src/shims/unix/sync.rs @@ -68,11 +68,20 @@ fn mutexattr_set_kind<'mir, 'tcx: 'mir>( // (the kind has to be at this particular offset for compatibility with Linux's static initializer // macros, e.g. PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP.) +#[inline] +fn mutex_id_offset<'mir, 'tcx: 'mir>(ecx: &MiriInterpCx<'mir, 'tcx>) -> u64 { + if matches!(&*ecx.tcx.sess.target.os, "macos") { 4 } else { 0 } +} + fn mutex_get_id<'mir, 'tcx: 'mir>( ecx: &mut MiriInterpCx<'mir, 'tcx>, mutex_op: &OpTy<'tcx, Provenance>, ) -> InterpResult<'tcx, MutexId> { - ecx.mutex_get_or_create_id(mutex_op, ecx.libc_ty_layout("pthread_mutex_t"), 4) + ecx.mutex_get_or_create_id( + mutex_op, + ecx.libc_ty_layout("pthread_mutex_t"), + mutex_id_offset(ecx), + ) } fn mutex_reset_id<'mir, 'tcx: 'mir>( @@ -81,7 +90,7 @@ fn mutex_reset_id<'mir, 'tcx: 'mir>( ) -> InterpResult<'tcx, ()> { ecx.deref_pointer_and_write( mutex_op, - 4, + mutex_id_offset(ecx), Scalar::from_i32(0), ecx.libc_ty_layout("pthread_mutex_t"), ecx.machine.layouts.u32,