tsan: fix mac build
authorDmitry Vyukov <dvyukov@google.com>
Tue, 2 Oct 2012 12:58:14 +0000 (12:58 +0000)
committerDmitry Vyukov <dvyukov@google.com>
Tue, 2 Oct 2012 12:58:14 +0000 (12:58 +0000)
llvm-svn: 165004

compiler-rt/lib/sanitizer_common/sanitizer_common.h
compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
compiler-rt/lib/tsan/rtl/tsan_report.cc
compiler-rt/lib/tsan/rtl/tsan_report.h
compiler-rt/lib/tsan/rtl/tsan_rtl.h
compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc

index 04b08b7..323b066 100644 (file)
@@ -34,7 +34,7 @@ const uptr kMmapGranularity = 1UL << 16;
 
 // Threads
 int GetPid();
-int GetTid();
+uptr GetTid();
 uptr GetThreadSelf();
 void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,
                                 uptr *stack_bottom);
index a280a8b..40f82c1 100644 (file)
@@ -89,6 +89,10 @@ int internal_sched_yield() {
 }
 
 // ----------------- sanitizer_common.h
+uptr GetTid() {
+  return syscall(__NR_gettid);
+}
+
 void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,
                                 uptr *stack_bottom) {
   static const uptr kMaxThreadStackSize = 256 * (1 << 20);  // 256M
index 202c4f7..aaf95d5 100644 (file)
@@ -80,6 +80,10 @@ int internal_sched_yield() {
 }
 
 // ----------------- sanitizer_common.h
+uptr GetTid() {
+  return reinterpret_cast<uptr>(pthread_self());
+}
+
 void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,
                                 uptr *stack_bottom) {
   CHECK(stack_top);
index 7d21b5f..e3f8516 100644 (file)
@@ -27,7 +27,6 @@
 #include <sys/resource.h>
 #include <sys/time.h>
 #include <sys/types.h>
-#include <syscall.h>
 #include <unistd.h>
 
 namespace __sanitizer {
@@ -38,10 +37,6 @@ int GetPid() {
   return getpid();
 }
 
-int GetTid() {
-  return syscall(__NR_gettid);
-}
-
 uptr GetThreadSelf() {
   return (uptr)pthread_self();
 }
index ded8070..f24a4ec 100644 (file)
@@ -104,7 +104,7 @@ static void PrintThread(const ReportThread *rt) {
   TsanPrintf("  Thread %d", rt->id);
   if (rt->name)
     TsanPrintf(" '%s'", rt->name);
-  TsanPrintf(" (tid=%d, %s)", rt->pid, rt->running ? "running" : "finished");
+  TsanPrintf(" (tid=%zu, %s)", rt->pid, rt->running ? "running" : "finished");
   if (rt->stack)
     TsanPrintf(" created at:");
   TsanPrintf("\n");
index 696e418..34dc88f 100644 (file)
@@ -67,7 +67,7 @@ struct ReportLocation {
 
 struct ReportThread {
   int id;
-  int pid;
+  uptr pid;
   bool running;
   char *name;
   ReportStack *stack;
index f2b18e9..d2487ef 100644 (file)
@@ -327,7 +327,7 @@ struct ThreadDeadInfo {
 struct ThreadContext {
   const int tid;
   int unique_id;  // Non-rolling thread id.
-  int os_id;  // pid
+  uptr os_id;  // pid
   uptr user_id;  // Some opaque user thread id (e.g. pthread_t).
   ThreadState *thr;
   ThreadStatus status;
@@ -481,7 +481,7 @@ void FuncEntry(ThreadState *thr, uptr pc);
 void FuncExit(ThreadState *thr);
 
 int ThreadCreate(ThreadState *thr, uptr pc, uptr uid, bool detached);
-void ThreadStart(ThreadState *thr, int tid, int os_id);
+void ThreadStart(ThreadState *thr, int tid, uptr os_id);
 void ThreadFinish(ThreadState *thr);
 int ThreadTid(ThreadState *thr, uptr pc, uptr uid);
 void ThreadJoin(ThreadState *thr, uptr pc, int tid);
index 47884b4..ee287cb 100644 (file)
@@ -137,7 +137,7 @@ int ThreadCreate(ThreadState *thr, uptr pc, uptr uid, bool detached) {
   return tid;
 }
 
-void ThreadStart(ThreadState *thr, int tid, int os_id) {
+void ThreadStart(ThreadState *thr, int tid, uptr os_id) {
   CHECK_GT(thr->in_rtl, 0);
   uptr stk_addr = 0;
   uptr stk_size = 0;