From bdd4988829973ed38a076b3948d990a9d095eda3 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Tue, 7 Sep 2004 12:49:49 +0000 Subject: [PATCH] Simplify. --- .../src/arch/Threads/Threads_Pthreads.cpp | 42 ++++--------------- stepmania/src/arch/Threads/Threads_Pthreads.h | 18 +++----- 2 files changed, 13 insertions(+), 47 deletions(-) diff --git a/stepmania/src/arch/Threads/Threads_Pthreads.cpp b/stepmania/src/arch/Threads/Threads_Pthreads.cpp index 8cd1517ea4..06d2aef852 100644 --- a/stepmania/src/arch/Threads/Threads_Pthreads.cpp +++ b/stepmania/src/arch/Threads/Threads_Pthreads.cpp @@ -20,8 +20,7 @@ void ThreadImpl_Pthreads::Halt( bool Kill ) { -#if defined(PID_BASED_THREADS) - /* + /* Linux: * Send a SIGSTOP to the thread. If we send a SIGKILL, pthreads will * "helpfully" propagate it to the other threads, and we'll get killed, too. * @@ -29,29 +28,18 @@ void ThreadImpl_Pthreads::Halt( bool Kill ) * the shell is concerned, so the shell prompt can display before the crash * handler actually displays a message. */ - SuspendThread( pid ); -#elif defined(DARWIN) - SuspendThread( MachThreadHandle ); -#endif + SuspendThread( threadHandle ); } void ThreadImpl_Pthreads::Resume() { -#if defined(PID_BASED_THREADS) - /* Send a SIGCONT to the thread. */ - ResumeThread( pid ); -#elif defined(DARWIN) - ResumeThread( MachThreadHandle ); -#endif + /* Linux: Send a SIGCONT to the thread. */ + ResumeThread( threadHandle ); } uint64_t ThreadImpl_Pthreads::GetThreadId() const { -#if defined(PID_BASED_THREADS) - return (uint64_t) pid; -#elif defined(DARWIN) - return MachThreadHandle; -#endif + return threadHandle; } int ThreadImpl_Pthreads::Wait() @@ -69,14 +57,7 @@ ThreadImpl *MakeThisThread() ThreadImpl_Pthreads *thread = new ThreadImpl_Pthreads; thread->thread = pthread_self(); - -#if defined(PID_BASED_THREADS) - thread->pid = GetCurrentThreadId(); /* in LinuxThreadHelpers.cpp */ -#endif - -#if defined(DARWIN) - thread->MachThreadHandle = GetCurrentThreadId(); -#endif + thread->threadHandle = GetCurrentThreadId(); return thread; } @@ -85,15 +66,8 @@ static void *StartThread( void *pData ) { ThreadImpl_Pthreads *pThis = (ThreadImpl_Pthreads *) pData; -#if defined(PID_BASED_THREADS) - pThis->pid = GetCurrentThreadId(); /* in LinuxThreadHelpers.cpp */ -#endif - -#if defined(DARWIN) - pThis->MachThreadHandle = GetCurrentThreadId(); -#endif - - *pThis->m_piThreadID = pThis->GetThreadId(); + pThis->threadHandle = GetCurrentThreadId(); + *pThis->m_piThreadID = pThis->threadHandle; /* Tell MakeThread that we've set m_piThreadID, so it's safe to return. */ pThis->m_StartFinishedSem->Post(); diff --git a/stepmania/src/arch/Threads/Threads_Pthreads.h b/stepmania/src/arch/Threads/Threads_Pthreads.h index 154fddcf97..263bc0073b 100644 --- a/stepmania/src/arch/Threads/Threads_Pthreads.h +++ b/stepmania/src/arch/Threads/Threads_Pthreads.h @@ -3,10 +3,6 @@ #include "Threads.h" -#if defined(LINUX) -#define PID_BASED_THREADS -#endif - #include #include @@ -15,16 +11,12 @@ class ThreadImpl_Pthreads: public ThreadImpl public: pthread_t thread; -#if defined(PID_BASED_THREADS) - /* Keep a list of child PIDs, so we can send them SIGKILL. This has an + /* Linux: + * Keep a list of child PIDs, so we can send them SIGKILL. This has an * added bonus: if this is corrupted, we'll just send signals and they'll - * fail; we won't blow up (unless we're root). */ - int pid; -#endif - -#if defined(DARWIN) - uint64_t MachThreadHandle; -#endif + * fail; we won't blow up (unless we're root). + */ + uint64_t threadHandle; /* These are only used during initialization. */ int (*m_pFunc)( void *pData );