@@ -2392,8 +2392,16 @@ PyDoc_STRVAR(thread__get_main_thread_ident_doc,
23922392Internal only. Return a non-zero integer that uniquely identifies the main thread\n\ 
23932393of the main interpreter." );
23942394
2395+ #if  defined(__OpenBSD__ )
2396+     /* pthread_*_np functions, especially pthread_{get,set}_name_np(). 
2397+        pthread_np.h exists on both OpenBSD and FreeBSD but the latter declares 
2398+        pthread_getname_np() and pthread_setname_np() in pthread.h as long as 
2399+        __BSD_VISIBLE remains set. 
2400+      */ 
2401+ #   include  <pthread_np.h> 
2402+ #endif 
23952403
2396- #if  defined(HAVE_PTHREAD_GETNAME_NP ) ||  defined(MS_WINDOWS )
2404+ #if  defined(HAVE_PTHREAD_GETNAME_NP ) ||  defined(HAVE_PTHREAD_GET_NAME_NP )  ||  defined( MS_WINDOWS )
23972405/*[clinic input] 
23982406_thread._get_name 
23992407
@@ -2408,7 +2416,12 @@ _thread__get_name_impl(PyObject *module)
24082416    // Linux and macOS are limited to respectively 16 and 64 bytes 
24092417    char  name [100 ];
24102418    pthread_t  thread  =  pthread_self ();
2419+ #ifdef  HAVE_PTHREAD_GETNAME_NP 
24112420    int  rc  =  pthread_getname_np (thread , name , Py_ARRAY_LENGTH (name ));
2421+ #else  /* defined(HAVE_PTHREAD_GET_NAME_NP) */ 
2422+     int  rc  =  0 ; /* pthread_get_name_np() returns void */ 
2423+     pthread_get_name_np (thread , name , Py_ARRAY_LENGTH (name ));
2424+ #endif 
24122425    if  (rc ) {
24132426        errno  =  rc ;
24142427        return  PyErr_SetFromErrno (PyExc_OSError );
@@ -2435,10 +2448,10 @@ _thread__get_name_impl(PyObject *module)
24352448    return  name_obj ;
24362449#endif 
24372450}
2438- #endif   // HAVE_PTHREAD_GETNAME_NP 
2451+ #endif   // HAVE_PTHREAD_GETNAME_NP || HAVE_PTHREAD_GET_NAME_NP || MS_WINDOWS  
24392452
24402453
2441- #if  defined(HAVE_PTHREAD_SETNAME_NP ) ||  defined(MS_WINDOWS )
2454+ #if  defined(HAVE_PTHREAD_SETNAME_NP ) ||  defined(HAVE_PTHREAD_SET_NAME_NP )  ||  defined( MS_WINDOWS )
24422455/*[clinic input] 
24432456_thread.set_name 
24442457
@@ -2487,9 +2500,13 @@ _thread_set_name_impl(PyObject *module, PyObject *name_obj)
24872500#elif  defined(__NetBSD__ )
24882501    pthread_t  thread  =  pthread_self ();
24892502    int  rc  =  pthread_setname_np (thread , "%s" , (void  * )name );
2490- #else  
2503+ #elif   defined( HAVE_PTHREAD_SETNAME_NP ) 
24912504    pthread_t  thread  =  pthread_self ();
24922505    int  rc  =  pthread_setname_np (thread , name );
2506+ #else  /* defined(HAVE_PTHREAD_SET_NAME_NP) */ 
2507+     pthread_t  thread  =  pthread_self ();
2508+     int  rc  =  0 ; /* pthread_set_name_np() returns void */ 
2509+     pthread_set_name_np (thread , name );
24932510#endif 
24942511    Py_DECREF (name_encoded );
24952512    if  (rc ) {
@@ -2527,7 +2544,7 @@ _thread_set_name_impl(PyObject *module, PyObject *name_obj)
25272544    Py_RETURN_NONE ;
25282545#endif 
25292546}
2530- #endif   // HAVE_PTHREAD_SETNAME_NP 
2547+ #endif   // HAVE_PTHREAD_SETNAME_NP || HAVE_PTHREAD_SET_NAME_NP || MS_WINDOWS  
25312548
25322549
25332550static  PyMethodDef  thread_methods [] =  {
0 commit comments