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

// Copyright 2023 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_SUPERPAGE_EXTENT_ENTRY_H_
#define PARTITION_ALLOC_PARTITION_SUPERPAGE_EXTENT_ENTRY_H_

#include <cstdint>

#include "partition_alloc/address_pool_manager.h"
#include "partition_alloc/address_pool_manager_types.h"
#include "partition_alloc/partition_alloc_constants.h"
#include "partition_alloc/partition_alloc_forward.h"
#include "partition_alloc/partition_dcheck_helper.h"
#include "partition_alloc/reservation_offset_table.h"

// Should not include partition_root.h, partition_bucket.h, partition_page.h.

namespace partition_alloc::internal {

template <MetadataKind kind>
struct PartitionSuperPageExtentEntry;

// An "extent" is a span of consecutive superpages. We link the partition's next
// extent (if there is one) to the very start of a superpage's metadata area.
template <MetadataKind kind>
struct PartitionSuperPageExtentEntryBase {};

template <MetadataKind kind>
struct PartitionSuperPageExtentEntry;

template <>
struct PartitionSuperPageExtentEntry<MetadataKind::kReadOnly>
    : public PartitionSuperPageExtentEntryBase<MetadataKind::kReadOnly> {};

template <>
struct PartitionSuperPageExtentEntry<MetadataKind::kWritable>
    : public PartitionSuperPageExtentEntryBase<MetadataKind::kWritable> {};

static_assert;
static_assert;
static_assert;

// Returns the base of the first super page in the range of consecutive super
// pages.
//
// CAUTION! |extent| must point to the extent of the first super page in the
// range of consecutive super pages.
PA_ALWAYS_INLINE uintptr_t SuperPagesBeginFromExtent(
    const PartitionSuperPageExtentEntry<MetadataKind::kReadOnly>* extent) {}

// Returns the end of the last super page in the range of consecutive super
// pages.
//
// CAUTION! |extent| must point to the extent of the first super page in the
// range of consecutive super pages.
PA_ALWAYS_INLINE uintptr_t SuperPagesEndFromExtent(
    const PartitionSuperPageExtentEntry<MetadataKind::kReadOnly>* extent) {}

}  // namespace partition_alloc::internal

#endif  // PARTITION_ALLOC_PARTITION_SUPERPAGE_EXTENT_ENTRY_H_