void-packages/srcpkgs/PrusaSlicer/patches/0002-Replace-get_current_th...

31 lines
749 B
Diff

--- src/libslic3r/Thread.cpp.orig 2021-01-24 13:50:00.469444149 +0100
+++ src/libslic3r/Thread.cpp 2021-01-24 13:51:17.109443201 +0100
@@ -171,16 +171,27 @@ bool set_thread_name(boost::thread &thre
return true;
}
+#ifndef __GLIBC__
+thread_local char current_thread_name[16] = { 0 };
+#endif
+
bool set_current_thread_name(const char *thread_name)
{
+#ifndef __GLIBC__
+ strncpy(current_thread_name, thread_name, 15);
+#endif
pthread_setname_np(pthread_self(), thread_name);
return true;
}
std::optional<std::string> get_current_thread_name()
{
+#ifdef __GLIBC__
char buf[16];
return std::string(pthread_getname_np(pthread_self(), buf, 16) == 0 ? buf : "");
+#else
+ return std::string(current_thread_name);
+#endif
}
#endif