From: Lars Op den Kamp Date: Tue, 15 May 2012 10:04:43 +0000 (+0200) Subject: platform: fixed initial value of m_thread in CThread X-Git-Tag: upstream/2.2.0~1^2~28^2~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=622f7c33630a30fbfdd25ca4ff97add39ebc0905;p=deb_libcec.git platform: fixed initial value of m_thread in CThread --- diff --git a/src/lib/platform/posix/os-threads.h b/src/lib/platform/posix/os-threads.h index 89f822b..e5f935c 100644 --- a/src/lib/platform/posix/os-threads.h +++ b/src/lib/platform/posix/os-threads.h @@ -64,6 +64,7 @@ namespace PLATFORM } typedef pthread_t thread_t; + #define INVALID_THREAD_VALUE 0 #define ThreadsCreate(thread, func, arg) (pthread_create(&thread, NULL, (void *(*) (void *))func, (void *)arg) == 0) #define ThreadsWait(thread, retval) (thread ? pthread_join(thread, retval) == 0 : true) diff --git a/src/lib/platform/threads/threads.h b/src/lib/platform/threads/threads.h index 1f62dcf..3647770 100644 --- a/src/lib/platform/threads/threads.h +++ b/src/lib/platform/threads/threads.h @@ -42,13 +42,13 @@ namespace PLATFORM m_bStop(false), m_bRunning(false), m_bStopped(false), - m_thread(NULL) {} + m_thread(INVALID_THREAD_VALUE) {} virtual ~CThread(void) { StopThread(0); void *retVal = NULL; - if (m_thread) + if (m_thread != INVALID_THREAD_VALUE) ThreadsWait(m_thread, &retVal); } diff --git a/src/lib/platform/windows/os-threads.h b/src/lib/platform/windows/os-threads.h index 3714c16..ff773f0 100644 --- a/src/lib/platform/windows/os-threads.h +++ b/src/lib/platform/windows/os-threads.h @@ -34,6 +34,7 @@ namespace PLATFORM { #define thread_t HANDLE + #define INVALID_THREAD_VALUE INVALID_HANDLE #define ThreadsWait(thread, retVal) (::WaitForSingleObject(thread, INFINITE) < 0) #define ThreadsCreate(thread, func, arg) ((thread = ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)func, arg, 0, NULL)) == NULL ? false : true)