From 47527cb5a9ea84b6e4f2d4cc4d0a752fa6833fa5 Mon Sep 17 00:00:00 2001 From: Regan Green Date: Fri, 26 Jan 2024 02:06:19 -0500 Subject: [PATCH] some fixes --- include/CKSDK/CKSDK.h | 4 ++++ src/OS/Mem.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/CKSDK/CKSDK.h b/include/CKSDK/CKSDK.h index 1a8116a..34f1436 100644 --- a/include/CKSDK/CKSDK.h +++ b/include/CKSDK/CKSDK.h @@ -37,4 +37,8 @@ // Keep section /// @brief Keep section /// @details This is used to keep a function in the final binary. You should use this for any functions that are called from DLLs. +#ifdef __INTELLISENSE__ +#define KEEP +#else #define KEEP __attribute__((used)) +#endif diff --git a/src/OS/Mem.cpp b/src/OS/Mem.cpp index 23f3e9a..681d8e2 100644 --- a/src/OS/Mem.cpp +++ b/src/OS/Mem.cpp @@ -101,6 +101,8 @@ namespace CKSDK KEEP void *Alloc(size_t size) { + OS::DisableIRQ(); + // Align size size = Align(size) + Align(sizeof(Block)); @@ -118,11 +120,13 @@ namespace CKSDK prev->next = head; // Return pointer + OS::EnableIRQ(); return (void*)((char*)head + Align(sizeof(Block))); } KEEP void *Realloc(void *ptr, size_t size) { + OS::DisableIRQ(); // Get block if (ptr == nullptr) @@ -155,11 +159,14 @@ namespace CKSDK head->next->prev = head; newprev->next = head; + OS::EnableIRQ(); return (void*)((char*)head + Align(sizeof(Block))); } KEEP void Free(void *ptr) { + OS::DisableIRQ(); + // Get block if (ptr == nullptr) return; @@ -168,10 +175,14 @@ namespace CKSDK // Unlink block if ((head->prev->next = head->next) != nullptr) head->next->prev = head->prev; + + OS::EnableIRQ(); } KEEP void Profile(size_t *used, size_t *total, size_t *blocks) { + OS::DisableIRQ(); + if (used != nullptr) { size_t u = 0; @@ -188,6 +199,8 @@ namespace CKSDK b++; *blocks = b; } + + OS::EnableIRQ(); } } }