ref: 4806492ac3813dbcca1b368c5ef431d8d078e706
parent: a0eb045cd4af0b43cd8a4d954a726048fa6bb85d
author: Jan Beich <jbeich@FreeBSD.org>
date: Thu Jul 18 14:36:58 EDT 2019
Set thread names on BSDs
--- a/src/thread.h
+++ b/src/thread.h
@@ -138,6 +138,25 @@
prctl(PR_SET_NAME, name);
}
+#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+
+#if defined(__FreeBSD__)
+ /* ALIGN from <sys/param.h> conflicts with ALIGN from "common/attributes.h" */
+#define _SYS_PARAM_H_
+#include <sys/types.h>
+#endif
+#include <pthread_np.h>
+
+static inline void dav1d_set_thread_name(const char* name) {
+ pthread_set_name_np(pthread_self(), name);
+}
+
+#elif defined(__NetBSD__)
+
+static inline void dav1d_set_thread_name(const char* name) {
+ pthread_setname_np(pthread_self(), "%s", (void*)name);
+}
+
#else
#define dav1d_set_thread_name(name)