chromium/base/allocator/partition_allocator/src/partition_alloc/partition_direct_map_extent.h

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PARTITION_ALLOC_PARTITION_DIRECT_MAP_EXTENT_H_
#define PARTITION_ALLOC_PARTITION_DIRECT_MAP_EXTENT_H_

#include "partition_alloc/partition_alloc_base/compiler_specific.h"
#include "partition_alloc/partition_alloc_check.h"
#include "partition_alloc/partition_bucket.h"
#include "partition_alloc/partition_page.h"

namespace partition_alloc::internal {

template <MetadataKind kind>
struct PartitionDirectMapExtent;

template <MetadataKind kind>
struct PartitionDirectMapExtentBase {};

template <MetadataKind kind>
struct PartitionDirectMapExtent;

template <>
struct PartitionDirectMapExtent<MetadataKind::kReadOnly>
    : public PartitionDirectMapExtentBase<MetadataKind::kReadOnly> {};

template <>
struct PartitionDirectMapExtent<MetadataKind::kWritable>
    : public PartitionDirectMapExtentBase<MetadataKind::kWritable> {};

// Metadata page for direct-mapped allocations.
template <MetadataKind kind>
struct PartitionDirectMapMetadataBase {};

template <MetadataKind kind>
struct PartitionDirectMapMetadata;

template <>
struct PartitionDirectMapMetadata<MetadataKind::kReadOnly>
    : public PartitionDirectMapMetadataBase<MetadataKind::kReadOnly> {};

template <>
struct PartitionDirectMapMetadata<MetadataKind::kWritable>
    : public PartitionDirectMapMetadataBase<MetadataKind::kWritable> {};

PA_ALWAYS_INLINE PartitionDirectMapMetadata<MetadataKind::kReadOnly>*
PartitionDirectMapMetadata<MetadataKind::kReadOnly>::FromSlotSpanMetadata(
    SlotSpanMetadata* slot_span) {}

PA_ALWAYS_INLINE PartitionDirectMapExtent<MetadataKind::kReadOnly>*
PartitionDirectMapExtent<MetadataKind::kReadOnly>::FromSlotSpanMetadata(
    SlotSpanMetadata* slot_span) {}

PA_ALWAYS_INLINE PartitionDirectMapMetadata<MetadataKind::kWritable>*
PartitionDirectMapMetadata<MetadataKind::kReadOnly>::ToWritable(
    const PartitionRoot* root) {}

template <typename T>
PartitionDirectMapMetadata<MetadataKind::kWritable>*
PartitionDirectMapMetadata<MetadataKind::kReadOnly>::ToWritableInternal(
    [[maybe_unused]] T* root) {}

PA_ALWAYS_INLINE PartitionDirectMapExtent<MetadataKind::kWritable>*
PartitionDirectMapExtent<MetadataKind::kReadOnly>::ToWritable(
    const PartitionRoot* root) {}

template <typename T>
PartitionDirectMapExtent<MetadataKind::kWritable>*
PartitionDirectMapExtent<MetadataKind::kReadOnly>::ToWritableInternal(
    [[maybe_unused]] T* root) {}

#if PA_BUILDFLAG(DCHECKS_ARE_ON)
PA_ALWAYS_INLINE PartitionDirectMapMetadata<MetadataKind::kReadOnly>*
PartitionDirectMapMetadata<MetadataKind::kReadOnly>::ToReadOnly() {}

PA_ALWAYS_INLINE PartitionDirectMapMetadata<MetadataKind::kReadOnly>*
PartitionDirectMapMetadata<MetadataKind::kWritable>::ToReadOnly(
    const PartitionRoot* root) {}

template <typename T>
PartitionDirectMapMetadata<MetadataKind::kReadOnly>*
PartitionDirectMapMetadata<MetadataKind::kWritable>::ToReadOnlyInternal(
    [[maybe_unused]] T* root) {}

PA_ALWAYS_INLINE PartitionDirectMapExtent<MetadataKind::kReadOnly>*
PartitionDirectMapExtent<MetadataKind::kReadOnly>::ToReadOnly() {}

PA_ALWAYS_INLINE PartitionDirectMapExtent<MetadataKind::kReadOnly>*
PartitionDirectMapExtent<MetadataKind::kWritable>::ToReadOnly(
    const PartitionRoot* root) {}

template <typename T>
PartitionDirectMapExtent<MetadataKind::kReadOnly>*
PartitionDirectMapExtent<MetadataKind::kWritable>::ToReadOnlyInternal(
    [[maybe_unused]] T* root) {}
#endif  // PA_BUILDFLAG(DCHECKS_ARE_ON)

}  // namespace partition_alloc::internal

#endif  // PARTITION_ALLOC_PARTITION_DIRECT_MAP_EXTENT_H_