[PATCH] D31883: Don't assume PTHREAD_CREATE_JOINABLE is 0 on all systems

Francis Ricci via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 13 10:41:43 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL300221: Don't assume PTHREAD_CREATE_JOINABLE is 0 on all systems (authored by fjricci).

Changed prior to commit:
  https://reviews.llvm.org/D31883?vs=95016&id=95164#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31883

Files:
  compiler-rt/trunk/lib/lsan/lsan_interceptors.cc
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.h
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc
  compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc


Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cc
@@ -418,6 +418,10 @@
   return process_status;
 }
 
+bool IsStateDetached(int state) {
+  return state == PTHREAD_CREATE_DETACHED;
+}
+
 } // namespace __sanitizer
 
 #endif // SANITIZER_POSIX
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.h
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.h
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.h
@@ -87,6 +87,9 @@
 
 uptr internal_execve(const char *filename, char *const argv[],
                      char *const envp[]);
+
+bool IsStateDetached(int state);
+
 }  // namespace __sanitizer
 
 #endif  // SANITIZER_POSIX_H
Index: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
===================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
@@ -18,6 +18,7 @@
 #include "sanitizer_common/sanitizer_linux.h"
 #include "sanitizer_common/sanitizer_platform_limits_posix.h"
 #include "sanitizer_common/sanitizer_placement_new.h"
+#include "sanitizer_common/sanitizer_posix.h"
 #include "sanitizer_common/sanitizer_stacktrace.h"
 #include "sanitizer_common/sanitizer_tls_get_addr.h"
 #include "interception/interception.h"
@@ -29,9 +30,6 @@
 #include "tsan_mman.h"
 #include "tsan_fd.h"
 
-#if SANITIZER_POSIX
-#include "sanitizer_common/sanitizer_posix.h"
-#endif
 
 using namespace __tsan;  // NOLINT
 
@@ -46,13 +44,6 @@
 #define mallopt(a, b)
 #endif
 
-#if SANITIZER_LINUX || SANITIZER_FREEBSD
-#define PTHREAD_CREATE_DETACHED 1
-#elif SANITIZER_MAC
-#define PTHREAD_CREATE_DETACHED 2
-#endif
-
-
 #ifdef __mips__
 const int kSigCount = 129;
 #else
@@ -928,8 +919,7 @@
     ThreadIgnoreEnd(thr, pc);
   }
   if (res == 0) {
-    int tid = ThreadCreate(thr, pc, *(uptr*)th,
-                           detached == PTHREAD_CREATE_DETACHED);
+    int tid = ThreadCreate(thr, pc, *(uptr*)th, IsStateDetached(detached));
     CHECK_NE(tid, 0);
     // Synchronization on p.tid serves two purposes:
     // 1. ThreadCreate must finish before the new thread starts.
Index: compiler-rt/trunk/lib/lsan/lsan_interceptors.cc
===================================================================
--- compiler-rt/trunk/lib/lsan/lsan_interceptors.cc
+++ compiler-rt/trunk/lib/lsan/lsan_interceptors.cc
@@ -21,6 +21,7 @@
 #include "sanitizer_common/sanitizer_linux.h"
 #include "sanitizer_common/sanitizer_platform_interceptors.h"
 #include "sanitizer_common/sanitizer_platform_limits_posix.h"
+#include "sanitizer_common/sanitizer_posix.h"
 #include "sanitizer_common/sanitizer_tls_get_addr.h"
 #include "lsan.h"
 #include "lsan_allocator.h"
@@ -281,7 +282,8 @@
     res = REAL(pthread_create)(th, attr, __lsan_thread_start_func, &p);
   }
   if (res == 0) {
-    int tid = ThreadCreate(GetCurrentThread(), *(uptr *)th, detached);
+    int tid = ThreadCreate(GetCurrentThread(), *(uptr *)th,
+                           IsStateDetached(detached));
     CHECK_NE(tid, 0);
     atomic_store(&p.tid, tid, memory_order_release);
     while (atomic_load(&p.tid, memory_order_acquire) != 0)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31883.95164.patch
Type: text/x-patch
Size: 3420 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170413/4d6abce2/attachment.bin>


More information about the llvm-commits mailing list