From 57e6b81954ce6303dbe9c352bb50c0c53f169dc6 Mon Sep 17 00:00:00 2001 From: "henrike@webrtc.org" Date: Tue, 29 Jan 2013 15:08:29 +0000 Subject: [PATCH] Mac 64-bit compatibility for WebRTC. pthread_t is a pointer type on Mac OS X, and is thus 32 bits wide in the 32-bit environment and 64 bits wide in the 64-bit environment. WebRTC's thread ID routines assume that thread IDs can always fit inside a uint32_t, but this is not the case in the 64-bit Mac environment when using pthread_t as the basis for a thread ID. Instead, switch to using the underlying Mach port for the thread, which is a 32-bit quantity in both the 32-bit and 64-bit environments. The only place this seems to be used is in TraceImpl::AddThreadId, and it's only used there for a thread ID for display. This is a better fix than https://webrtc-codereview.appspot.com/929015 . Review URL: https://webrtc-codereview.appspot.com/1063005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3427 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/system_wrappers/source/thread_posix.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/webrtc/system_wrappers/source/thread_posix.cc b/webrtc/system_wrappers/source/thread_posix.cc index c821931973..f96978304b 100644 --- a/webrtc/system_wrappers/source/thread_posix.cc +++ b/webrtc/system_wrappers/source/thread_posix.cc @@ -138,6 +138,8 @@ ThreadPosix::ThreadPosix(ThreadRunFunction func, ThreadObj obj, uint32_t ThreadWrapper::GetThreadId() { #if defined(WEBRTC_ANDROID) || defined(WEBRTC_LINUX) return static_cast(syscall(__NR_gettid)); +#elif defined(WEBRTC_MAC) || defined(WEBRTC_IOS) + return pthread_mach_thread_np(pthread_self()); #else return reinterpret_cast(pthread_self()); #endif