1 //===-- scudo_tsd.h ---------------------------------------------*- 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 thread specific data definition.
11 /// Implementation will differ based on the thread local storage primitives
12 /// offered by the underlying platform.
14 //===----------------------------------------------------------------------===//
19 #include "scudo_allocator.h"
20 #include "scudo_utils.h"
26 struct ALIGNED(64) ScudoTSD {
28 uptr QuarantineCachePlaceHolder[4];
30 void init(bool Shared);
33 INLINE bool tryLock() {
34 if (Mutex.TryLock()) {
35 atomic_store_relaxed(&Precedence, 0);
38 if (atomic_load_relaxed(&Precedence) == 0)
39 atomic_store_relaxed(&Precedence, MonotonicNanoTime());
45 atomic_store_relaxed(&Precedence, 0);
48 INLINE void unlock() {
54 INLINE u64 getPrecedence() {
55 return atomic_load_relaxed(&Precedence);
60 StaticSpinMutex Mutex;
61 atomic_uint64_t Precedence;
64 void initThread(bool MinimalInit);
66 // TSD model specific fastpath functions definitions.
67 #include "scudo_tsd_exclusive.inc"
68 #include "scudo_tsd_shared.inc"
70 } // namespace __scudo
72 #endif // SCUDO_TSD_H_