mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-25 13:40:24 +01:00
util/u_thread: fix u_thread_setname for long names
"WSI swapchain queue", set by vulkan/wsi/x11, is longer than 15 characters. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10935>
This commit is contained in:
parent
7844bdadac
commit
62014aeccd
1 changed files with 9 additions and 1 deletions
|
|
@ -27,6 +27,7 @@
|
|||
#ifndef U_THREAD_H_
|
||||
#define U_THREAD_H_
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
|
@ -104,7 +105,14 @@ static inline void u_thread_setname( const char *name )
|
|||
{
|
||||
#if defined(HAVE_PTHREAD)
|
||||
#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS
|
||||
pthread_setname_np(pthread_self(), name);
|
||||
int ret = pthread_setname_np(pthread_self(), name);
|
||||
if (ret == ERANGE) {
|
||||
char buf[16];
|
||||
const size_t len = MIN2(strlen(name), ARRAY_SIZE(buf) - 1);
|
||||
memcpy(buf, name, len);
|
||||
buf[len] = '\0';
|
||||
pthread_setname_np(pthread_self(), buf);
|
||||
}
|
||||
#elif DETECT_OS_FREEBSD || DETECT_OS_OPENBSD
|
||||
pthread_set_name_np(pthread_self(), name);
|
||||
#elif DETECT_OS_NETBSD
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue