Skip to content

Commit d2385cb

Browse files
committed
implement setting the thread name on freebsd
1 parent db2c119 commit d2385cb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

ci.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ case $HOST_TARGET in
8383
MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests
8484
MIRI_TEST_TARGET=aarch64-apple-darwin run_tests
8585
MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests
86-
MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec data_race env/var
86+
MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple atomic data_race env/var
8787
MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec
8888
MIRI_TEST_TARGET=thumbv7em-none-eabihf MIRI_NO_STD=1 run_tests_minimal no_std # no_std embedded architecture
8989
;;

src/shims/unix/freebsd/foreign_items.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use rustc_target::spec::abi::Abi;
33

44
use crate::*;
55
use shims::foreign_items::EmulateByNameResult;
6+
use shims::unix::thread::EvalContextExt as _;
67

78
impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
89

@@ -16,12 +17,21 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
1617
) -> InterpResult<'tcx, EmulateByNameResult<'mir, 'tcx>> {
1718
let this = self.eval_context_mut();
1819
match link_name.as_str() {
19-
// Linux's `pthread_getattr_np` equivalent
20+
// Threading
2021
"pthread_attr_get_np" if this.frame_in_std() => {
2122
let [_thread, _attr] =
2223
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
2324
this.write_null(dest)?;
2425
}
26+
"pthread_set_name_np" => {
27+
let [thread, name] =
28+
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
29+
let res = this.pthread_setname_np(
30+
this.read_scalar(thread)?.check_init()?,
31+
this.read_scalar(name)?.check_init()?,
32+
)?;
33+
this.write_scalar(res, dest)?;
34+
}
2535

2636
// errno
2737
"__error" => {

0 commit comments

Comments
 (0)