Bugfix get thread ID for linux.

Review URL: http://webrtc-codereview.appspot.com/331015

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1282 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pwestin@webrtc.org 2011-12-22 09:40:28 +00:00
parent a4863dbdf0
commit 43761beb47

View File

@ -15,7 +15,9 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
#ifdef __linux__
#include <sys/syscall.h>
#endif
#ifdef WEBRTC_ANDROID
#include <pthread.h>
#else
@ -48,13 +50,17 @@ TracePosix::~TracePosix()
StopThread();
}
WebRtc_Word32 TracePosix::AddThreadId(char* traceMessage) const
{
WebRtc_UWord64 threadId = (WebRtc_UWord64)pthread_self();
sprintf(traceMessage, "%10llu; ",
static_cast<long long unsigned int>(threadId));
// 12 bytes are written.
return 12;
WebRtc_Word32 TracePosix::AddThreadId(char* traceMessage) const {
#ifdef __linux__
pid_t threadId = (pid_t) syscall(SYS_gettid);
sprintf(traceMessage, "%10d; ", threadId);
#else
WebRtc_UWord64 threadId = (WebRtc_UWord64)pthread_self();
sprintf(traceMessage, "%10llu; ",
static_cast<long long unsigned int>(threadId));
#endif
// 12 bytes are written.
return 12;
}
WebRtc_Word32 TracePosix::AddTime(char* traceMessage,