X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/32632baf6d4a9c9d03fb8b17a7a9a4a2aa339999..05e66a7002abbc726d3aa53fc5cb42ebaf8748e8:/src/unix/threadpsx.cpp diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp index 1d77856e80..952c77c9c7 100644 --- a/src/unix/threadpsx.cpp +++ b/src/unix/threadpsx.cpp @@ -54,10 +54,17 @@ #include #endif +#ifdef HAVE_ABI_FORCEDUNWIND + #include +#endif + +#ifdef HAVE_SETPRIORITY + #include // for setpriority() +#endif + // we use wxFFile under Linux in GetCPUCount() #ifdef __LINUX__ #include "wx/ffile.h" - #include // for setpriority() #endif #define THR_ID_CAST(id) (reinterpret_cast(id)) @@ -857,6 +864,18 @@ void *wxThreadInternal::PthreadStart(wxThread *thread) wxT("Thread %p Entry() returned %lu."), THR_ID(pthread), wxPtrToUInt(pthread->m_exitcode)); } +#ifdef HAVE_ABI_FORCEDUNWIND + // When using common C++ ABI under Linux we must always rethrow this + // special exception used to unwind the stack when the thread was + // cancelled, otherwise the thread library would simply terminate the + // program, see http://udrepper.livejournal.com/21541.html + catch ( abi::__forced_unwind& ) + { + wxCriticalSectionLocker lock(thread->m_critsect); + pthread->SetState(STATE_EXITED); + throw; + } +#endif // HAVE_ABI_FORCEDUNWIND wxCATCH_ALL( wxTheApp->OnUnhandledException(); ) { @@ -938,7 +957,7 @@ wxThreadInternal::wxThreadInternal() { m_state = STATE_NEW; m_cancelled = false; - m_prio = WXTHREAD_DEFAULT_PRIORITY; + m_prio = wxPRIORITY_DEFAULT; m_threadId = 0; m_exitcode = 0; @@ -1215,7 +1234,7 @@ wxThreadError wxThread::Create(unsigned int WXUNUSED_STACKSIZE(stackSize)) } else if ( max_prio == min_prio ) { - if ( prio != WXTHREAD_DEFAULT_PRIORITY ) + if ( prio != wxPRIORITY_DEFAULT ) { // notify the programmer that this doesn't work here wxLogWarning(_("Thread priority setting is ignored.")); @@ -1304,8 +1323,7 @@ wxThreadError wxThread::Run() void wxThread::SetPriority(unsigned int prio) { - wxCHECK_RET( ((int)WXTHREAD_MIN_PRIORITY <= (int)prio) && - ((int)prio <= (int)WXTHREAD_MAX_PRIORITY), + wxCHECK_RET( wxPRIORITY_MIN <= prio && prio <= wxPRIORITY_MAX, wxT("invalid thread priority") ); wxCriticalSectionLocker lock(m_critsect); @@ -1331,8 +1349,7 @@ void wxThread::SetPriority(unsigned int prio) // // FIXME this is not true for 2.6!! - // map wx priorites WXTHREAD_MIN_PRIORITY..WXTHREAD_MAX_PRIORITY - // to Unix priorities 20..-20 + // map wx priorites 0..100 to Unix priorities 20..-20 if ( setpriority(PRIO_PROCESS, 0, -(2*(int)prio)/5 + 20) == -1 ) { wxLogError(_("Failed to set thread priority %d."), prio); @@ -1837,7 +1854,7 @@ static void DeleteThread(wxThread *This) } } -#ifndef __WXOSX__ +#ifndef __DARWIN__ void wxMutexGuiEnterImpl() {