From dc20e265948c0e758cdfa3974f3b87d2bd248210 Mon Sep 17 00:00:00 2001 From: deadbeef Date: Tue, 31 Jan 2017 15:10:44 -0800 Subject: [PATCH] Use correct calling convention for CreateThread callback on Windows. It appears that thread.cc was the only thing in the webrtc codebase that was doing this incorrectly (platform_thread.cc, for instance, is ok). BUG=chromium:687251 Review-Url: https://codereview.webrtc.org/2668693005 Cr-Commit-Position: refs/heads/master@{#16387} --- webrtc/base/thread.cc | 14 +++++++++++--- webrtc/base/thread.h | 4 ++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/webrtc/base/thread.cc b/webrtc/base/thread.cc index b7d448656d..ed0c446741 100644 --- a/webrtc/base/thread.cc +++ b/webrtc/base/thread.cc @@ -228,8 +228,7 @@ bool Thread::Start(Runnable* runnable) { init->thread = this; init->runnable = runnable; #if defined(WEBRTC_WIN) - thread_ = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PreRun, init, 0, - &thread_id_); + thread_ = CreateThread(NULL, 0, PreRun, init, 0, &thread_id_); if (thread_) { running_.Set(); } else { @@ -308,7 +307,12 @@ void Thread::AssertBlockingIsAllowedOnCurrentThread() { #endif } +// static +#if defined(WEBRTC_WIN) +DWORD WINAPI Thread::PreRun(LPVOID pv) { +#else void* Thread::PreRun(void* pv) { +#endif ThreadInit* init = static_cast(pv); ThreadManager::Instance()->SetCurrentThread(init->thread); rtc::SetCurrentThreadName(init->thread->name_.c_str()); @@ -325,7 +329,11 @@ void* Thread::PreRun(void* pv) { init->thread->Run(); } delete init; - return NULL; +#ifdef WEBRTC_WIN + return 0; +#else + return nullptr; +#endif } } diff --git a/webrtc/base/thread.h b/webrtc/base/thread.h index 97e69415cd..29b78e1845 100644 --- a/webrtc/base/thread.h +++ b/webrtc/base/thread.h @@ -238,7 +238,11 @@ class LOCKABLE Thread : public MessageQueue { friend class ScopedDisallowBlockingCalls; private: +#if defined(WEBRTC_WIN) + static DWORD WINAPI PreRun(LPVOID context); +#else static void *PreRun(void *pv); +#endif // ThreadManager calls this instead WrapCurrent() because // ThreadManager::Instance() cannot be used while ThreadManager is