summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcomex <comexk@gmail.com>2020-08-02 19:57:08 +0200
committercomex <comexk@gmail.com>2020-08-06 05:34:49 +0200
commitd37f0b29e26b0e6f655f801423ae6ba4f77fa9df (patch)
tree20ebd140e8b07c86976e57a2cc2b38bfffacaedd
parentMerge pull request #4489 from lioncash/typesafe (diff)
downloadyuzu-d37f0b29e26b0e6f655f801423ae6ba4f77fa9df.tar
yuzu-d37f0b29e26b0e6f655f801423ae6ba4f77fa9df.tar.gz
yuzu-d37f0b29e26b0e6f655f801423ae6ba4f77fa9df.tar.bz2
yuzu-d37f0b29e26b0e6f655f801423ae6ba4f77fa9df.tar.lz
yuzu-d37f0b29e26b0e6f655f801423ae6ba4f77fa9df.tar.xz
yuzu-d37f0b29e26b0e6f655f801423ae6ba4f77fa9df.tar.zst
yuzu-d37f0b29e26b0e6f655f801423ae6ba4f77fa9df.zip
-rw-r--r--src/common/thread.cpp12
-rw-r--r--src/core/cpu_manager.cpp2
2 files changed, 13 insertions, 1 deletions
diff --git a/src/common/thread.cpp b/src/common/thread.cpp
index 8e5935e6a..d2c1ac60d 100644
--- a/src/common/thread.cpp
+++ b/src/common/thread.cpp
@@ -2,6 +2,8 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include "common/common_funcs.h"
+#include "common/logging/log.h"
#include "common/thread.h"
#ifdef __APPLE__
#include <mach/mach.h>
@@ -19,6 +21,8 @@
#include <unistd.h>
#endif
+#include <string>
+
#ifdef __FreeBSD__
#define cpu_set_t cpuset_t
#endif
@@ -110,6 +114,14 @@ void SetCurrentThreadName(const char* name) {
pthread_set_name_np(pthread_self(), name);
#elif defined(__NetBSD__)
pthread_setname_np(pthread_self(), "%s", (void*)name);
+#elif defined(__linux__)
+ // Linux limits thread names to 15 characters and will outright reject any
+ // attempt to set a longer name with ERANGE.
+ std::string truncated(name, std::min(strlen(name), static_cast<size_t>(15)));
+ if (int e = pthread_setname_np(pthread_self(), truncated.c_str())) {
+ errno = e;
+ LOG_ERROR(Common, "Failed to set thread name to '{}': {}", truncated, GetLastErrorMsg());
+ }
#else
pthread_setname_np(pthread_self(), name);
#endif
diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp
index 358943429..03651e285 100644
--- a/src/core/cpu_manager.cpp
+++ b/src/core/cpu_manager.cpp
@@ -331,7 +331,7 @@ void CpuManager::RunThread(std::size_t core) {
system.RegisterCoreThread(core);
std::string name;
if (is_multicore) {
- name = "yuzu:CoreCPUThread_" + std::to_string(core);
+ name = "yuzu:CPUCore_" + std::to_string(core);
} else {
name = "yuzu:CPUThread";
}