[AArch64] Fix SDNode type mismatches between *.td files and ISel (#116523)
[llvm-project.git] / compiler-rt / lib / msan / msan_thread.h
blobf6ed1534cccdfa9f38afdc77bd08d0d3c29402d4
1 //===-- msan_thread.h -------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file is a part of MemorySanitizer.
11 //===----------------------------------------------------------------------===//
13 #ifndef MSAN_THREAD_H
14 #define MSAN_THREAD_H
16 #include "msan_allocator.h"
17 #include "sanitizer_common/sanitizer_common.h"
18 #include "sanitizer_common/sanitizer_posix.h"
19 namespace __msan {
21 class MsanThread {
22 public:
23 static MsanThread *Create(thread_callback_t start_routine, void *arg);
24 static void TSDDtor(void *tsd);
25 void Destroy();
27 void Init(); // Should be called from the thread itself.
28 thread_return_t ThreadStart();
30 uptr stack_top();
31 uptr stack_bottom();
32 uptr tls_begin() { return tls_begin_; }
33 uptr tls_end() { return tls_end_; }
34 bool IsMainThread() { return start_routine_ == nullptr; }
36 bool AddrIsInStack(uptr addr);
38 bool InSignalHandler() { return in_signal_handler_; }
39 void EnterSignalHandler() { in_signal_handler_++; }
40 void LeaveSignalHandler() { in_signal_handler_--; }
42 void StartSwitchFiber(uptr bottom, uptr size);
43 void FinishSwitchFiber(uptr *bottom_old, uptr *size_old);
45 MsanThreadLocalMallocStorage &malloc_storage() { return malloc_storage_; }
47 int destructor_iterations_;
48 __sanitizer_sigset_t starting_sigset_;
50 private:
51 // NOTE: There is no MsanThread constructor. It is allocated
52 // via mmap() and *must* be valid in zero-initialized state.
53 void SetThreadStackAndTls();
54 void ClearShadowForThreadStackAndTLS();
55 struct StackBounds {
56 uptr bottom;
57 uptr top;
59 StackBounds GetStackBounds() const;
60 thread_callback_t start_routine_;
61 void *arg_;
63 bool stack_switching_;
65 StackBounds stack_;
66 StackBounds next_stack_;
68 uptr tls_begin_;
69 uptr tls_end_;
71 unsigned in_signal_handler_;
73 MsanThreadLocalMallocStorage malloc_storage_;
76 MsanThread *GetCurrentThread();
77 void SetCurrentThread(MsanThread *t);
79 } // namespace __msan
81 #endif // MSAN_THREAD_H