From 1b21161aacf69f0b9bd7951d7311f27a18322e86 Mon Sep 17 00:00:00 2001 From: Nawid3333 <102778966+Nawid3333@users.noreply.github.com> Date: Tue, 6 Oct 2026 23:18:48 +0200 Subject: [PATCH] kernel: fix the macOS build of host thread naming (#1122) * kernel: apply clang-format to pthread.cpp Output of the repository's pre-commit clang-format hook (v22.1.3) on this file; no code change. Co-Authored-By: Claude Opus 5.5 * kernel: fix the macOS build of host thread naming 199d0a9d (#1106) names guest threads on the host with the two-argument glibc pthread_setname_np(thread, name). KYTY_PLATFORM is KYTY_PLATFORM_LINUX on macOS too, so the macOS job now fails with "no matching function for call to 'pthread_setname_np'": Apple's version takes only the name and renames the calling thread. This code already runs on the new thread itself (it passes pthread_self()), so use the one-argument form on Apple with Apple's 63-character limit and keep the Linux call unchanged. Co-Authored-By: Claude Opus 5.5 * Remove formatting --------- Co-authored-by: Claude Opus 5.5 Co-authored-by: nmzik --- src/kernel/pthread.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/kernel/pthread.cpp b/src/kernel/pthread.cpp index 21be846ce..673a7dc72 100644 --- a/src/kernel/pthread.cpp +++ b/src/kernel/pthread.cpp @@ -3202,7 +3202,11 @@ static void* RunThread(void* arg) { thread->host_thread_id = os_thread_id; #if KYTY_PLATFORM == KYTY_PLATFORM_LINUX if (!thread->name.empty()) { +#if defined(__APPLE__) + pthread_setname_np(thread->name.substr(0, 63).c_str()); +#else pthread_setname_np(pthread_self(), thread->name.substr(0, 15).c_str()); +#endif } #endif