chromium/base/memory/madv_free_discardable_memory_posix.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40284755): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "base/memory/madv_free_discardable_memory_posix.h"

#include <errno.h>
#include <inttypes.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/utsname.h>

#include <atomic>

#include "base/atomicops.h"
#include "base/bits.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/memory/madv_free_discardable_memory_allocator_posix.h"
#include "base/memory/page_size.h"
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/tracing_buildflags.h"
#include "build/build_config.h"

#if BUILDFLAG(IS_ANDROID)
#include <sys/prctl.h>
#endif

#if BUILDFLAG(ENABLE_BASE_TRACING)
#include "base/trace_event/memory_allocator_dump.h"  // no-presubmit-check
#include "base/trace_event/memory_dump_manager.h"    // no-presubmit-check
#endif  // BUILDFLAG(ENABLE_BASE_TRACING)

#if defined(ADDRESS_SANITIZER)
#include <sanitizer/asan_interface.h>
#endif  // defined(ADDRESS_SANITIZER)

namespace {

constexpr intptr_t kPageMagicCookie =;

void* AllocatePages(size_t size_in_pages) {}

// Checks if the system supports usage of MADV_FREE as a backing for discardable
// memory.
base::MadvFreeSupport ProbePlatformMadvFreeSupport() {}

}  // namespace

namespace base {

MadvFreeDiscardableMemoryPosix::MadvFreeDiscardableMemoryPosix(
    size_t size_in_bytes,
    std::atomic<size_t>* allocator_byte_count)
    :{}

MadvFreeDiscardableMemoryPosix::~MadvFreeDiscardableMemoryPosix() {}

bool MadvFreeDiscardableMemoryPosix::Lock() {}

void MadvFreeDiscardableMemoryPosix::Unlock() {}

void* MadvFreeDiscardableMemoryPosix::data() const {}

bool MadvFreeDiscardableMemoryPosix::LockPage(size_t page_index) {}

void MadvFreeDiscardableMemoryPosix::UnlockPage(size_t page_index) {}

void MadvFreeDiscardableMemoryPosix::DiscardPage(size_t page_index) {}

bool MadvFreeDiscardableMemoryPosix::IsLockedForTesting() const {}

void MadvFreeDiscardableMemoryPosix::DiscardForTesting() {}

trace_event::MemoryAllocatorDump*
MadvFreeDiscardableMemoryPosix::CreateMemoryAllocatorDump(
    const char* name,
    trace_event::ProcessMemoryDump* pmd) const {}

bool MadvFreeDiscardableMemoryPosix::IsValid() const {}

void MadvFreeDiscardableMemoryPosix::SetKeepMemoryForTesting(bool keep_memory) {}

bool MadvFreeDiscardableMemoryPosix::IsResident() const {}

bool MadvFreeDiscardableMemoryPosix::IsDiscarded() const {}

bool MadvFreeDiscardableMemoryPosix::Deallocate() {}

MadvFreeSupport GetMadvFreeSupport() {}

}  // namespace base