Update libs, fix annoying heap bug here as well

This commit is contained in:
XorTroll 2023-09-04 01:28:04 +02:00
parent a6750c5a0f
commit 9ab9ad9d38
4 changed files with 21 additions and 11 deletions

@ -1 +1 @@
Subproject commit b1607dc8a3d85bc8c859c60d70ebb4a3dcbb85b8
Subproject commit c3dc418a28e390bc57426016aa2c9e7e87d7a584

View file

@ -1,7 +1,7 @@
export UL_MAJOR := 0
export UL_MINOR := 3
export UL_MICRO := 5
export UL_MICRO := 6
export UL_VERSION := $(UL_MAJOR).$(UL_MINOR).$(UL_MICRO)
export UL_DEFS := -DUL_MAJOR=$(UL_MAJOR) -DUL_MINOR=$(UL_MINOR) -DUL_MICRO=$(UL_MICRO) -DUL_VERSION=\"$(UL_VERSION)\"

@ -1 +1 @@
Subproject commit 672dec9798f4bbceb808f4affb0e55419a8075ea
Subproject commit 205d6688c0e282aeeddbb5bfb22d2e3a8ed0805c

View file

@ -18,9 +18,7 @@ extern "C" {
extern u32 __nx_applet_type;
u32 __nx_fsdev_direntry_cache_size = 0;
// Needed by libnx's usbcomms to allocate internal buffers...
// Note: operator new(size_t, std::align_val_t) isn't redefined in ams, so we need to stick with C-style memory functions
// (by default that operator internally calls _memalign_r, which isn't redefined by ams either, so it leads to crashes)
// So that libstratosphere doesn't redefine them as invalid
void *__libnx_alloc(size_t size) {
return malloc(size);
@ -75,8 +73,11 @@ namespace {
constexpr size_t UsbPacketSize = PlainRgbaScreenBufferSize + sizeof(UsbMode);
constexpr size_t HeapSize = 10_MB;
alignas(ams::os::MemoryPageSize) constinit u8 g_HeapBuffer[HeapSize];
constexpr size_t LibstratosphereHeapSize = 4_MB;
alignas(ams::os::MemoryPageSize) constinit u8 g_LibstratosphereHeap[LibstratosphereHeapSize];
constexpr size_t LibnxHeapSize = 4_MB;
alignas(ams::os::MemoryPageSize) constinit u8 g_LibnxHeap[LibnxHeapSize];
}
@ -546,6 +547,13 @@ namespace {
// TODO: consider stopping using Atmosphere-libs?
extern "C" {
extern u8 *fake_heap_start;
extern u8 *fake_heap_end;
}
namespace ams {
namespace init {
@ -562,14 +570,16 @@ namespace ams {
UL_RC_ASSERT(pmshellInitialize());
UL_RC_ASSERT(setsysInitialize());
fsdevMountSdmc();
UL_RC_ASSERT(fsdevMountSdmc());
}
void FinalizeSystemModule() {}
void Startup() {
// Initialize the global malloc-free/new-delete allocator
init::InitializeAllocator(g_HeapBuffer, HeapSize);
init::InitializeAllocator(g_LibstratosphereHeap, LibstratosphereHeapSize);
fake_heap_start = g_LibnxHeap;
fake_heap_end = fake_heap_start + LibnxHeapSize;
os::SetThreadNamePointer(os::GetCurrentThread(), "ul.daemon.Main");
}