xref: /netbsd-src/external/gpl3/gcc.old/dist/libsanitizer/lsan/lsan_thread.h (revision 7863ba460b0a05b553c754e5dbc29247dddec322)
1 //=-- lsan_thread.h -------------------------------------------------------===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of LeakSanitizer.
9 // Thread registry for standalone LSan.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LSAN_THREAD_H
14 #define LSAN_THREAD_H
15 
16 #include "sanitizer_common/sanitizer_thread_registry.h"
17 
18 namespace __lsan {
19 
20 class ThreadContext : public ThreadContextBase {
21  public:
22   explicit ThreadContext(int tid);
23   void OnStarted(void *arg);
24   void OnFinished();
25   uptr stack_begin() { return stack_begin_; }
26   uptr stack_end() { return stack_end_; }
27   uptr tls_begin() { return tls_begin_; }
28   uptr tls_end() { return tls_end_; }
29   uptr cache_begin() { return cache_begin_; }
30   uptr cache_end() { return cache_end_; }
31  private:
32   uptr stack_begin_, stack_end_,
33        cache_begin_, cache_end_,
34        tls_begin_, tls_end_;
35 };
36 
37 void InitializeThreadRegistry();
38 
39 void ThreadStart(u32 tid, uptr os_id);
40 void ThreadFinish();
41 u32 ThreadCreate(u32 tid, uptr uid, bool detached);
42 void ThreadJoin(u32 tid);
43 u32 ThreadTid(uptr uid);
44 
45 u32 GetCurrentThread();
46 void SetCurrentThread(u32 tid);
47 ThreadContext *CurrentThreadContext();
48 void EnsureMainThreadIDIsCorrect();
49 }  // namespace __lsan
50 
51 #endif  // LSAN_THREAD_H
52