X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/122cf17b1304d0af9dfe67d605ee4e5c92dd2dfc..c9cc9a2f3e41341a4c04c67137b58faaeaa55366:/src/unix/threadpsx.cpp diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp index db3063e48e..1b7248d98a 100644 --- a/src/unix/threadpsx.cpp +++ b/src/unix/threadpsx.cpp @@ -118,7 +118,11 @@ static wxArrayThread gs_allThreads; static wxMutex *gs_mutexAllThreads = NULL; // the id of the main thread -static pthread_t gs_tidMain = (pthread_t)-1; +// +// we suppose that 0 is not a valid pthread_t value but in principle this might +// be false (e.g. if it's a selector-like value), wxThread::IsMain() would need +// to be updated in such case +wxThreadIdType wxThread::ms_idMainThread = 0; // the key for the pointer to the associated wxThread object static pthread_key_t gs_keySelf; @@ -720,7 +724,7 @@ public: wxThreadState GetState() const { return m_state; } void SetState(wxThreadState state) { -#ifdef __WXDEBUG__ +#if wxUSE_LOG_TRACE static const wxChar *stateNames[] = { _T("NEW"), @@ -731,7 +735,7 @@ public: wxLogTrace(TRACE_THREADS, _T("Thread %p: %s => %s."), GetId(), stateNames[m_state], stateNames[state]); -#endif // __WXDEBUG__ +#endif // wxUSE_LOG_TRACE m_state = state; } @@ -1057,11 +1061,6 @@ wxThread *wxThread::This() return (wxThread *)pthread_getspecific(gs_keySelf); } -bool wxThread::IsMain() -{ - return (bool)pthread_equal(pthread_self(), gs_tidMain) || gs_tidMain == (pthread_t)-1; -} - void wxThread::Yield() { #ifdef HAVE_SCHED_YIELD @@ -1110,23 +1109,11 @@ int wxThread::GetCPUCount() return -1; } -// VMS is a 64 bit system and threads have 64 bit pointers. -// FIXME: also needed for other systems???? -#ifdef __VMS -unsigned long long wxThread::GetCurrentId() -{ - return (unsigned long long)pthread_self(); -} - -#else // !__VMS - -unsigned long wxThread::GetCurrentId() +wxThreadIdType wxThread::GetCurrentId() { - return (unsigned long)pthread_self(); + return (wxThreadIdType)pthread_self(); } -#endif // __VMS/!__VMS - bool wxThread::SetConcurrency(size_t level) { @@ -1624,7 +1611,6 @@ bool wxThread::TestDestroy() wxThread::~wxThread() { -#ifdef __WXDEBUG__ m_critsect.Enter(); // check that the thread either exited or couldn't be created @@ -1636,7 +1622,6 @@ wxThread::~wxThread() } m_critsect.Leave(); -#endif // __WXDEBUG__ delete m_internal; @@ -1707,7 +1692,7 @@ bool wxThreadModule::OnInit() return false; } - gs_tidMain = pthread_self(); + wxThread::ms_idMainThread = wxThread::GetCurrentId(); gs_mutexAllThreads = new wxMutex();