Simple Directmedia Layer

Use `pthread_setname_np` also on Android

Set thread name on Android the same way as we do on Linux.

Acording to Bionic source code this function is available since 2013 [1] and
hase the same signature.

[1] https://android.googlesource.com/platform/bionic/+/2a1bb4e64677b9abbc17173c79768ed494565047

(cherry picked from commit e79b0ce2e4660e7621719ca3fce362545c90cbf7)

authored by Blaž Tomažič and committed by Sam Lantinga e9290eee 578509c3

Changed files
+7 -7
src
thread
pthread
+7 -7
src/thread/pthread/SDL_systhread.c
··· 40 40 #include "../../core/linux/SDL_dbus.h" 41 41 #endif // SDL_PLATFORM_LINUX 42 42 43 - #if (defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)) && defined(HAVE_DLOPEN) 43 + #if (defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)) && defined(HAVE_DLOPEN) 44 44 #include <dlfcn.h> 45 45 #ifndef RTLD_DEFAULT 46 46 #define RTLD_DEFAULT NULL ··· 77 77 #if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)) && defined(HAVE_DLOPEN) 78 78 static bool checked_setname = false; 79 79 static int (*ppthread_setname_np)(const char *) = NULL; 80 - #elif defined(SDL_PLATFORM_LINUX) && defined(HAVE_DLOPEN) 80 + #elif (defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID)) && defined(HAVE_DLOPEN) 81 81 static bool checked_setname = false; 82 82 static int (*ppthread_setname_np)(pthread_t, const char *) = NULL; 83 83 #endif ··· 88 88 pthread_attr_t type; 89 89 90 90 // do this here before any threads exist, so there's no race condition. 91 - #if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_LINUX)) && defined(HAVE_DLOPEN) 91 + #if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID)) && defined(HAVE_DLOPEN) 92 92 if (!checked_setname) { 93 93 void *fn = dlsym(RTLD_DEFAULT, "pthread_setname_np"); 94 94 #if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) 95 95 ppthread_setname_np = (int (*)(const char *))fn; 96 - #elif defined(SDL_PLATFORM_LINUX) 96 + #elif defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) 97 97 ppthread_setname_np = (int (*)(pthread_t, const char *))fn; 98 98 #endif 99 99 checked_setname = true; 100 100 } 101 - #endif 101 + #endif 102 102 103 103 // Set the thread attributes 104 104 if (pthread_attr_init(&type) != 0) { ··· 127 127 #endif 128 128 129 129 if (name) { 130 - #if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_LINUX)) && defined(HAVE_DLOPEN) 130 + #if (defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) || defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID)) && defined(HAVE_DLOPEN) 131 131 SDL_assert(checked_setname); 132 132 if (ppthread_setname_np) { 133 133 #if defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS) 134 134 ppthread_setname_np(name); 135 - #elif defined(SDL_PLATFORM_LINUX) 135 + #elif defined(SDL_PLATFORM_LINUX) || defined(SDL_PLATFORM_ANDROID) 136 136 if (ppthread_setname_np(pthread_self(), name) == ERANGE) { 137 137 char namebuf[16]; // Limited to 16 char 138 138 SDL_strlcpy(namebuf, name, sizeof(namebuf));