1 //===-- scudo_tsd_shared.inc ------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 /// Scudo shared TSD fastpath functions implementation.
12 //===----------------------------------------------------------------------===//
15 # error "This file must be included inside scudo_tsd.h."
16 #endif // SCUDO_TSD_H_
18 #if !SCUDO_TSD_EXCLUSIVE
20 extern pthread_key_t PThreadKey;
22 ALWAYS_INLINE ScudoTSD* getCurrentTSD() {
24 return reinterpret_cast<ScudoTSD *>(*get_android_tls_ptr());
26 return reinterpret_cast<ScudoTSD *>(pthread_getspecific(PThreadKey));
27 #endif // SANITIZER_ANDROID
30 ALWAYS_INLINE void initThreadMaybe(bool MinimalInit = false) {
31 if (LIKELY(getCurrentTSD()))
33 initThread(MinimalInit);
36 ScudoTSD *getTSDAndLockSlow();
38 ALWAYS_INLINE ScudoTSD *getTSDAndLock() {
39 ScudoTSD *TSD = getCurrentTSD();
40 CHECK(TSD && "No TSD associated with the current thread!");
41 // Try to lock the currently associated context.
44 // If it failed, go the slow path.
45 return getTSDAndLockSlow();
48 #endif // !SCUDO_TSD_EXCLUSIVE