[PATCH vkd3d v2 1/5] vkd3d: Fix pthread_setname_np(3) call on Mac OS.

Chip Davis cdavis at codeweavers.com
Fri Aug 3 16:12:19 CDT 2018


That function exists on Mac, but it only takes a single argument, the
thread's new name. That's OK for our purposes, since we were calling it
on pthread_self anyhow.

Signed-off-by: Chip Davis <cdavis at codeweavers.com>
---

Notes:
    Try 2: Pull the pthread_setname_np(3) call into a header.

 libs/vkd3d/command.c       |  4 +---
 libs/vkd3d/vkd3d_private.h | 11 +++++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c
index 4db9967..042d2f1 100644
--- a/libs/vkd3d/command.c
+++ b/libs/vkd3d/command.c
@@ -199,9 +199,7 @@ static void *vkd3d_fence_worker_main(void *arg)
     struct vkd3d_fence_worker *worker = arg;
     int rc;
 
-#ifdef HAVE_PTHREAD_SETNAME_NP
-    pthread_setname_np(pthread_self(), "vkd3d_worker");
-#endif
+	vkd3d_set_thread_name("vkd3d_worker");
 
     for (;;)
     {
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index 8efb930..b233d94 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -86,6 +86,17 @@ struct vkd3d_vulkan_info
     VkPhysicalDeviceSparseProperties sparse_properties;
 };
 
+static inline void vkd3d_set_thread_name(const char *name)
+{
+#ifdef HAVE_PTHREAD_SETNAME_NP
+#ifdef __APPLE__
+    pthread_setname_np(name);
+#else
+    pthread_setname_np(pthread_self(), name);
+#endif
+#endif
+}
+
 struct vkd3d_instance
 {
     VkInstance vk_instance;
-- 
2.18.0




More information about the wine-devel mailing list