src/thread/pthread/SDL_systhread.c
changeset 5969 3a041d215edc
parent 5963 fe5d2285dffa
child 5972 8b7f8d297943
equal deleted inserted replaced
5968:b229328c7ad4 5969:3a041d215edc
    19   3. This notice may not be removed or altered from any source distribution.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    20 */
    21 #include "SDL_config.h"
    21 #include "SDL_config.h"
    22 
    22 
    23 #include <pthread.h>
    23 #include <pthread.h>
       
    24 
       
    25 #if HAVE_PTHREAD_NP_H
       
    26 #include <pthread_np.h>
       
    27 #endif
       
    28 
    24 #include <signal.h>
    29 #include <signal.h>
    25 #ifdef __LINUX__
    30 #ifdef __LINUX__
    26 #include <sys/time.h>
    31 #include <sys/time.h>
    27 #include <sys/resource.h>
    32 #include <sys/resource.h>
    28 #include <sys/syscall.h>
    33 #include <sys/syscall.h>
    29 #endif
    34 #endif
    30 
    35 
       
    36 #include "SDL_platform.h"
    31 #include "SDL_thread.h"
    37 #include "SDL_thread.h"
    32 #include "../SDL_thread_c.h"
    38 #include "../SDL_thread_c.h"
    33 #include "../SDL_systhread.h"
    39 #include "../SDL_systhread.h"
    34 
    40 
    35 /* List of signals to mask in the subthreads */
    41 /* List of signals to mask in the subthreads */
    65     }
    71     }
    66 
    72 
    67     return (0);
    73     return (0);
    68 }
    74 }
    69 
    75 
       
    76 /* make pthread_setname_np() a weak reference even without SDK support. */
       
    77 #if __MACOSX__ && (MAC_OS_X_VERSION_MAX_ALLOWED < 1060)
       
    78 int pthread_setname_np(const char*) __attribute__((weak_import,visibility("default")));
       
    79 #elif __IPHONEOS__ && (__IPHONE_OS_VERSION_MAX_ALLOWED < 30200)
       
    80 int pthread_setname_np(const char*) __attribute__((weak_import));
       
    81 #endif
       
    82 
    70 void
    83 void
    71 SDL_SYS_SetupThread(void)
    84 SDL_SYS_SetupThread(const char *name)
    72 {
    85 {
    73     int i;
    86     int i;
    74     sigset_t mask;
    87     sigset_t mask;
       
    88 
       
    89 #if __MACOSX__ || __IPHONEOS__
       
    90     if (pthread_setname_np != NULL) { pthread_setname_np(name); }
       
    91 #elif HAVE_PTHREAD_SETNAME_NP
       
    92     pthread_setname_np(pthread_self(), name);
       
    93 #elif HAVE_PTHREAD_SET_NAME_NP
       
    94     pthread_set_name_np(pthread_self(), name);
       
    95 #endif
    75 
    96 
    76     /* Mask asynchronous signals for this thread */
    97     /* Mask asynchronous signals for this thread */
    77     sigemptyset(&mask);
    98     sigemptyset(&mask);
    78     for (i = 0; sig_list[i]; ++i) {
    99     for (i = 0; sig_list[i]; ++i) {
    79         sigaddset(&mask, sig_list[i]);
   100         sigaddset(&mask, sig_list[i]);