1 //===-- scudo_tls_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 /// Scudo thread local structure fastpath functions implementation for Android.
12 //===----------------------------------------------------------------------===//
14 #ifndef SCUDO_TLS_ANDROID_H_
15 #define SCUDO_TLS_ANDROID_H_
18 # error "This file must be included inside scudo_tls.h."
19 #endif // SCUDO_TLS_H_
21 #if SANITIZER_LINUX && SANITIZER_ANDROID
23 ALWAYS_INLINE void initThreadMaybe() {
24 if (LIKELY(*get_android_tls_ptr()))
29 ScudoThreadContext *getThreadContextAndLockSlow();
31 ALWAYS_INLINE ScudoThreadContext *getThreadContextAndLock() {
32 ScudoThreadContext *ThreadContext =
33 reinterpret_cast<ScudoThreadContext *>(*get_android_tls_ptr());
35 // Try to lock the currently associated context.
36 if (ThreadContext->tryLock())
38 // If it failed, go the slow path.
39 return getThreadContextAndLockSlow();
42 #endif // SANITIZER_LINUX && SANITIZER_ANDROID
44 #endif // SCUDO_TLS_ANDROID_H_