mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-02-25 21:57:00 +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"
|
#include "../../core/linux/SDL_dbus.h"
|
||||||
#endif /* __LINUX__ */
|
#endif /* __LINUX__ */
|
||||||
|
|
||||||
|
#undef HAVE_DLOPEN
|
||||||
|
|
||||||
#if (defined(__LINUX__) || defined(__MACOSX__) || defined(__IPHONEOS__)) && defined(HAVE_DLOPEN)
|
#if (defined(__LINUX__) || defined(__MACOSX__) || defined(__IPHONEOS__)) && defined(HAVE_DLOPEN)
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#ifndef RTLD_DEFAULT
|
#ifndef RTLD_DEFAULT
|
||||||
|
@ -137,22 +139,25 @@ SDL_SYS_SetupThread(const char *name)
|
||||||
#if defined(__MACOSX__) || defined(__IPHONEOS__)
|
#if defined(__MACOSX__) || defined(__IPHONEOS__)
|
||||||
ppthread_setname_np(name);
|
ppthread_setname_np(name);
|
||||||
#elif defined(__LINUX__)
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
#elif HAVE_PTHREAD_SETNAME_NP
|
#elif HAVE_PTHREAD_SETNAME_NP
|
||||||
#if defined(__NETBSD__)
|
#if defined(__NETBSD__)
|
||||||
pthread_setname_np(pthread_self(), "%s", name);
|
pthread_setname_np(pthread_self(), "%s", name);
|
||||||
#else
|
#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
|
#endif
|
||||||
#elif HAVE_PTHREAD_SET_NAME_NP
|
#elif HAVE_PTHREAD_SET_NAME_NP
|
||||||
pthread_set_name_np(pthread_self(), name);
|
pthread_set_name_np(pthread_self(), name);
|
||||||
#elif defined(__HAIKU__)
|
#elif defined(__HAIKU__)
|
||||||
/* The docs say the thread name can't be longer than B_OS_NAME_LENGTH. */
|
/* The docs say the thread name can't be longer than B_OS_NAME_LENGTH. */
|
||||||
char namebuf[B_OS_NAME_LENGTH];
|
char namebuf[B_OS_NAME_LENGTH];
|
||||||
SDL_snprintf(namebuf, sizeof (namebuf), "%s", name);
|
SDL_strlcpy(namebuf, name, sizeof (namebuf));
|
||||||
namebuf[sizeof (namebuf) - 1] = '\0';
|
|
||||||
rename_thread(find_thread(NULL), namebuf);
|
rename_thread(find_thread(NULL), namebuf);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue