diff options
| author | bors <bors@rust-lang.org> | 2022-08-11 18:05:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-08-11 18:05:55 +0000 |
| commit | 20ffea6938b5839c390252e07940b99e3b6a889a (patch) | |
| tree | 2f04efd7c69095fca1a6949ae82cc43f80adeb4c /library/std/src/sys/unix/thread.rs | |
| parent | aeb5067967ef58e4a324b19dd0dba2f385d5959f (diff) | |
| parent | f583bf611dcda66a5fd9845c8e0e7293b0053ece (diff) | |
| download | rust-20ffea6938b5839c390252e07940b99e3b6a889a.tar.gz rust-20ffea6938b5839c390252e07940b99e3b6a889a.zip | |
Auto merge of #100416 - Dylan-DPC:rollup-m344lh1, r=Dylan-DPC
Rollup of 11 pull requests Successful merges: - #92744 (Check if enum from foreign crate has any non exhaustive variants when attempting a cast) - #99110 (Determine match_has_guard from candidates instead of looking up thir table again) - #100184 (Stabilize ptr_const_cast) - #100192 ( Remove duplicated temporaries creating during box derefs elaboration) - #100232 (Do not consider method call receiver as an argument in AST.) - #100287 (linux: Use `pthread_setname_np` instead of `prctl`) - #100351 (Use `&mut Diagnostic` instead of `&mut DiagnosticBuilder` unless needed) - #100370 (Remove more Clean trait implementations) - #100391 (Improve size assertions) - #100398 (Improve `-Zhir-stats`) - #100403 (Improve error messages when running rustdoc GUI tests) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src/sys/unix/thread.rs')
| -rw-r--r-- | library/std/src/sys/unix/thread.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index 36a3fa6023b..7db3065dee0 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -116,11 +116,9 @@ impl Thread { debug_assert_eq!(ret, 0); } - #[cfg(any(target_os = "linux", target_os = "android"))] + #[cfg(target_os = "android")] pub fn set_name(name: &CStr) { const PR_SET_NAME: libc::c_int = 15; - // pthread wrapper only appeared in glibc 2.12, so we use syscall - // directly. unsafe { libc::prctl( PR_SET_NAME, @@ -132,6 +130,14 @@ impl Thread { } } + #[cfg(target_os = "linux")] + pub fn set_name(name: &CStr) { + unsafe { + // Available since glibc 2.12, musl 1.1.16, and uClibc 1.0.20. + libc::pthread_setname_np(libc::pthread_self(), name.as_ptr()); + } + } + #[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd"))] pub fn set_name(name: &CStr) { unsafe { |
