From 0fe1b687531710071d7c5a85cc59577481a06c9b Mon Sep 17 00:00:00 2001 From: vnugent Date: Mon, 27 Mar 2023 12:22:32 -0400 Subject: Version bump, update method calling convention --- lib/NativeHeapApi/src/NativeHeapApi.h | 22 +++++++++++++++++----- lib/WinRpMalloc/src/dllmain.c | 10 +++++----- lib/WinRpMalloc/src/package.json | 2 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/NativeHeapApi/src/NativeHeapApi.h b/lib/NativeHeapApi/src/NativeHeapApi.h index 5e83108..00ca2b8 100644 --- a/lib/NativeHeapApi/src/NativeHeapApi.h +++ b/lib/NativeHeapApi/src/NativeHeapApi.h @@ -27,6 +27,18 @@ /* * Method calling convention for export */ +#ifndef HEAP_METHOD_CC + #ifdef WIN32 + #define HEAP_METHOD_CC __stdcall + #else + #define HEAP_METHOD_CC + #endif // WIN32 +#endif // !HEAP_METHOD_CC + + +/* +* Decorator for exporting methods for dll usage +*/ #ifndef HEAP_METHOD_EXPORT #ifdef WIN32 #define HEAP_METHOD_EXPORT __declspec(dllexport) @@ -81,13 +93,13 @@ typedef struct UnmanagedHeapFlags /// /// Creation flags passed by the caller to create the heap. This structure will be initialized, and may be modified /// A boolean value that indicates the result of the operation -HEAP_METHOD_EXPORT ERRNO heapCreate(UnmanagedHeapFlags* flags); +HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapCreate(UnmanagedHeapFlags* flags); /// /// Destroys a previously created heap /// /// The pointer to your custom heap structure from heap creation -HEAP_METHOD_EXPORT ERRNO heapDestroy(LPVOID heap); +HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapDestroy(LPVOID heap); /// /// Allocates a block from the desired heap and returns a pointer @@ -98,7 +110,7 @@ HEAP_METHOD_EXPORT ERRNO heapDestroy(LPVOID heap); /// The alignment (or size) of each element in bytes /// A flag to zero the block before returning the block /// A pointer to the allocated block -HEAP_METHOD_EXPORT LPVOID heapAlloc(LPVOID heap, size_t elements, size_t alignment, BOOL zero); +HEAP_METHOD_EXPORT LPVOID HEAP_METHOD_CC heapAlloc(LPVOID heap, size_t elements, size_t alignment, BOOL zero); /// /// Reallocates a block on the desired heap and returns a pointer to the new block. If reallocation @@ -111,7 +123,7 @@ HEAP_METHOD_EXPORT LPVOID heapAlloc(LPVOID heap, size_t elements, size_t alignme /// The element size or block alignment /// A flag to zero the block (or the new size) before returning. /// A pointer to the reallocated block, or zero if the operation failed or is not supported -HEAP_METHOD_EXPORT LPVOID heapRealloc(LPVOID heap, LPVOID block, size_t elements, size_t alignment, BOOL zero); +HEAP_METHOD_EXPORT LPVOID HEAP_METHOD_CC heapRealloc(LPVOID heap, LPVOID block, size_t elements, size_t alignment, BOOL zero); /// /// Frees a previously allocated block on the desired heap. @@ -119,6 +131,6 @@ HEAP_METHOD_EXPORT LPVOID heapRealloc(LPVOID heap, LPVOID block, size_t elements /// A pointer to your heap structure /// A pointer to the block to free /// A value that indicates the result of the operation, nonzero if success, 0 if a failure occurred -HEAP_METHOD_EXPORT ERRNO heapFree(LPVOID heap, LPVOID block); +HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapFree(LPVOID heap, LPVOID block); #endif // !NATIVE_HEAP_API \ No newline at end of file diff --git a/lib/WinRpMalloc/src/dllmain.c b/lib/WinRpMalloc/src/dllmain.c index 1c1378e..adcf3e6 100644 --- a/lib/WinRpMalloc/src/dllmain.c +++ b/lib/WinRpMalloc/src/dllmain.c @@ -52,7 +52,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv //Define the heap methods -HEAP_METHOD_EXPORT ERRNO heapCreate(UnmanagedHeapFlags* flags) +HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapCreate(UnmanagedHeapFlags* flags) { //Check flags if (flags->CreationFlags & HEAP_CREATION_IS_SHARED) @@ -77,7 +77,7 @@ HEAP_METHOD_EXPORT ERRNO heapCreate(UnmanagedHeapFlags* flags) } -HEAP_METHOD_EXPORT ERRNO heapDestroy(LPVOID heap) +HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapDestroy(LPVOID heap) { //Destroy the heap if ((int)heap == GLOBAL_HEAP_HANDLE_VALUE) @@ -96,7 +96,7 @@ HEAP_METHOD_EXPORT ERRNO heapDestroy(LPVOID heap) } -HEAP_METHOD_EXPORT LPVOID heapAlloc(LPVOID heap, size_t elements, size_t alignment, BOOL zero) +HEAP_METHOD_EXPORT LPVOID HEAP_METHOD_CC heapAlloc(LPVOID heap, size_t elements, size_t alignment, BOOL zero) { //Multiply for element size size_t size = elements * alignment; @@ -138,7 +138,7 @@ HEAP_METHOD_EXPORT LPVOID heapAlloc(LPVOID heap, size_t elements, size_t alignme } -HEAP_METHOD_EXPORT LPVOID heapRealloc(LPVOID heap, LPVOID block, size_t elements, size_t alignment, BOOL zero) +HEAP_METHOD_EXPORT LPVOID HEAP_METHOD_CC heapRealloc(LPVOID heap, LPVOID block, size_t elements, size_t alignment, BOOL zero) { //Multiply for element size size_t size = elements * alignment; @@ -164,7 +164,7 @@ HEAP_METHOD_EXPORT LPVOID heapRealloc(LPVOID heap, LPVOID block, size_t elements } -HEAP_METHOD_EXPORT ERRNO heapFree(LPVOID heap, LPVOID block) +HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapFree(LPVOID heap, LPVOID block) { //Check for global heap if ((int)heap == GLOBAL_HEAP_HANDLE_VALUE) diff --git a/lib/WinRpMalloc/src/package.json b/lib/WinRpMalloc/src/package.json index 35a1ca6..7ee361e 100644 --- a/lib/WinRpMalloc/src/package.json +++ b/lib/WinRpMalloc/src/package.json @@ -2,7 +2,7 @@ "Description": "A project to maintain an x64 Windows dll for RpMalloc by Mattias Jansson with some basic defaults for .NET loading. The debug output contains the debug MVCR libs and debug symbols.", "Authors": "Vaughn Nugent", "Copyright": "Copyright © 2023 Vaughn Nugent", - "Version": "0.1.1", + "Version": "0.1.2", "Company": "Vaughn Nugent", "Product": "WinRpMalloc", "RepositoryUrl": "https://github.com/VnUgE/VNLib.Core/tree/main/lib/WinRpMalloc" -- cgit