[PATCH] D9638: Implement `internal_start/join_thread` on Mac OS X

Ismail Pazarbasi via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 10 18:46:49 PST 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL252696: Implement `internal_start/join_thread` on Mac OS X (authored by ismailp).

Changed prior to commit:
  http://reviews.llvm.org/D9638?vs=30596&id=39881#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D9638

Files:
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc

Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
@@ -371,8 +371,18 @@
   return info.resident_size;
 }
 
-void *internal_start_thread(void (*func)(void *arg), void *arg) { return 0; }
-void internal_join_thread(void *th) { }
+void *internal_start_thread(void(*func)(void *arg), void *arg) {
+  // Start the thread with signals blocked, otherwise it can steal user signals.
+  __sanitizer_sigset_t set, old;
+  internal_sigfillset(&set);
+  internal_sigprocmask(SIG_SETMASK, &set, &old);
+  pthread_t th;
+  pthread_create(&th, 0, (void*(*)(void *arg))func, arg);
+  internal_sigprocmask(SIG_SETMASK, &old, 0);
+  return th;
+}
+
+void internal_join_thread(void *th) { pthread_join((pthread_t)th, 0); }
 
 void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
   ucontext_t *ucontext = (ucontext_t*)context;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9638.39881.patch
Type: text/x-patch
Size: 1017 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151111/0a425548/attachment.bin>


More information about the llvm-commits mailing list