]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/scudo/scudo_tls_android.inc
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r302418, and update
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / scudo / scudo_tls_android.inc
1 //===-- scudo_tls_android.inc -----------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// Scudo thread local structure fastpath functions implementation for Android.
11 ///
12 //===----------------------------------------------------------------------===//
13
14 #ifndef SCUDO_TLS_ANDROID_H_
15 #define SCUDO_TLS_ANDROID_H_
16
17 #ifndef SCUDO_TLS_H_
18 # error "This file must be included inside scudo_tls.h."
19 #endif  // SCUDO_TLS_H_
20
21 #if SANITIZER_LINUX && SANITIZER_ANDROID
22
23 ALWAYS_INLINE void initThreadMaybe() {
24   if (LIKELY(*get_android_tls_ptr()))
25     return;
26   initThread();
27 }
28
29 ScudoThreadContext *getThreadContextAndLockSlow();
30
31 ALWAYS_INLINE ScudoThreadContext *getThreadContextAndLock() {
32   ScudoThreadContext *ThreadContext =
33       reinterpret_cast<ScudoThreadContext *>(*get_android_tls_ptr());
34   CHECK(ThreadContext);
35   // Try to lock the currently associated context.
36   if (ThreadContext->tryLock())
37     return ThreadContext;
38   // If it failed, go the slow path.
39   return getThreadContextAndLockSlow();
40 }
41
42 #endif  // SANITIZER_LINUX && SANITIZER_ANDROID
43
44 #endif  // SCUDO_TLS_ANDROID_H_