diff --git a/libretroshare/src/util/rsthreads.cc b/libretroshare/src/util/rsthreads.cc index baa95b93e..bf2f34042 100644 --- a/libretroshare/src/util/rsthreads.cc +++ b/libretroshare/src/util/rsthreads.cc @@ -24,13 +24,14 @@ * */ - #include "rsthreads.h" #include // for usleep() #include // for errno #include #include +int __attribute__((weak)) pthread_setname_np(pthread_t __target_thread, const char *__buf) ; + #ifdef RSMUTEX_DEBUG #include #include @@ -164,20 +165,21 @@ void RsThread::start(const std::string &threadName) mTid = tid; // set name -#ifdef __USE_GNU - if(!threadName.empty()) { - // thread names are restricted to 16 characters including the terminating null byte - if(threadName.length() > 15) - { + + if(pthread_setname_np) + if(!threadName.empty()) + { + // thread names are restricted to 16 characters including the terminating null byte + if(threadName.length() > 15) + { #ifdef DEBUG_THREADS - THREAD_DEBUG << "RsThread::start called with to long name '" << name << "' truncating..." << std::endl; -#endif - pthread_setname_np(mTid, threadName.substr(0, 15).c_str()); - } else { - pthread_setname_np(mTid, threadName.c_str()); - } - } + THREAD_DEBUG << "RsThread::start called with to long name '" << name << "' truncating..." << std::endl; #endif + pthread_setname_np(mTid, threadName.substr(0, 15).c_str()); + } else { + pthread_setname_np(mTid, threadName.c_str()); + } + } } else {