Auto merge of #3880 - RalfJung:sync, r=RalfJung
add non-portable linux pthread initializers to layout sanity check Also, turns out we can enable all pthread tests on Solarish.
This commit is contained in:
commit
9621058b7b
2 changed files with 25 additions and 12 deletions
|
|
@ -150,8 +150,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 available-parallelism libc-time tls
|
||||
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX threadname pthread-sync available-parallelism libc-time tls
|
||||
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX threadname pthread available-parallelism libc-time tls
|
||||
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX threadname pthread available-parallelism libc-time tls
|
||||
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
|
||||
|
|
|
|||
|
|
@ -96,15 +96,28 @@ fn mutex_id_offset<'tcx>(ecx: &MiriInterpCx<'tcx>) -> InterpResult<'tcx, u64> {
|
|||
// recursive or error checking mutexes. We should also add thme in this sanity check.
|
||||
static SANITY: AtomicBool = AtomicBool::new(false);
|
||||
if !SANITY.swap(true, Ordering::Relaxed) {
|
||||
let static_initializer = ecx.eval_path(&["libc", "PTHREAD_MUTEX_INITIALIZER"]);
|
||||
let id_field = static_initializer
|
||||
.offset(Size::from_bytes(offset), ecx.machine.layouts.u32, ecx)
|
||||
.unwrap();
|
||||
let id = ecx.read_scalar(&id_field).unwrap().to_u32().unwrap();
|
||||
assert_eq!(
|
||||
id, 0,
|
||||
"PTHREAD_MUTEX_INITIALIZER is incompatible with our pthread_mutex layout: id is not 0"
|
||||
);
|
||||
let check_static_initializer = |name| {
|
||||
let static_initializer = ecx.eval_path(&["libc", name]);
|
||||
let id_field = static_initializer
|
||||
.offset(Size::from_bytes(offset), ecx.machine.layouts.u32, ecx)
|
||||
.unwrap();
|
||||
let id = ecx.read_scalar(&id_field).unwrap().to_u32().unwrap();
|
||||
assert_eq!(id, 0, "{name} is incompatible with our pthread_mutex layout: id is not 0");
|
||||
};
|
||||
|
||||
check_static_initializer("PTHREAD_MUTEX_INITIALIZER");
|
||||
// Check non-standard initializers.
|
||||
match &*ecx.tcx.sess.target.os {
|
||||
"linux" => {
|
||||
check_static_initializer("PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP");
|
||||
check_static_initializer("PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP");
|
||||
check_static_initializer("PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP");
|
||||
}
|
||||
"illumos" | "solaris" | "macos" => {
|
||||
// No non-standard initializers.
|
||||
}
|
||||
os => throw_unsup_format!("`pthread_mutex` is not supported on {os}"),
|
||||
}
|
||||
}
|
||||
|
||||
Ok(offset)
|
||||
|
|
@ -167,7 +180,7 @@ fn kind_from_static_initializer<'tcx>(
|
|||
mutex.offset(Size::from_bytes(offset), ecx.machine.layouts.i32, ecx)?;
|
||||
ecx.read_scalar(&kind_place)?.to_i32()?
|
||||
}
|
||||
| "illumos" | "solaris" | "macos" => ecx.eval_libc_i32("PTHREAD_MUTEX_DEFAULT"),
|
||||
"illumos" | "solaris" | "macos" => ecx.eval_libc_i32("PTHREAD_MUTEX_DEFAULT"),
|
||||
os => throw_unsup_format!("`pthread_mutex` is not supported on {os}"),
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue