File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ static PF_SET_THREAD_DESCRIPTION pSetThreadDescription = NULL;
7979#endif 
8080
8181#if  defined(HAVE_PTHREAD_SETNAME_NP ) ||  defined(HAVE_PTHREAD_SET_NAME_NP )
82- static   int  _set_thread_name (const  char  * name );
82+ int  _set_thread_name (const  char  * name );
8383#endif 
8484
8585
@@ -2582,7 +2582,7 @@ Set the name of the current thread.
25822582
25832583#ifndef  MS_WINDOWS 
25842584// Helper to set the thread name using platform-specific APIs (POSIX only) 
2585- static   int 
2585+ int 
25862586_set_thread_name (const  char  * name )
25872587{
25882588    int  rc ;
@@ -2709,6 +2709,25 @@ _set_thread_name(const char *name)
27092709}
27102710#endif 
27112711
2712+ /* Weak global fallback when the platform-specific helper isn't compiled. 
2713+  * On toolchains that support weak symbols (GCC/Clang), mark it weak so a 
2714+  * real strong implementation will override it. */ 
2715+ #if  !defined(HAVE_PTHREAD_SETNAME_NP ) &&  !defined(HAVE_PTHREAD_SET_NAME_NP ) &&  !defined(MS_WINDOWS )
2716+ 
2717+ #if  defined(__GNUC__ ) ||  defined(__clang__ )
2718+ int  __attribute__((weak ))
2719+ _set_thread_name (const  char  * name )
2720+ #else 
2721+ int 
2722+ _set_thread_name (const  char  * name )
2723+ #endif 
2724+ {
2725+     (void )name ;
2726+     return  0 ;
2727+ }
2728+ #endif 
2729+ 
2730+ 
27122731static  PyMethodDef  thread_methods [] =  {
27132732    {"start_new_thread" ,        thread_PyThread_start_new_thread ,
27142733     METH_VARARGS , start_new_thread_doc },
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments