Path: blob/main/contrib/llvm-project/compiler-rt/lib/scudo/standalone/bytemap.h
35292 views
//===-- bytemap.h -----------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef SCUDO_BYTEMAP_H_9#define SCUDO_BYTEMAP_H_1011#include "atomic_helpers.h"12#include "common.h"13#include "mutex.h"1415namespace scudo {1617template <uptr Size> class FlatByteMap {18public:19void init() { DCHECK(Size == 0 || Map[0] == 0); }2021void unmapTestOnly() { memset(Map, 0, Size); }2223void set(uptr Index, u8 Value) {24DCHECK_LT(Index, Size);25DCHECK_EQ(0U, Map[Index]);26Map[Index] = Value;27}28u8 operator[](uptr Index) {29DCHECK_LT(Index, Size);30return Map[Index];31}3233void disable() {}34void enable() {}3536private:37u8 Map[Size] = {};38};3940} // namespace scudo4142#endif // SCUDO_BYTEMAP_H_434445