mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-05-27 21:24:11 -04:00
fssystem: Implement PartitionFileSystemCore (#856)
* fssystem: implement PartitionFileSystemMetaCore * fssystem: PartitionFileSystemMetaCore cleanup * fs: add IFile::DryWrite, update results * fssystem: implement PartitionFileSystemCore * fssystem: cleanup PartitionFileSystemCore * fssystem: implement Sha256PartitionFileSystem Co-authored-by: Michael Scire <SciresM@gmail.com>
This commit is contained in:
parent
0af2758fde
commit
3d518759da
9 changed files with 949 additions and 2 deletions
58
libraries/libvapours/include/vapours/allocator.hpp
Normal file
58
libraries/libvapours/include/vapours/allocator.hpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
|
||||
namespace ams {
|
||||
|
||||
constexpr inline size_t DefaultAlignment = alignof(max_align_t);
|
||||
|
||||
using AllocateFunction = void *(*)(size_t);
|
||||
using AllocateFunctionWithUserData = void *(*)(size_t, void *);
|
||||
using AlignedAllocateFunction = void *(*)(size_t, size_t);
|
||||
using AlignedAllocateFunctionWithUserData = void *(*)(size_t, size_t, void *);
|
||||
using DeallocateFunction = void (*)(void *, size_t);
|
||||
using FreeFunction = void (*)(void *);
|
||||
using FreeFunctionWithUserData = void (*)(void *, void *);
|
||||
|
||||
class MemoryResource {
|
||||
public:
|
||||
ALWAYS_INLINE void *allocate(size_t size, size_t alignment = DefaultAlignment) {
|
||||
return this->AllocateImpl(size, alignment);
|
||||
}
|
||||
ALWAYS_INLINE void deallocate(void *buffer, size_t size, size_t alignment = DefaultAlignment) {
|
||||
this->DeallocateImpl(buffer, size, alignment);
|
||||
}
|
||||
ALWAYS_INLINE bool is_equal(const MemoryResource &resource) const {
|
||||
return this->IsEqualImpl(resource);
|
||||
}
|
||||
ALWAYS_INLINE void *Allocate(size_t size, size_t alignment = DefaultAlignment) {
|
||||
return this->AllocateImpl(size, alignment);
|
||||
}
|
||||
ALWAYS_INLINE void Deallocate(void *buffer, size_t size, size_t alignment = DefaultAlignment) {
|
||||
this->DeallocateImpl(buffer, size, alignment);
|
||||
}
|
||||
ALWAYS_INLINE bool IsEqual(const MemoryResource &resource) const {
|
||||
return this->IsEqualImpl(resource);
|
||||
}
|
||||
protected:
|
||||
virtual void *AllocateImpl(size_t size, size_t alignment) = 0;
|
||||
virtual void DeallocateImpl(void *buffer, size_t size, size_t alignment) = 0;
|
||||
virtual bool IsEqualImpl(const MemoryResource &resource) const = 0;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue