attempt to fix the pthread_setname_np symbol issue. To be tested

This commit is contained in:
csoler 2016-06-03 19:03:10 +02:00
parent 53eb4dfb12
commit 4c986cdc3e

View File

@ -24,13 +24,14 @@
* *
*/ */
#include "rsthreads.h" #include "rsthreads.h"
#include <unistd.h> // for usleep() #include <unistd.h> // for usleep()
#include <errno.h> // for errno #include <errno.h> // for errno
#include <iostream> #include <iostream>
#include <time.h> #include <time.h>
int __attribute__((weak)) pthread_setname_np(pthread_t __target_thread, const char *__buf) ;
#ifdef RSMUTEX_DEBUG #ifdef RSMUTEX_DEBUG
#include <stdio.h> #include <stdio.h>
#include <sys/time.h> #include <sys/time.h>
@ -164,20 +165,21 @@ void RsThread::start(const std::string &threadName)
mTid = tid; mTid = tid;
// set name // set name
#ifdef __USE_GNU
if(!threadName.empty()) { if(pthread_setname_np)
// thread names are restricted to 16 characters including the terminating null byte if(!threadName.empty())
if(threadName.length() > 15) {
{ // thread names are restricted to 16 characters including the terminating null byte
if(threadName.length() > 15)
{
#ifdef DEBUG_THREADS #ifdef DEBUG_THREADS
THREAD_DEBUG << "RsThread::start called with to long name '" << name << "' truncating..." << std::endl; 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());
}
}
#endif #endif
pthread_setname_np(mTid, threadName.substr(0, 15).c_str());
} else {
pthread_setname_np(mTid, threadName.c_str());
}
}
} }
else else
{ {