From f4272716f44d6470ef7dbb6b2bcf55ff736bcf83 Mon Sep 17 00:00:00 2001 From: Kamil Rytarowski Date: Mon, 18 Apr 2016 03:55:53 +0200 Subject: [PATCH] Implement mono_threads_core_set_name() on NetBSD (#2914) Part of man-page showing this interface: PTHREAD_GETNAME_NP(3) Library Functions Manual PTHREAD_GETNAME_NP(3) NAME pthread_getname_np - get and set descriptive name of a thread LIBRARY POSIX Threads Library (libpthread, -lpthread) SYNOPSIS #include int pthread_getname_np(pthread_t thread, char *name, size_t len); int pthread_setname_np(pthread_t thread, const char *name, void *arg); -- pthread_setname_np(3) --- mono/utils/mono-threads-posix.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mono/utils/mono-threads-posix.c b/mono/utils/mono-threads-posix.c index 7fe86b96273..395fdb5bdab 100644 --- a/mono/utils/mono-threads-posix.c +++ b/mono/utils/mono-threads-posix.c @@ -296,6 +296,16 @@ mono_threads_core_set_name (MonoNativeThreadId tid, const char *name) n [62] = '\0'; pthread_setname_np (n); } +#elif defined (__NetBSD__) + if (!name) { + pthread_setname_np (tid, "%s", (void*)""); + } else { + char n [PTHREAD_MAX_NAMELEN_NP]; + + strncpy (n, name, PTHREAD_MAX_NAMELEN_NP); + n [PTHREAD_MAX_NAMELEN_NP - 1] = '\0'; + pthread_setname_np (tid, "%s", (void*)n); + } #elif defined (HAVE_PTHREAD_SETNAME_NP) if (!name) { pthread_setname_np (tid, ""); -- 2.25.1