diff options
Diffstat (limited to 'lib/scudo/scudo_tsd_shared.inc')
-rw-r--r-- | lib/scudo/scudo_tsd_shared.inc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/scudo/scudo_tsd_shared.inc b/lib/scudo/scudo_tsd_shared.inc index 79fcd651ed2d..9dad756b5386 100644 --- a/lib/scudo/scudo_tsd_shared.inc +++ b/lib/scudo/scudo_tsd_shared.inc @@ -19,9 +19,16 @@ extern pthread_key_t PThreadKey; +#if SANITIZER_LINUX && !SANITIZER_ANDROID +__attribute__((tls_model("initial-exec"))) +extern THREADLOCAL ScudoTSD *CurrentTSD; +#endif + ALWAYS_INLINE ScudoTSD* getCurrentTSD() { #if SANITIZER_ANDROID return reinterpret_cast<ScudoTSD *>(*get_android_tls_ptr()); +#elif SANITIZER_LINUX + return CurrentTSD; #else return reinterpret_cast<ScudoTSD *>(pthread_getspecific(PThreadKey)); #endif // SANITIZER_ANDROID @@ -33,16 +40,17 @@ ALWAYS_INLINE void initThreadMaybe(bool MinimalInit = false) { initThread(MinimalInit); } -ScudoTSD *getTSDAndLockSlow(); +ScudoTSD *getTSDAndLockSlow(ScudoTSD *TSD); -ALWAYS_INLINE ScudoTSD *getTSDAndLock() { +ALWAYS_INLINE ScudoTSD *getTSDAndLock(bool *UnlockRequired) { ScudoTSD *TSD = getCurrentTSD(); - CHECK(TSD && "No TSD associated with the current thread!"); + DCHECK(TSD && "No TSD associated with the current thread!"); + *UnlockRequired = true; // Try to lock the currently associated context. if (TSD->tryLock()) return TSD; // If it failed, go the slow path. - return getTSDAndLockSlow(); + return getTSDAndLockSlow(TSD); } #endif // !SCUDO_TSD_EXCLUSIVE |