1 //===-- scudo_tsd_exclusive.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 exclusive 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 enum ThreadState : u8 {
21 ThreadNotInitialized = 0,
25 __attribute__((tls_model("initial-exec")))
26 extern THREADLOCAL ThreadState ScudoThreadState;
27 __attribute__((tls_model("initial-exec")))
28 extern THREADLOCAL ScudoTSD TSD;
30 extern ScudoTSD FallbackTSD;
32 ALWAYS_INLINE void initThreadMaybe(bool MinimalInit = false) {
33 if (LIKELY(ScudoThreadState != ThreadNotInitialized))
35 initThread(MinimalInit);
38 ALWAYS_INLINE ScudoTSD *getTSDAndLock(bool *UnlockRequired) {
39 if (UNLIKELY(ScudoThreadState != ThreadInitialized)) {
41 *UnlockRequired = true;
44 *UnlockRequired = false;
48 #endif // SCUDO_TSD_EXCLUSIVE