solaris add suport for threadname. · rust-lang/rust@7f5e0aa (original) (raw)

1

1

`use rustc_span::Symbol;

`

2

2

`use rustc_target::spec::abi::Abi;

`

3

3

``

``

4

`+

use crate::shims::unix::*;

`

4

5

`use crate::*;

`

5

6

``

6

``

`-

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")

`

8

9

`}

`

9

10

``

10

11

`impl<'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> {

`

18

19

`) -> InterpResult<'tcx, EmulateItemResult> {

`

19

20

`let this = self.eval_context_mut();

`

20

21

`match 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

+

21

47

`// Miscellaneous

`

22

48

`"___errno" => {

`

23

49

`let [] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;

`