]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/lsan/lsan_thread.h
Merge compiler-rt trunk r300890, and update build glue.
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / lsan / lsan_thread.h
1 //=-- lsan_thread.h -------------------------------------------------------===//
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 // This file is a part of LeakSanitizer.
11 // Thread registry for standalone LSan.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LSAN_THREAD_H
16 #define LSAN_THREAD_H
17
18 #include "sanitizer_common/sanitizer_thread_registry.h"
19
20 namespace __sanitizer {
21 struct DTLS;
22 }
23
24 namespace __lsan {
25
26 class ThreadContext : public ThreadContextBase {
27  public:
28   explicit ThreadContext(int tid);
29   void OnStarted(void *arg) override;
30   void OnFinished() override;
31   uptr stack_begin() { return stack_begin_; }
32   uptr stack_end() { return stack_end_; }
33   uptr tls_begin() { return tls_begin_; }
34   uptr tls_end() { return tls_end_; }
35   uptr cache_begin() { return cache_begin_; }
36   uptr cache_end() { return cache_end_; }
37   DTLS *dtls() { return dtls_; }
38
39  private:
40   uptr stack_begin_, stack_end_,
41        cache_begin_, cache_end_,
42        tls_begin_, tls_end_;
43   DTLS *dtls_;
44 };
45
46 void InitializeThreadRegistry();
47
48 void ThreadStart(u32 tid, tid_t os_id);
49 void ThreadFinish();
50 u32 ThreadCreate(u32 tid, uptr uid, bool detached);
51 void ThreadJoin(u32 tid);
52 u32 ThreadTid(uptr uid);
53
54 u32 GetCurrentThread();
55 void SetCurrentThread(u32 tid);
56 ThreadContext *CurrentThreadContext();
57 void EnsureMainThreadIDIsCorrect();
58 }  // namespace __lsan
59
60 #endif  // LSAN_THREAD_H