CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Common/MemoryUtilHorizon.cpp
Views: 1401
// Copyright (C) 2003 Dolphin Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official SVN repository and contact information can be found at15// http://code.google.com/p/dolphin-emu/1617#include "ppsspp_config.h"1819#if PPSSPP_PLATFORM(SWITCH)20#include <cstring>21#include <cstdlib>2223#include "Common/CommonTypes.h"24#include "Common/Log.h"25#include "Common/MemoryUtil.h"26#include "Common/StringUtils.h"27#include "Common/SysError.h"2829#include <errno.h>30#include <stdio.h>3132#include <malloc.h> // memalign3334#define MEM_PAGE_SIZE (0x1000)35#define MEM_PAGE_MASK ((MEM_PAGE_SIZE)-1)36#define ppsspp_round_page(x) ((((uintptr_t)(x)) + MEM_PAGE_MASK) & ~(MEM_PAGE_MASK))3738// On Switch we dont support allocating executable memory here39// See CodeBlock.h40void *AllocateExecutableMemory(size_t size) {41return nullptr;42}4344void *AllocateMemoryPages(size_t size, uint32_t memProtFlags) {45void* ptr = nullptr;46size = ppsspp_round_page(size);47ptr = memalign(MEM_PAGE_SIZE, size);48return ptr;49}5051void *AllocateAlignedMemory(size_t size, size_t alignment) {52void* ptr = memalign(alignment, size);5354_assert_msg_(ptr != nullptr, "Failed to allocate aligned memory of size %lu", size);55return ptr;56}5758void FreeMemoryPages(void *ptr, size_t size) {59if (!ptr)60return;6162free(ptr);63return;64}6566void FreeExecutableMemory(void *ptr, size_t size) {67return; // Not supported on Switch68}6970void FreeAlignedMemory(void* ptr) {71if (!ptr)72return;7374free(ptr);75}7677bool PlatformIsWXExclusive() {78return false; // Switch technically is W^X but we use dual mappings instead of reprotecting the pages to allow a W and X mapping79}8081bool ProtectMemoryPages(const void* ptr, size_t size, uint32_t memProtFlags) {82return true;83}8485int GetMemoryProtectPageSize() {86return MEM_PAGE_SIZE;87}88#endif // PPSSPP_PLATFORM(SWITCH)899091