src/thread/pthread/SDL_systhread.c
changeset 6641 45187a87d35b
parent 6640 44a2e00e7c66
child 6885 700f1b25f77f
equal deleted inserted replaced
6640:44a2e00e7c66 6641:45187a87d35b
    70     return NULL;
    70     return NULL;
    71 }
    71 }
    72 
    72 
    73 #if defined(__MACOSX__) || defined(__IPHONEOS__)
    73 #if defined(__MACOSX__) || defined(__IPHONEOS__)
    74 static SDL_bool checked_setname = SDL_FALSE;
    74 static SDL_bool checked_setname = SDL_FALSE;
    75 static int (*pthread_setname_np)(const char*) = NULL;
    75 static int (*ppthread_setname_np)(const char*) = NULL;
    76 #elif defined(__LINUX__)
    76 #elif defined(__LINUX__)
    77 static SDL_bool checked_setname = SDL_FALSE;
    77 static SDL_bool checked_setname = SDL_FALSE;
    78 static int (*pthread_setname_np)(pthread_t, const char*) = NULL;
    78 static int (*ppthread_setname_np)(pthread_t, const char*) = NULL;
    79 #endif
    79 #endif
    80 int
    80 int
    81 SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
    81 SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
    82 {
    82 {
    83     pthread_attr_t type;
    83     pthread_attr_t type;
    85     /* do this here before any threads exist, so there's no race condition. */
    85     /* do this here before any threads exist, so there's no race condition. */
    86     #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)
    86     #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)
    87     if (!checked_setname) {
    87     if (!checked_setname) {
    88         void *fn = dlsym(RTLD_DEFAULT, "pthread_setname_np");
    88         void *fn = dlsym(RTLD_DEFAULT, "pthread_setname_np");
    89         #if defined(__MACOSX__) || defined(__IPHONEOS__)
    89         #if defined(__MACOSX__) || defined(__IPHONEOS__)
    90         pthread_setname_np = (int(*)(const char*)) fn;
    90         ppthread_setname_np = (int(*)(const char*)) fn;
    91         #elif defined(__LINUX__)
    91         #elif defined(__LINUX__)
    92         pthread_setname_np = (int(*)(pthread_t, const char*)) fn;
    92         ppthread_setname_np = (int(*)(pthread_t, const char*)) fn;
    93         #endif
    93         #endif
    94         checked_setname = SDL_TRUE;
    94         checked_setname = SDL_TRUE;
    95     }
    95     }
    96     #endif
    96     #endif
    97 
    97 
   118     sigset_t mask;
   118     sigset_t mask;
   119 
   119 
   120     if (name != NULL) {
   120     if (name != NULL) {
   121         #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)
   121         #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)
   122         SDL_assert(checked_setname);
   122         SDL_assert(checked_setname);
   123         if (pthread_setname_np) {
   123         if (ppthread_setname_np != NULL) {
   124             #if defined(__MACOSX__) || defined(__IPHONEOS__)
   124             #if defined(__MACOSX__) || defined(__IPHONEOS__)
   125             pthread_setname_np(name);
   125             ppthread_setname_np(name);
   126             #elif defined(__LINUX__)
   126             #elif defined(__LINUX__)
   127             pthread_setname_np(pthread_self(), name);
   127             ppthread_setname_np(pthread_self(), name);
   128             #endif
   128             #endif
   129         }
   129         }
   130         #elif HAVE_PTHREAD_SETNAME_NP
   130         #elif HAVE_PTHREAD_SETNAME_NP
   131             pthread_setname_np(pthread_self(), name);
   131             pthread_setname_np(pthread_self(), name);
   132         #elif HAVE_PTHREAD_SET_NAME_NP
   132         #elif HAVE_PTHREAD_SET_NAME_NP