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
This commit is contained in:
parent
d94659dc27
commit
57e6b81954
@ -138,6 +138,8 @@ ThreadPosix::ThreadPosix(ThreadRunFunction func, ThreadObj obj,
|
|||||||
uint32_t ThreadWrapper::GetThreadId() {
|
uint32_t ThreadWrapper::GetThreadId() {
|
||||||
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_LINUX)
|
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_LINUX)
|
||||||
return static_cast<uint32_t>(syscall(__NR_gettid));
|
return static_cast<uint32_t>(syscall(__NR_gettid));
|
||||||
|
#elif defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
|
||||||
|
return pthread_mach_thread_np(pthread_self());
|
||||||
#else
|
#else
|
||||||
return reinterpret_cast<uint32_t>(pthread_self());
|
return reinterpret_cast<uint32_t>(pthread_self());
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user