1 //===-- scudo_tls_context_android.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 /// Android specific base thread context definition.
12 //===----------------------------------------------------------------------===//
14 #ifndef SCUDO_TLS_CONTEXT_ANDROID_INC_
15 #define SCUDO_TLS_CONTEXT_ANDROID_INC_
18 # error "This file must be included inside scudo_tls.h."
19 #endif // SCUDO_TLS_H_
21 #if SANITIZER_LINUX && SANITIZER_ANDROID
23 struct ScudoThreadContextPlatform {
24 INLINE bool tryLock() {
25 if (Mutex.TryLock()) {
26 atomic_store_relaxed(&SlowLockPrecedence, 0);
29 if (atomic_load_relaxed(&SlowLockPrecedence) == 0)
30 atomic_store_relaxed(&SlowLockPrecedence, NanoTime());
36 atomic_store_relaxed(&SlowLockPrecedence, 0);
39 INLINE void unlock() {
43 INLINE u64 getSlowLockPrecedence() {
44 return atomic_load_relaxed(&SlowLockPrecedence);
48 StaticSpinMutex Mutex;
49 atomic_uint64_t SlowLockPrecedence;
52 #endif // SANITIZER_LINUX && SANITIZER_ANDROID
54 #endif // SCUDO_TLS_CONTEXT_ANDROID_INC_