about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-03-22 21:34:38 +0100
committerGitHub <noreply@github.com>2025-03-22 21:34:38 +0100
commit9a9859637a2d586cea8d99e5937abc4e078f47b1 (patch)
treebb68ea8cce3b2831e36c64faf61ca073f0c8cc0b /library/std/src/sys
parent8986c532c44d8973132833ff260db5c4a60c498e (diff)
parente5fc7d6a55fd3318f7e457bb27df0de3089dcc0a (diff)
downloadrust-9a9859637a2d586cea8d99e5937abc4e078f47b1.tar.gz
rust-9a9859637a2d586cea8d99e5937abc4e078f47b1.zip
Rollup merge of #138765 - Berrysoft:cygwin-thread-name, r=joboet
Fix Thread::set_name on cygwin

Just like Linux, Cygwin also sets a limitation to thread name.

https://github.com/cygwin/cygwin/blob/8e50c7af7c49819245739d6f626f6fecc394ef7f/winsup/cygwin/thread.cc#L3175
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/pal/unix/thread.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs
index bffe2536299..bb34c2fabe5 100644
--- a/library/std/src/sys/pal/unix/thread.rs
+++ b/library/std/src/sys/pal/unix/thread.rs
@@ -143,8 +143,8 @@ impl Thread {
     pub fn set_name(name: &CStr) {
         unsafe {
             cfg_if::cfg_if! {
-                if #[cfg(target_os = "linux")] {
-                    // Linux limits the allowed length of the name.
+                if #[cfg(any(target_os = "linux", target_os = "cygwin"))] {
+                    // Linux and Cygwin limits the allowed length of the name.
                     const TASK_COMM_LEN: usize = 16;
                     let name = truncate_cstr::<{ TASK_COMM_LEN }>(name);
                 } else {
@@ -346,6 +346,7 @@ impl Drop for Thread {
     target_os = "solaris",
     target_os = "illumos",
     target_os = "vxworks",
+    target_os = "cygwin",
     target_vendor = "apple",
 ))]
 fn truncate_cstr<const MAX_WITH_NUL: usize>(cstr: &CStr) -> [libc::c_char; MAX_WITH_NUL] {