From a5d15a7a3a26aeebc671f24137f61fe6b0832b0a Mon Sep 17 00:00:00 2001 From: James Benton Date: Tue, 29 May 2018 10:51:53 +0100 Subject: [PATCH] Remove libdefaultheap. Replaced by coreinit data exports. --- libraries/CMakeLists.txt | 1 - libraries/libdefaultheap/CMakeLists.txt | 16 ---- .../libdefaultheap/include/defaultheap.h | 20 ----- libraries/libdefaultheap/src/defaultheap.c | 75 ------------------- libraries/libwhb/CMakeLists.txt | 1 - libraries/libwhb/src/file.c | 2 +- libraries/libwhb/src/gfx_heap.c | 2 +- libraries/libwhb/src/log.c | 2 +- libraries/libwhb/src/log_udp.c | 2 +- samples/helloworld/CMakeLists.txt | 1 - samples/helloworld_std_thread/CMakeLists.txt | 1 - 11 files changed, 4 insertions(+), 119 deletions(-) delete mode 100644 libraries/libdefaultheap/CMakeLists.txt delete mode 100644 libraries/libdefaultheap/include/defaultheap.h delete mode 100644 libraries/libdefaultheap/src/defaultheap.c diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index fb32b55..ab7375c 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(libraries C) -add_subdirectory(libdefaultheap) add_subdirectory(libgfd) add_subdirectory(libwhb) add_subdirectory(wutcrt) diff --git a/libraries/libdefaultheap/CMakeLists.txt b/libraries/libdefaultheap/CMakeLists.txt deleted file mode 100644 index 3fb3a2c..0000000 --- a/libraries/libdefaultheap/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(libdefaultheap) - -file(GLOB_RECURSE SOURCE_FILES *.c) -file(GLOB_RECURSE HEADER_FILES *.h) - -add_library(defaultheap STATIC ${SOURCE_FILES} ${HEADER_FILES}) - -target_include_directories(defaultheap PRIVATE "../../include") -target_include_directories(defaultheap PUBLIC "include") - -install(TARGETS defaultheap - ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") -install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ - DESTINATION "${CMAKE_INSTALL_PREFIX}/include" - FILES_MATCHING PATTERN "*.h*") diff --git a/libraries/libdefaultheap/include/defaultheap.h b/libraries/libdefaultheap/include/defaultheap.h deleted file mode 100644 index f4f0be1..0000000 --- a/libraries/libdefaultheap/include/defaultheap.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include - -#ifdef __cplusplus -extern "C" { -#endif - -void * -MEMAllocFromDefaultHeap(uint32_t size); - -void * -MEMAllocFromDefaultHeapEx(uint32_t size, - int32_t alignment); - -void -MEMFreeToDefaultHeap(void *block); - -#ifdef __cplusplus -} -#endif diff --git a/libraries/libdefaultheap/src/defaultheap.c b/libraries/libdefaultheap/src/defaultheap.c deleted file mode 100644 index ef330d2..0000000 --- a/libraries/libdefaultheap/src/defaultheap.c +++ /dev/null @@ -1,75 +0,0 @@ -#include "defaultheap.h" -#include - -typedef void *(*MEMAllocFromDefaultHeapFn)(uint32_t size); -typedef void *(*MEMAllocFromDefaultHeapExFn)(uint32_t size, int32_t alignment); -typedef void (*MEMFreeToDefaultHeapFn)(void *block); - -static OSDynLoadModule sCoreinitHandle = 0; -static MEMAllocFromDefaultHeapFn *MEMAllocFromDefaultHeapPtr = NULL; -static MEMAllocFromDefaultHeapExFn *MEMAllocFromDefaultHeapExPtr = NULL; -static MEMFreeToDefaultHeapFn *MEMFreeToDefaultHeapPtr = NULL; - -void * -MEMAllocFromDefaultHeap(uint32_t size) -{ - if (!sCoreinitHandle) { - if (OSDynLoad_Acquire("coreinit.rpl", &sCoreinitHandle)) { - return NULL; - } - } - - if (!MEMAllocFromDefaultHeapPtr) { - if (OSDynLoad_FindExport(sCoreinitHandle, - TRUE, - "MEMAllocFromDefaultHeap", - (void **)&MEMAllocFromDefaultHeapPtr)) { - return NULL; - } - } - - return (**MEMAllocFromDefaultHeapPtr)(size); -} - -void * -MEMAllocFromDefaultHeapEx(uint32_t size, - int32_t alignment) -{ - if (!sCoreinitHandle) { - if (OSDynLoad_Acquire("coreinit.rpl", &sCoreinitHandle)) { - return NULL; - } - } - - if (!MEMAllocFromDefaultHeapExPtr) { - if (OSDynLoad_FindExport(sCoreinitHandle, - TRUE, - "MEMAllocFromDefaultHeapEx", - (void **)&MEMAllocFromDefaultHeapExPtr)) { - return NULL; - } - } - - return (**MEMAllocFromDefaultHeapExPtr)(size, alignment); -} - -void -MEMFreeToDefaultHeap(void *block) -{ - if (!sCoreinitHandle) { - if (OSDynLoad_Acquire("coreinit.rpl", &sCoreinitHandle)) { - return; - } - } - - if (!MEMFreeToDefaultHeapPtr) { - if (OSDynLoad_FindExport(sCoreinitHandle, - TRUE, - "MEMFreeToDefaultHeap", - (void **)&MEMFreeToDefaultHeapPtr)) { - return; - } - } - - (**MEMFreeToDefaultHeapPtr)(block); -} diff --git a/libraries/libwhb/CMakeLists.txt b/libraries/libwhb/CMakeLists.txt index d89472f..36702ed 100644 --- a/libraries/libwhb/CMakeLists.txt +++ b/libraries/libwhb/CMakeLists.txt @@ -7,7 +7,6 @@ file(GLOB_RECURSE HEADER_FILES *.h) add_library(whb STATIC ${SOURCE_FILES} ${HEADER_FILES}) target_include_directories(whb PRIVATE "../../include") -target_include_directories(whb PRIVATE "../libdefaultheap/include") target_include_directories(whb PRIVATE "../libgfd/include") target_include_directories(whb PUBLIC "include") diff --git a/libraries/libwhb/src/file.c b/libraries/libwhb/src/file.c index d02926d..84155ee 100644 --- a/libraries/libwhb/src/file.c +++ b/libraries/libwhb/src/file.c @@ -1,5 +1,5 @@ +#include #include -#include #include #include #include diff --git a/libraries/libwhb/src/gfx_heap.c b/libraries/libwhb/src/gfx_heap.c index 9b726bb..83b584e 100644 --- a/libraries/libwhb/src/gfx_heap.c +++ b/libraries/libwhb/src/gfx_heap.c @@ -1,8 +1,8 @@ #include "gfx_heap.h" #include +#include #include #include -#include #include static void * diff --git a/libraries/libwhb/src/log.c b/libraries/libwhb/src/log.c index eccd15e..cb110a1 100644 --- a/libraries/libwhb/src/log.c +++ b/libraries/libwhb/src/log.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/libraries/libwhb/src/log_udp.c b/libraries/libwhb/src/log_udp.c index 2e5cd5e..150d806 100644 --- a/libraries/libwhb/src/log_udp.c +++ b/libraries/libwhb/src/log_udp.c @@ -1,5 +1,5 @@ +#include #include -#include #include #include #include diff --git a/samples/helloworld/CMakeLists.txt b/samples/helloworld/CMakeLists.txt index c5bc994..7fe9844 100644 --- a/samples/helloworld/CMakeLists.txt +++ b/samples/helloworld/CMakeLists.txt @@ -7,7 +7,6 @@ add_executable(helloworld target_link_libraries(helloworld whb - defaultheap coreinit proc_ui sysapp) diff --git a/samples/helloworld_std_thread/CMakeLists.txt b/samples/helloworld_std_thread/CMakeLists.txt index b4bd2dc..dfe022b 100644 --- a/samples/helloworld_std_thread/CMakeLists.txt +++ b/samples/helloworld_std_thread/CMakeLists.txt @@ -7,7 +7,6 @@ add_executable(helloworld_std_thread target_link_libraries(helloworld_std_thread whb - defaultheap coreinit proc_ui sysapp)