solaris add suport for threadname. · rust-lang/rust@7f5e0aa
11use rustc_span::Symbol;
22use rustc_target::spec::abi::Abi;
334+use crate::shims::unix::*;
45use crate::*;
566-pub fn is_dyn_sym(_name: &str) -> bool {
7-false
7+pub fn is_dyn_sym(name: &str) -> bool {
8+matches!(name, "pthread_setname_np")
89}
9101011impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriInterpCx<'mir, 'tcx> {}
@@ -18,6 +19,31 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
1819) -> InterpResult<'tcx, EmulateItemResult> {
1920let this = self.eval_context_mut();
2021match link_name.as_str() {
22+// Threading
23+"pthread_setname_np" => {
24+let [thread, name] =
25+ this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
26+// THREAD_NAME_MAX allows a thread name of 31+1 length
27+// https://github.com/illumos/illumos-gate/blob/7671517e13b8123748eda4ef1ee165c6d9dba7fe/usr/src/uts/common/sys/thread.h#L613
28+let max_len = 32;
29+let res = this.pthread_setname_np(
30+ this.read_scalar(thread)?,
31+ this.read_scalar(name)?,
32+ max_len,
33+)?;
34+ this.write_scalar(res, dest)?;
35+}
36+"pthread_getname_np" => {
37+let [thread, name, len] =
38+ this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
39+let res = this.pthread_getname_np(
40+ this.read_scalar(thread)?,
41+ this.read_scalar(name)?,
42+ this.read_scalar(len)?,
43+)?;
44+ this.write_scalar(res, dest)?;
45+}
46+2147// Miscellaneous
2248"___errno" => {
2349let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;