]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/compiler-rt/lib/scudo/standalone/bytemap.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm-project / compiler-rt / lib / scudo / standalone / bytemap.h
1 //===-- bytemap.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 #ifndef SCUDO_BYTEMAP_H_
10 #define SCUDO_BYTEMAP_H_
11
12 #include "atomic_helpers.h"
13 #include "common.h"
14 #include "mutex.h"
15
16 namespace scudo {
17
18 template <uptr Size> class FlatByteMap {
19 public:
20   void initLinkerInitialized() {}
21   void init() { memset(Map, 0, sizeof(Map)); }
22
23   void unmapTestOnly() {}
24
25   void set(uptr Index, u8 Value) {
26     DCHECK_LT(Index, Size);
27     DCHECK_EQ(0U, Map[Index]);
28     Map[Index] = Value;
29   }
30   u8 operator[](uptr Index) {
31     DCHECK_LT(Index, Size);
32     return Map[Index];
33   }
34
35   void disable() {}
36   void enable() {}
37
38 private:
39   u8 Map[Size];
40 };
41
42 } // namespace scudo
43
44 #endif // SCUDO_BYTEMAP_H_