[+] AuDummyHeap

This commit is contained in:
Reece Wilson 2024-12-04 09:48:22 +00:00
parent 2986577cb7
commit ece8482645
5 changed files with 88 additions and 9 deletions

View File

@ -1 +1,27 @@
// TODO:
/***
Copyright (C) 2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auDummyHeap.hpp
Date: 2024-12-2
Author: Reece
Note: Do not use me, if the Aurora Runtime is present.
Use AuMemory::GetDefaultDiscontiguousHeap() / AuMemory::GetDefaultDiscontiguousHeapShared() / AuMemory::AuMemory::DefaultDiscontiguousHeapGenericUnique() / related
...instead.
This interface provides a barebones AuHeap given the three static memory allocation functions required by this template library.
See: NoRuntime/auMemoryAlloc.hpp for their Aurora Runtimeless dummy implementations
***/
#pragma once
struct AuDummyHeap : AuHeap
{
inline AuSPtr<AuHeap> AllocateDivision(AuUInt32 heap, AuUInt32 alignment = 32) override;
inline AuUInt GetChunkSize(const void *pHead) override;
inline AuHeapStats & GetStats() override;
inline void WalkHeap(bool(*fCallback)(void *, void *), void *pSecondArg) override;
inline AuSPtr<AuHeap> GetSelfReference() override;
inline AuHeap * GetSelfReferenceRaw() override;
inline void * _FAlloc(AuUInt uLength, AuUInt uAlignment) override;
inline void _Free(void* pBase) override;
};
AU_INLINE_OR_STATIC_17 AuDummyHeap gDummyHeap;

View File

@ -1 +1,53 @@
// TODO:
/***
Copyright (C) 2024 Jamie Reece Wilson (a/k/a "Reece"). All rights reserved.
File: auDummyHeap.ipp
Date: 2024-12-2
Author: Reece
***/
#pragma once
namespace __audetail
{
static AuHeapStats gDummyStats;
}
AuSPtr<AuHeap> AuDummyHeap::AllocateDivision(AuUInt32 heap, AuUInt32 alignment)
{
return {};
}
AuUInt AuDummyHeap::GetChunkSize(const void *pHead)
{
return pHead ? Aurora::Memory::__SizeOf((void *)pHead) : 0u;
}
AuHeapStats & AuDummyHeap::GetStats()
{
return __audetail::gDummyStats;
}
void AuDummyHeap::WalkHeap(bool(*fCallback)(void *, void *), void *pSecondArg)
{
}
AuSPtr<AuHeap> AuDummyHeap::GetSelfReference()
{
return {};
}
AuHeap * AuDummyHeap::GetSelfReferenceRaw()
{
return this;
}
void * AuDummyHeap::_FAlloc(AuUInt uLength, AuUInt uAlignment)
{
return Aurora::Memory::__FAlloc(uLength, uAlignment);
}
void AuDummyHeap::_Free(void* pBase)
{
Aurora::Memory::__Free(pBase);
}

View File

@ -87,7 +87,7 @@ public:
#if defined(AU_LANG_CPP_14_)
template <class T, class ...Args>
template <class T, class ...Args>
AuSPtr<T> NewClass(Args &&...args);
// Same behaviour as NewClass, except pControlBlockHeap is used by the weak reference list or detached atomic counting block
@ -125,7 +125,7 @@ public:
using HUPOf_t = AuUPtr<T, void(*)(T *)>;
#endif
template <class T>
cstatic AuUPtr<T, void(*)(T *)> NullUniquePointer();

View File

@ -688,7 +688,7 @@ void *AuHeap::_FAlloc(AuUInt uLength)
{
return nullptr;
}
#if defined(AU_LANG_CPP_14_)
return this->_FAlloc(uLength, alignof(void *));
#else
@ -852,10 +852,10 @@ namespace __audetail
{
inline AuSPtr<AuUInt8> AllocateArray(AuHeap *pAuHeap, AuUInt uLength, AuUInt32 uAlignment)
{
#if defined(AU_LANG_CPP_14_)
#if defined(AU_LANG_CPP_14_)
return pAuHeap->NewClassArray2<AuUInt8>(uLength, uAlignment);
#else
return AuSPtr<AuUInt8>();
#endif
#else
return AuSPtr<AuUInt8>();
#endif
}
}

View File

@ -80,6 +80,7 @@ namespace __audetail
#include <auROXTL/MemoryModel/auHeap.ipp>
#include <auROXTL/MemoryModel/auUniquePointer.ipp>
#include <auROXTL/MemoryModel/auMemoryView.ipp>
#include <auROXTL/MemoryModel/auDummyHeap.ipp>
struct IAuNullDelegate
{