Merge pull request #401 from PhenomRetroShare/Fix_WindowsCompilationWithThreadName

Fix Compilation with unknown pthread_getname_np if not __USE_GNU defined
This commit is contained in:
Cyril Soler 2016-06-02 20:36:51 -04:00
commit 5362fd3413

View File

@ -164,18 +164,20 @@ void RsThread::start(const std::string &threadName)
mTid = tid; mTid = tid;
// set name // set name
if(!threadName.empty()) { #ifdef __USE_GNU
// 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
{ {