mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-02-25 19:06:48 +00:00
Fixed bug #5283 - limit thread name to 16 characters when using pthread_setname_np()
This commit is contained in:
parent
b11dfd7611
commit
9e46a512b1
|
@ -41,6 +41,8 @@
|
|||
#include "../../core/linux/SDL_dbus.h"
|
||||
#endif /* __LINUX__ */
|
||||
|
||||
#undef HAVE_DLOPEN
|
||||
|
||||
#if (defined(__LINUX__) || defined(__MACOSX__) || defined(__IPHONEOS__)) && defined(HAVE_DLOPEN)
|
||||
#include <dlfcn.h>
|
||||
#ifndef RTLD_DEFAULT
|
||||
|
@ -137,22 +139,25 @@ SDL_SYS_SetupThread(const char *name)
|
|||
#if defined(__MACOSX__) || defined(__IPHONEOS__)
|
||||
ppthread_setname_np(name);
|
||||
#elif defined(__LINUX__)
|
||||
ppthread_setname_np(pthread_self(), name);
|
||||
char namebuf[16]; /* Limited to 16 char */
|
||||
SDL_strlcpy(namebuf, name, sizeof (namebuf));
|
||||
ppthread_setname_np(pthread_self(), namebuf);
|
||||
#endif
|
||||
}
|
||||
#elif HAVE_PTHREAD_SETNAME_NP
|
||||
#if defined(__NETBSD__)
|
||||
pthread_setname_np(pthread_self(), "%s", name);
|
||||
#else
|
||||
pthread_setname_np(pthread_self(), name);
|
||||
char namebuf[16]; /* Limited to 16 char */
|
||||
SDL_strlcpy(namebuf, name, sizeof (namebuf));
|
||||
pthread_setname_np(pthread_self(), namebuf);
|
||||
#endif
|
||||
#elif HAVE_PTHREAD_SET_NAME_NP
|
||||
pthread_set_name_np(pthread_self(), name);
|
||||
#elif defined(__HAIKU__)
|
||||
/* The docs say the thread name can't be longer than B_OS_NAME_LENGTH. */
|
||||
char namebuf[B_OS_NAME_LENGTH];
|
||||
SDL_snprintf(namebuf, sizeof (namebuf), "%s", name);
|
||||
namebuf[sizeof (namebuf) - 1] = '\0';
|
||||
SDL_strlcpy(namebuf, name, sizeof (namebuf));
|
||||
rename_thread(find_thread(NULL), namebuf);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue