thread cannot be used for lsan or msan on Android, because its emutls implementation relies on functions that will be intercepted. This revision replaces thread with a struct stored in TLS_SLOT_TSAN.
msan requires corresponding changes (D22550) to LLVM MemorySanitizer.cpp.
No system headers in this file.
This code should go in sanitizer_common as something similar to InstallDeadlySignalHandlers. We can use it in other sanitizers to dump allocator stats, for example.
Please upload it as a separate change.