ref: fa32f2de759a658b039e15aaa290e20e7ce874a2
parent: 6c3e85de57884820ee5f2a4e5cd8ff7a2ee73b79
author: Henrik Gramner <[email protected]>
date: Mon Jul 29 11:46:32 EDT 2019
Set thread names on MacOS
--- a/meson.build
+++ b/meson.build
@@ -85,8 +85,13 @@
optional_arguments = []
# Define _POSIX_C_SOURCE to POSIX.1–2001 (IEEE Std 1003.1-2001)
-test_args += '-D_POSIX_C_SOURCE=200112L'
+test_args += '-D_POSIX_C_SOURCE=200112L'
add_project_arguments('-D_POSIX_C_SOURCE=200112L', language: 'c')
+
+if host_machine.system() == 'darwin'
+ test_args += '-D_DARWIN_C_SOURCE'
+ add_project_arguments('-D_DARWIN_C_SOURCE', language: 'c')
+endif
if host_machine.system() == 'windows'
cdata.set('_WIN32_WINNT', '0x0601')
--- a/src/thread.h
+++ b/src/thread.h
@@ -138,10 +138,16 @@
#include <sys/prctl.h>
-static inline void dav1d_set_thread_name(const char* name) {
+static inline void dav1d_set_thread_name(const char *const name) {
prctl(PR_SET_NAME, name);
}
+#elif defined(__APPLE__)
+
+static inline void dav1d_set_thread_name(const char *const name) {
+ pthread_setname_np(name);
+}
+
#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#if defined(__FreeBSD__)
@@ -151,13 +157,13 @@
#endif
#include <pthread_np.h>
-static inline void dav1d_set_thread_name(const char* name) {
+static inline void dav1d_set_thread_name(const char *const name) {
pthread_set_name_np(pthread_self(), name);
}
#elif defined(__NetBSD__)
-static inline void dav1d_set_thread_name(const char* name) {
+static inline void dav1d_set_thread_name(const char *const name) {
pthread_setname_np(pthread_self(), "%s", (void*)name);
}