Fix building on NetBSD

Thanks to Thomas Klausner
This commit is contained in:
Kovid Goyal 2019-02-14 18:48:18 +05:30
parent f2315801db
commit 15a3bb4b8d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -502,6 +502,8 @@ extern int pthread_setname_np(const char *name);
#elif defined(FREEBSD_SET_NAME) #elif defined(FREEBSD_SET_NAME)
// Function has a different name on FreeBSD // Function has a different name on FreeBSD
void pthread_set_name_np(pthread_t tid, const char *name); void pthread_set_name_np(pthread_t tid, const char *name);
#elif defined(__NetBSD__)
// pthread.h provides the symbol
#else #else
// Need _GNU_SOURCE for pthread_setname_np on linux and that causes other issues on systems with old glibc // Need _GNU_SOURCE for pthread_setname_np on linux and that causes other issues on systems with old glibc
extern int pthread_setname_np(pthread_t, const char *name); extern int pthread_setname_np(pthread_t, const char *name);
@ -526,6 +528,8 @@ set_thread_name(PyObject *self, PyObject *args) {
#elif defined(FREEBSD_SET_NAME) #elif defined(FREEBSD_SET_NAME)
pthread_set_name_np(pthread_self(), name); pthread_set_name_np(pthread_self(), name);
ret = 0; ret = 0;
#elif defined(__NetBSD__)
ret = pthread_setname_np(pthread_self(), "%s", name);
#else #else
ret = pthread_setname_np(pthread_self(), name); ret = pthread_setname_np(pthread_self(), name);
#endif #endif