2021-06-27 21:25:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: Heap.cpp
|
|
|
|
Date: 2021-6-12
|
|
|
|
Author: Reece
|
|
|
|
***/
|
2021-09-30 14:57:41 +00:00
|
|
|
#include <Source/RuntimeInternal.hpp>
|
2021-06-27 21:25:29 +00:00
|
|
|
#include "Memory.hpp"
|
|
|
|
#include "Heap.hpp"
|
|
|
|
|
|
|
|
#include "mimalloc.h"
|
|
|
|
#include "o1heap.hpp"
|
|
|
|
|
2022-03-22 03:53:08 +00:00
|
|
|
#if defined(AURORA_IS_POSIX_DERIVED)
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#endif
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
namespace Aurora::Memory
|
|
|
|
{
|
2021-10-14 11:35:05 +00:00
|
|
|
static AuUInt32 RoundPageUp(AuUInt32 value)
|
|
|
|
{
|
|
|
|
auto pageMask = HWInfo::GetPageSize() - 1;
|
|
|
|
return (value + pageMask) & ~(pageMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *HeapLargeAllocate(AuUInt length)
|
|
|
|
{
|
|
|
|
length = RoundPageUp(length);
|
|
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
|
|
return VirtualAlloc(nullptr, length, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
|
|
|
#elif defined(AURORA_IS_POSIX_DERIVED)
|
|
|
|
return mmap(0, length, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
|
|
|
#else
|
|
|
|
// ideally we should page align.
|
|
|
|
// i think mimalloc has fast paths with warnings for overly large passthrough allocations. unsure.
|
|
|
|
// 32 alignment in the fastest way mimalloc can provide us memory seems adequate
|
2022-01-19 15:25:47 +00:00
|
|
|
// it's very easy for mimalloc to seethe at larger allocations, but it does have slowpaths to handle them
|
2022-01-20 16:37:22 +00:00
|
|
|
return AuMemory::FAlloc<void *>(length, 32);
|
2021-10-14 11:35:05 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HeapLargeFree(void *buffer, AuUInt length)
|
|
|
|
{
|
|
|
|
length = RoundPageUp(length);
|
|
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
|
|
VirtualFree(buffer, 0, MEM_RELEASE);
|
|
|
|
#elif defined(AURORA_IS_POSIX_DERIVED)
|
|
|
|
munmap(buffer, length);
|
|
|
|
#else
|
2022-01-20 16:37:22 +00:00
|
|
|
AuMemory::Free(buffer);
|
2021-10-14 11:35:05 +00:00
|
|
|
mi_collect(false);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-12-07 01:29:09 +00:00
|
|
|
struct InternalHeap : BaseHeap, AuEnableSharedFromThis<InternalHeap>
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2022-07-21 09:59:02 +00:00
|
|
|
virtual AuSPtr<Heap> AllocateDivision(AuUInt32 heap, AuUInt32 alignment) override;
|
|
|
|
|
2023-06-28 09:33:12 +00:00
|
|
|
InternalHeap() : heap_(nullptr), count_(0)
|
2021-07-12 12:17:16 +00:00
|
|
|
{ }
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2022-07-21 09:59:02 +00:00
|
|
|
virtual ~InternalHeap();
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2022-07-21 09:59:02 +00:00
|
|
|
bool ownsMemory_ {};
|
|
|
|
bool Init(AuUInt length, void *ptr = nullptr);
|
2021-06-27 21:25:29 +00:00
|
|
|
|
|
|
|
typedef struct FragmentHeader
|
|
|
|
{
|
|
|
|
void *next;
|
|
|
|
void *prev;
|
|
|
|
size_t size;
|
|
|
|
bool used;
|
|
|
|
} FragmentHeader;
|
|
|
|
|
|
|
|
static AuUInt GetHeapSize(const void *ptr)
|
|
|
|
{
|
|
|
|
return reinterpret_cast<const FragmentHeader *>(ptr)[-1].size;
|
|
|
|
}
|
|
|
|
|
|
|
|
Types::size_t GetChunkSize(const void *head) override;
|
|
|
|
|
|
|
|
void *_FAlloc(Types::size_t length) override;
|
|
|
|
void *_FAlloc(Types::size_t length, Types::size_t align) override;
|
|
|
|
void *_ZAlloc(Types::size_t length) override;
|
|
|
|
void *_ZAlloc(Types::size_t length, Types::size_t align) override;
|
|
|
|
void *_ZRealloc(void *buffer, Types::size_t length) override;
|
|
|
|
void *_ZRealloc(void *buffer, Types::size_t length, Types::size_t align) override;
|
|
|
|
void *_FRealloc(void *buffer, Types::size_t length) override;
|
|
|
|
void *_FRealloc(void *buffer, Types::size_t length, Types::size_t align) override;
|
|
|
|
void _Free(void *buffer) override;
|
2022-01-18 19:31:15 +00:00
|
|
|
AuSPtr<Heap> GetSelfReference() override;
|
2021-07-12 12:17:16 +00:00
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
void TryRelease();
|
2022-01-18 19:42:32 +00:00
|
|
|
void DecrementUsers();
|
2021-06-27 21:25:29 +00:00
|
|
|
void RequestTermination();
|
|
|
|
|
2022-12-08 19:34:15 +00:00
|
|
|
void UpdateStats() override;
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
private:
|
2022-12-07 01:29:09 +00:00
|
|
|
|
2023-06-28 09:33:12 +00:00
|
|
|
AuThreadPrimitives::Mutex mutex_;
|
2022-12-07 01:29:09 +00:00
|
|
|
|
2021-07-12 12:17:16 +00:00
|
|
|
O1HeapInstance *heap_ {};
|
2021-11-05 17:34:23 +00:00
|
|
|
int count_ {};
|
|
|
|
bool isDangling_ {};
|
2021-06-27 21:25:29 +00:00
|
|
|
};
|
2021-07-12 12:17:16 +00:00
|
|
|
|
2022-07-21 09:59:02 +00:00
|
|
|
struct DeletableHeap : InternalHeap
|
|
|
|
{
|
|
|
|
Heap *parent {};
|
|
|
|
void *ptr2_ {};
|
|
|
|
|
|
|
|
DeletableHeap(Heap *parent, void *ptr);
|
|
|
|
~DeletableHeap();
|
|
|
|
};
|
|
|
|
|
|
|
|
DeletableHeap::DeletableHeap(Heap *parent, void *ptr) : parent(parent), ptr2_(ptr)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
DeletableHeap::~DeletableHeap()
|
|
|
|
{
|
|
|
|
if (this->ptr2_)
|
|
|
|
{
|
|
|
|
parent->Free(this->ptr2_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
InternalHeap::~InternalHeap()
|
|
|
|
{
|
2021-11-05 17:34:23 +00:00
|
|
|
SysAssertDbgExp(count_ == 0);
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2022-07-21 09:59:02 +00:00
|
|
|
if (this->base_)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2023-02-09 19:28:01 +00:00
|
|
|
if (this->heap_)
|
|
|
|
{
|
|
|
|
o1HeapReleaseCpp(this->heap_);// ->~O1HeapInstance(); // TODO: make free func
|
|
|
|
this->heap_ = nullptr;
|
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2022-07-21 09:59:02 +00:00
|
|
|
if (this->ownsMemory_)
|
|
|
|
{
|
|
|
|
HeapLargeFree(this->base_, this->length_);
|
|
|
|
this->base_ = nullptr;
|
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-21 09:59:02 +00:00
|
|
|
bool InternalHeap::Init(AuUInt length, void *ptr)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2022-07-21 09:59:02 +00:00
|
|
|
SysAssert(!this->base_, "heap already initialized");
|
2021-06-27 21:25:29 +00:00
|
|
|
|
|
|
|
SysAssert(length, "invalid heap allocation");
|
2022-07-21 09:59:02 +00:00
|
|
|
this->length_ = length;
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2022-07-21 09:59:02 +00:00
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
this->base_ = ptr;
|
|
|
|
this->ownsMemory_ = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->base_ = HeapLargeAllocate(length);
|
|
|
|
if (!base_) return false;
|
|
|
|
|
|
|
|
this->ownsMemory_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->heap_ = o1heapInit(this->base_, length,
|
2021-10-14 11:35:05 +00:00
|
|
|
[this](const O1HeapInstance *const handle) -> void
|
|
|
|
{
|
2022-01-18 14:26:38 +00:00
|
|
|
SysAssertDbg(this->mutex_, "missing mutex");
|
2021-10-14 11:35:05 +00:00
|
|
|
this->mutex_->Lock();
|
|
|
|
},
|
|
|
|
[this](const O1HeapInstance *const handle) -> void
|
|
|
|
{
|
2022-01-18 14:26:38 +00:00
|
|
|
SysAssertDbg(this->mutex_, "missing mutex");
|
2021-10-14 11:35:05 +00:00
|
|
|
this->mutex_->Unlock();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Types::size_t InternalHeap::GetChunkSize(const void *head)
|
|
|
|
{
|
|
|
|
return InternalHeap::GetHeapSize(head);
|
|
|
|
}
|
|
|
|
|
2022-07-21 09:59:02 +00:00
|
|
|
AuSPtr<Heap> InternalHeap::AllocateDivision(AuUInt32 heap, AuUInt32 alignment)
|
|
|
|
{
|
|
|
|
return AllocateDivisionGlobal(this, heap, alignment);
|
|
|
|
}
|
|
|
|
|
|
|
|
AuSPtr<Heap> AllocateDivisionGlobal(Heap *heap, AuUInt32 length, AuUInt32 alignment)
|
|
|
|
{
|
|
|
|
auto ptr = heap->ZAlloc<void *>(length, alignment);
|
|
|
|
if (!ptr)
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
auto ret = AuMakeShared<DeletableHeap>(heap, ptr);
|
|
|
|
if (!ret)
|
|
|
|
{
|
2022-08-16 22:58:18 +00:00
|
|
|
heap->Free(ptr);
|
2022-07-21 09:59:02 +00:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret->Init(length, ptr))
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
void *InternalHeap::_FAlloc(Types::size_t length)
|
|
|
|
{
|
2022-07-21 09:59:02 +00:00
|
|
|
if (!this->heap_)
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto ret = o1heapAllocate(this->heap_, length);
|
|
|
|
if (ret)
|
|
|
|
{
|
2022-12-07 11:38:10 +00:00
|
|
|
AuAtomicAdd(&this->count_, 1);
|
2022-07-21 09:59:02 +00:00
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *InternalHeap::_FAlloc(Types::size_t length, Types::size_t align)
|
|
|
|
{
|
|
|
|
SysAssert(align < O1HEAP_ALIGNMENT, "heap wrapping is unsupported, alignment past the supported 2^x alignment is not possible");
|
2022-07-21 09:59:02 +00:00
|
|
|
return this->_FAlloc(length);
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *InternalHeap::_ZAlloc(Types::size_t length)
|
|
|
|
{
|
2022-07-21 09:59:02 +00:00
|
|
|
if (!this->heap_)
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto ptr = this->_FAlloc(length);
|
|
|
|
if (!ptr)
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2022-01-19 18:53:22 +00:00
|
|
|
AuMemset(ptr, 0, length);
|
2021-06-27 21:25:29 +00:00
|
|
|
return ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *InternalHeap::_ZAlloc(Types::size_t length, Types::size_t align)
|
|
|
|
{
|
|
|
|
SysAssert(align < O1HEAP_ALIGNMENT, "heap wrapping is unsupported, alignment past the supported 2^x alignment is not possible");
|
|
|
|
return _ZAlloc(length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *InternalHeap::_ZRealloc(void *buffer, Types::size_t length)
|
|
|
|
{
|
|
|
|
auto prevLength = GetHeapSize(buffer);
|
2022-07-21 09:59:02 +00:00
|
|
|
auto alloc = this->_ZAlloc(length);
|
|
|
|
if (!alloc)
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2022-01-19 17:08:13 +00:00
|
|
|
AuMemcpy(alloc, buffer, AuMin(prevLength, length));
|
2022-07-21 09:59:02 +00:00
|
|
|
this->_Free(buffer);
|
2021-06-27 21:25:29 +00:00
|
|
|
return alloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *InternalHeap::_ZRealloc(void *buffer, Types::size_t length, Types::size_t align)
|
|
|
|
{
|
|
|
|
SysAssert(align < O1HEAP_ALIGNMENT, "heap wrapping is unsupported, alignment past the supported 2^x alignment is not possible");
|
2022-07-21 09:59:02 +00:00
|
|
|
return this->_ZRealloc(buffer, length);
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *InternalHeap::_FRealloc(void *buffer, Types::size_t length)
|
|
|
|
{
|
|
|
|
auto prevLength = GetHeapSize(buffer);
|
2022-07-21 09:59:02 +00:00
|
|
|
auto alloc = this->_FAlloc(length);
|
|
|
|
if (!alloc)
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2022-01-19 17:08:13 +00:00
|
|
|
AuMemcpy(alloc, buffer, AuMin(prevLength, length));
|
2022-07-21 09:59:02 +00:00
|
|
|
this->_Free(buffer);
|
2021-06-27 21:25:29 +00:00
|
|
|
return alloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *InternalHeap::_FRealloc(void *buffer, Types::size_t length, Types::size_t align)
|
|
|
|
{
|
|
|
|
SysAssert(align < O1HEAP_ALIGNMENT, "heap wrapping is unsupported, alignment past the supported 2^x alignment is not possible");
|
2022-07-21 09:59:02 +00:00
|
|
|
return this->_FRealloc(buffer, length);
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InternalHeap::_Free(void *buffer)
|
|
|
|
{
|
2022-07-21 09:59:02 +00:00
|
|
|
if (buffer == nullptr)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
o1heapFree(this->heap_, buffer);
|
2022-01-18 19:42:32 +00:00
|
|
|
DecrementUsers();
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalHeap::DecrementUsers()
|
|
|
|
{
|
2022-12-07 11:38:10 +00:00
|
|
|
if (AuAtomicSub(&this->count_, 1) == 0)
|
2022-01-18 19:42:32 +00:00
|
|
|
{
|
|
|
|
TryRelease();
|
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void InternalHeap::TryRelease()
|
|
|
|
{
|
2022-07-21 09:59:02 +00:00
|
|
|
if (!this->isDangling_)
|
2022-01-18 19:42:32 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
|
2021-11-05 17:34:23 +00:00
|
|
|
if (count_ == 0)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void InternalHeap::RequestTermination()
|
|
|
|
{
|
2022-12-07 11:38:10 +00:00
|
|
|
this->mutex_->Lock();
|
|
|
|
|
|
|
|
if (this->count_)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2022-12-07 11:38:10 +00:00
|
|
|
SysPushErrorMemory("Heap life was less than its allocations, waiting for final free");
|
|
|
|
SysPushErrorMemory("Reporting using mayday!");
|
2021-06-27 21:25:29 +00:00
|
|
|
Telemetry::Mayday();
|
|
|
|
|
2022-07-21 09:59:02 +00:00
|
|
|
this->isDangling_ = true;
|
2022-12-07 11:38:10 +00:00
|
|
|
this->mutex_->Unlock();
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-08 19:34:15 +00:00
|
|
|
void InternalHeap::UpdateStats()
|
|
|
|
{
|
|
|
|
auto pDiag = o1heapGetDiagnostics(this->heap_);
|
|
|
|
|
|
|
|
this->stats.uBytesLiveCounter = pDiag.allocated;
|
2023-01-15 06:05:22 +00:00
|
|
|
this->stats.uBytesCapacity = pDiag.capacity;
|
2022-12-08 19:34:15 +00:00
|
|
|
this->stats.uBytesPeakCounter = pDiag.peak_allocated;
|
|
|
|
}
|
|
|
|
|
2022-01-18 19:31:15 +00:00
|
|
|
AuSPtr<Heap> InternalHeap::GetSelfReference()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
[*/+/-] MEGA COMMIT. ~2 weeks compressed.
The intention is to quickly improve and add util apis, enhance functionality given current demands, go back to the build pipeline, finish that, publish runtime tests, and then use what we have to go back to to linux support with a more stable api.
[+] AuMakeSharedArray
[+] Technet ArgvQuote
[+] Grug subsystem (UNIX signal thread async safe ipc + telemetry flusher + log flusher.)
[+] auEndianness -> Endian swap utils
[+] AuGet<N>(...)
[*] AUE_DEFINE conversion for
ECompresionType, EAnsiColor, EHashType, EStreamError, EHexDump
[+] ConsoleMessage ByteBuffer serialization
[+] CmdLine subsystem for parsing command line arguments and simple switch/flag checks
[*] Split logger from console subsystem
[+] StartupParameters -> A part of a clean up effort under Process
[*] Refactor SysErrors header + get caller hack
[+] Atomic APIs
[+] popcnt
[+] Ring Buffer sink
[+] Added more standard errors
Catch,
Submission,
LockError,
NoAccess,
ResourceMissing,
ResourceLocked,
MalformedData,
InSandboxContext,
ParseError
[+] Added ErrorCategorySet, ErrorCategoryClear, GetStackTrace
[+] IExitSubscriber, ETriggerLevel
[*] Write bias the high performance RWLockImpl read-lock operation operation
[+] ExitHandlerAdd/ExitHandlerRemove (exit subsystem)
[*] Updated API style
Digests
[+] CpuId::CpuBitCount
[+] GetUserProgramsFolder
[+] GetPackagePath
[*] Split IStreamReader with an inl file
[*] BlobWriter/BlobReader/BlobArbitraryReader can now take shared pointers to bytebuffers. default constructor allocates a new scalable bytebuffer
[+] ICharacterProvider
[+] ICharacterProviderEx
[+] IBufferedCharacterConsumer
[+] ProviderFromSharedString
[+] ProviderFromString
[+] BufferConsumerFromProvider
[*] Parse Subsystem uses character io bufferer
[*] Rewritten NT's high perf semaphore to use userland SRW/ConVars [like mutex, based on generic semaphore]
[+] ByteBuffer::ResetReadPointer
[*] Bug fix bytebuffer base not reset on free and some scaling issues
[+] ProcessMap -> Added kSectionNameStack, kSectionNameFile, kSectionNameHeap for Section
[*] ProcessMap -> Refactor Segment to Section. I was stupid for keeping a type conflict hack API facing
[+] Added 64 *byte* fast RNG seeds
[+] File Advisorys/File Lock Awareness
[+] Added extended IAuroraThread from OS identifier caches for debug purposes
[*] Tweaked how memory is reported on Windows. Better consistency of what values mean across functions.
[*] Broke AuroraUtils/Typedefs out into a separate library
[*] Update build script
[+] Put some more effort into adding detail to the readme before rewriting it, plus, added some media
[*] Improved public API documentation
[*] Bug fix `SetConsoleCtrlHandler`
[+] Locale TimeDateToFileNameISO8601
[+] Console config stdOutShortTime
[*] Begin using internal UTF8/16 decoders when platform support isnt available (instead of stl)
[*] Bug fixes in decoders
[*] Major bug fix, AuMax
[+] RateLimiter
[+] Binary file sink
[+] Log directory sink
[*] Data header usability (more operators)
[+] AuRemoveRange
[+] AuRemove
[+] AuTryRemove
[+] AuTryRemoveRange
[+] auCastUtils
[+] Finish NewLSWin32Source
[+] AuTryFindByTupleN, AuTryRemoveByTupleN
[+] Separated AuRead/Write types, now in auTypeUtils
[+] Added GetPosition/SetPosition to FileWriter
[*] Fix stupid AuMin in place of AuMax in SpawnThread.Unix.Cpp
[*] Refactored Arbitrary readers to SeekingReaders (as in, they could be atomic and/or parallelized, and accept an arbitrary position as a work parameter -> not Seekable, as in, you can simply set the position)
[*] Hack back in the sched deinit
[+] File AIO loop source interop
[+] Begin to prototype a LoopQueue object I had in mind for NT, untested btw
[+] Stub code for networking
[+] Compression BaseStream/IngestableStreamBase
[*] Major: read/write locks now support write-entrant read routines.
[*] Compression subsystem now uses the MemoryView concept
[*] Rewrite the base stream compressions, made them less broken
[*] Update hashing api
[*] WriterTryGoForward and ReaderTryGoForward now revert to the previous relative index instead of panicing
[+] Added new AuByteBuffer apis
Trim, Pad, WriteFrom, WriteString, [TODO: ReadString]
[+] Added ByteBufferPushReadState
[+] Added ByteBufferPushWriteState
[*] Move from USC-16 to full UTF-16. Win32 can handle full UTF-16.
[*] ELogLevel is now an Aurora enum
[+] Raised arbitrary limit in header to 255, the max filter buffer
[+] Explicit GZip support
[+] Explicit Zip support
[+] Added [some] compressors
et al
2022-02-17 00:11:40 +00:00
|
|
|
return AuSharedFromThis();
|
2022-01-18 19:31:15 +00:00
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
AUKN_SYM Heap *AllocHeapNew(AuUInt size)
|
|
|
|
{
|
|
|
|
auto heap = _new InternalHeap();
|
|
|
|
if (!heap)
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2022-07-21 09:59:02 +00:00
|
|
|
if (!heap->Init(size, nullptr))
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
|
|
|
delete heap;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return heap;
|
|
|
|
}
|
|
|
|
|
2021-07-12 12:17:16 +00:00
|
|
|
AUKN_SYM void AllocHeapRelease(Heap *heap)
|
2021-06-27 21:25:29 +00:00
|
|
|
{
|
2021-09-06 10:58:08 +00:00
|
|
|
static_cast<InternalHeap *>(heap)->RequestTermination();
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|
2022-07-21 09:59:02 +00:00
|
|
|
|
|
|
|
AUKN_SYM Heap *RequestHeapOfRegionNew(void *ptr, AuUInt size)
|
|
|
|
{
|
|
|
|
auto heap = _new InternalHeap();
|
|
|
|
if (!heap)
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!heap->Init(size, ptr))
|
|
|
|
{
|
|
|
|
delete heap;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return heap;
|
|
|
|
}
|
|
|
|
|
|
|
|
AUKN_SYM void RequestHeapOfRegionRelease(Heap *heap)
|
|
|
|
{
|
|
|
|
static_cast<InternalHeap *>(heap)->RequestTermination();
|
|
|
|
}
|
2021-06-27 21:25:29 +00:00
|
|
|
}
|