#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "base/metrics/persistent_memory_allocator.h"
#include <assert.h>
#include <algorithm>
#include <atomic>
#include <optional>
#include <string_view>
#include "base/bits.h"
#include "base/containers/contains.h"
#include "base/debug/alias.h"
#include "base/debug/crash_logging.h"
#include "base/debug/dump_without_crashing.h"
#include "base/files/memory_mapped_file.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/persistent_histogram_allocator.h"
#include "base/metrics/sparse_histogram.h"
#include "base/notreached.h"
#include "base/numerics/checked_math.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/strcat.h"
#include "base/system/sys_info.h"
#include "base/threading/scoped_blocking_call.h"
#include "build/build_config.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#include <winbase.h>
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
#include <sys/mman.h>
#if BUILDFLAG(IS_ANDROID)
#include <sys/prctl.h>
#endif
#endif
namespace {
constexpr uint32_t kSegmentMaxSize = …;
constexpr uint32_t kGlobalCookie = …;
constexpr uint32_t kGlobalVersion = …;
static constexpr uint32_t kOldCompatibleVersions[] = …;
constexpr uint32_t kBlockCookieFree = …;
constexpr uint32_t kBlockCookieQueue = …;
constexpr uint32_t kBlockCookieWasted = …;
constexpr uint32_t kBlockCookieAllocated = …;
constexpr uint32_t kFlagCorrupt = …;
constexpr uint32_t kFlagFull = …;
enum AllocatorError : int { … };
bool CheckFlag(const volatile std::atomic<uint32_t>* flags, uint32_t flag) { … }
void SetFlag(volatile std::atomic<uint32_t>* flags, uint32_t flag) { … }
}
base