diff options
author | vnugent <public@vaughnnugent.com> | 2024-04-20 12:23:40 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2024-04-20 12:23:40 -0400 |
commit | 107b058a38d6785b350826c6fb01bb64997c630a (patch) | |
tree | e0cb1664982934c6d87002864d50642f1d0b0645 /lib/Utils.Memory | |
parent | e07537a3dde8e16100ef1bcc2a54f9ade8ae856f (diff) |
Squashed commit of the following:
commit 8c4a45e384accf92b1b6d748530e8d46f7de40d6
Author: vnugent <public@vaughnnugent.com>
Date: Sat Apr 20 11:10:30 2024 -0400
refactor: Overhaul C libraries and fix builds
commit 42ff77080d10b0fc9fecbbc46141e8e23a1d066a
Author: vnugent <public@vaughnnugent.com>
Date: Sat Apr 20 00:45:57 2024 -0400
fix!: Middlware array, multiple cookie set, and cookie check
commit 97e82b9d66f387f9e6d21d88ddc7a8ab8693149c
Merge: 4ca5791 e07537a
Author: vnugent <public@vaughnnugent.com>
Date: Tue Apr 2 13:34:22 2024 -0400
Merge branch 'main' into develop
commit 4ca5791ed67b9834bdbd010206b30373e4705e9b
Author: vnugent <public@vaughnnugent.com>
Date: Tue Apr 2 13:32:12 2024 -0400
fix: Missed ! on null pointer check
commit 9b4036377c52200c6488c98180d69a0e63321f97
Author: vnugent <public@vaughnnugent.com>
Date: Tue Apr 2 13:22:29 2024 -0400
fix: Fix _In_ macro for compression public api
commit 53a7b4b5c5b67b4a4e06e1d9098cac4bcd6afd7c
Merge: 448a93b 21130c8
Author: vnugent <public@vaughnnugent.com>
Date: Sun Mar 31 17:01:15 2024 -0400
Merge branch 'main' into develop
commit 448a93bb1d18d032087afe2476ffccb98634a54c
Author: vnugent <public@vaughnnugent.com>
Date: Sun Mar 31 16:56:51 2024 -0400
ci: fix third-party dir cleanup
commit 9afed1427472da1ea13079f98dbe27339e55ee7d
Author: vnugent <public@vaughnnugent.com>
Date: Sun Mar 31 16:43:15 2024 -0400
perf: Deprecate unsafememoryhandle span extensions
commit 3ff90da4f02af47ea6d233fdd4445337ebe36452
Author: vnugent <public@vaughnnugent.com>
Date: Sat Mar 30 21:36:18 2024 -0400
refactor: Updates, advanced tracing, http optimizations
commit 8d6b79b5ae309b36f265ba81529bcef8bfcd7414
Merge: 6c1667b 5585915
Author: vnugent <public@vaughnnugent.com>
Date: Sun Mar 24 21:01:31 2024 -0400
Merge branch 'main' into develop
commit 6c1667be23597513537f8190e2f55d65eb9b7c7a
Author: vnugent <public@vaughnnugent.com>
Date: Fri Mar 22 12:01:53 2024 -0400
refactor: Overhauled native library loading and lazy init
commit ebf688f2f974295beabf7b5def7e6f6f150551d0
Author: vnugent <public@vaughnnugent.com>
Date: Wed Mar 20 22:16:17 2024 -0400
refactor: Update compression header files and macros + Ci build
commit 9c7b564911080ccd5cbbb9851a0757b05e1e9047
Author: vnugent <public@vaughnnugent.com>
Date: Tue Mar 19 21:54:49 2024 -0400
refactor: JWK overhaul & add length getter to FileUpload
commit 6d8c3444e09561e5957491b3cc1ae858e0abdd14
Author: vnugent <public@vaughnnugent.com>
Date: Mon Mar 18 16:13:20 2024 -0400
feat: Add FNV1a software checksum and basic correction tests
commit 00d182088cecefc08ca80b1faee9bed3f215f40b
Author: vnugent <public@vaughnnugent.com>
Date: Fri Mar 15 01:05:27 2024 -0400
chore: #6 Use utils filewatcher instead of built-in
commit d513c10d9895c6693519ef1d459c6a5a76929436
Author: vnugent <public@vaughnnugent.com>
Date: Sun Mar 10 21:58:14 2024 -0400
source tree project location updated
Diffstat (limited to 'lib/Utils.Memory')
-rw-r--r-- | lib/Utils.Memory/NativeHeapApi/src/NativeHeapApi.h | 160 | ||||
-rw-r--r-- | lib/Utils.Memory/vnlib_mimalloc/CMakeLists.txt | 151 | ||||
-rw-r--r-- | lib/Utils.Memory/vnlib_mimalloc/NativeHeapApi.h | 160 | ||||
-rw-r--r-- | lib/Utils.Memory/vnlib_mimalloc/Taskfile.yaml | 23 | ||||
-rw-r--r-- | lib/Utils.Memory/vnlib_rpmalloc/CMakeLists.txt | 130 | ||||
-rw-r--r-- | lib/Utils.Memory/vnlib_rpmalloc/NativeHeapApi.h | 160 | ||||
-rw-r--r-- | lib/Utils.Memory/vnlib_rpmalloc/Taskfile.yaml | 16 | ||||
-rw-r--r-- | lib/Utils.Memory/vnlib_rpmalloc/build.readme.txt | 2 | ||||
-rw-r--r-- | lib/Utils.Memory/vnlib_rpmalloc/vnlib_rpmalloc.c | 3 | ||||
-rw-r--r-- | lib/Utils.Memory/vnlib_rpmalloc/vnlib_rpmalloc.vcxitems | 1 |
10 files changed, 367 insertions, 439 deletions
diff --git a/lib/Utils.Memory/NativeHeapApi/src/NativeHeapApi.h b/lib/Utils.Memory/NativeHeapApi/src/NativeHeapApi.h index 6a994b2..1738d19 100644 --- a/lib/Utils.Memory/NativeHeapApi/src/NativeHeapApi.h +++ b/lib/Utils.Memory/NativeHeapApi/src/NativeHeapApi.h @@ -5,13 +5,13 @@ * Package: NativeHeapApi * File: NativeHeapApi.h * -* This library is free software; you can redistribute it and/or +* This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License -* as published by the Free Software Foundation; either version 2.1 -* of the License, or (at your option) any later version. +* as published by the Free Software Foundation; either version 2.1 +* of the License, or (at your option) any later version. * -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * @@ -30,78 +30,60 @@ #define _P_IS_WINDOWS #endif -//Set api export calling convention (allow used to override) +/* Set api export calling convention (allow used to override) */ #ifndef VNLIB_CC #ifdef _P_IS_WINDOWS - //STD for importing to other languages such as .NET - #define VNLIB_CC __stdcall + /* STD for importing to other languages such as.NET */ + #define VNLIB_CC __stdcall #else #define VNLIB_CC #endif -#endif // !NC_CC +#endif /* !VNLIB_CC */ -#ifndef VNLIB_EXPORT //Allow users to disable the export/impoty macro if using source code directly +#ifndef VNLIB_HEAP_API /* Allow users to disable the export/impoty macro if using source code directly */ #ifdef VNLIB_EXPORTING #ifdef _P_IS_WINDOWS #define VNLIB_HEAP_API __declspec(dllexport) #else #define VNLIB_HEAP_API __attribute__((visibility("default"))) - #endif // _NC_IS_WINDOWS + #endif /* _P_IS_WINDOWS */ #else #ifdef _P_IS_WINDOWS #define VNLIB_HEAP_API __declspec(dllimport) #else #define VNLIB_HEAP_API - #endif // _P_IS_WINDOWS - #endif // !VNLIB_EXPORTING -#endif // !VNLIB_EXPORT + #endif /* _P_IS_WINDOWS */ + #endif /* !VNLIB_EXPORTING */ +#endif /* !VNLIB_EXPORT */ -/// <summary> -/// Internal heap creation flags passed to the creation method by the library loader -/// </summary> +/* Internal heap creation flags passed to the creation method by the library loader */ typedef enum HeapCreationFlags { - /// <summary> - /// Default/no flags - /// </summary> + /* Default/no flags */ HEAP_CREATION_NO_FLAGS, - /// <summary> - /// Specifies that all allocations be zeroed before returning to caller - /// </summary> + /* Specifies that all allocations be zeroed before returning to caller */ HEAP_CREATION_GLOBAL_ZERO = 0x01, - /// <summary> - /// Specifies that the heap should use internal locking, aka its not thread safe - /// and needs to be made thread safe - /// </summary> + /* Specifies that the heap should use internal locking, aka its not thread safe + and needs to be made thread safe */ HEAP_CREATION_SERIALZE_ENABLED = 0x02, - /// <summary> - /// Specifies that the requested heap will be a shared heap for the process/library - /// </summary> + /* Specifies that the requested heap will be a shared heap for the process/library */ HEAP_CREATION_IS_SHARED = 0x04, - /// <summary> - /// Specifies that the heap will support block reallocation - /// </summary> - HEAP_CREATION_SUPPORTS_REALLOC = 0x08, + /* Specifies that the heap will support block reallocation */ + HEAP_CREATION_SUPPORTS_REALLOC = 0x08 } HeapCreationFlags; #ifdef _P_IS_WINDOWS - typedef void* LPVOID; -#endif // !WIN32 +typedef void* LPVOID; +#endif /* !WIN32 */ -/// <summary> -/// The vnlib ERRNO type, integer/process dependent, -/// internally represented as a pointer -/// </summary> +/* The vnlib ERRNO type, integer/process dependent, +internally represented as a pointer */ typedef void* ERRNO; -/// <summary> -/// A pointer to a heap structure that was stored during heap creation -/// </summary> +/* A pointer to a heap structure that was stored during heap creation */ typedef void* HeapHandle; -/// <summary> -/// A structure for heap initialization -/// </summary> +/* A structure for heap initialization */ typedef struct UnmanagedHeapDescriptor { HeapHandle HeapPointer; @@ -109,56 +91,60 @@ typedef struct UnmanagedHeapDescriptor HeapCreationFlags CreationFlags; } UnmanagedHeapDescriptor; -/// <summary> -/// Gets the shared heap handle for the process/library -/// </summary> -/// <returns>A pointer to the shared heap</returns> +/* Gets the shared heap handle for the process/library +Returns: A pointer to the shared heap +*/ VNLIB_HEAP_API HeapHandle VNLIB_CC heapGetSharedHeapHandle(void); -/// <summary> -/// The heap creation method. You must set the flags->HeapPointer = your heap -/// structure -/// </summary> -/// <param name="flags">Creation flags passed by the caller to create the heap. This structure will be initialized, and may be modified</param> -/// <returns>A boolean value that indicates the result of the operation</returns> +/* The heap creation method. You must set the flags->HeapPointer = your heap +structure. +Parameters: + flags - Creation flags passed by the caller to create the heap. This structure will be initialized, and may be modified +Returns: A boolean value that indicates the result of the operation +*/ VNLIB_HEAP_API ERRNO VNLIB_CC heapCreate(UnmanagedHeapDescriptor* flags); -/// <summary> -/// Destroys a previously created heap -/// </summary> -/// <param name="heap">The pointer to your custom heap structure from heap creation</param> +/* Destroys a previously created heap +Parameters: + heap - The pointer to your custom heap structure from heap creation +*/ VNLIB_HEAP_API ERRNO VNLIB_CC heapDestroy(HeapHandle heap); -/// <summary> -/// Allocates a block from the desired heap and returns a pointer -/// to the block. Optionally zeros the block before returning -/// </summary> -/// <param name="heap">A pointer to your heap structure</param> -/// <param name="elements">The number of elements to allocate</param> -/// <param name="alignment">The alignment (or size) of each element in bytes</param> -/// <param name="zero">A flag to zero the block before returning the block</param> -/// <returns>A pointer to the allocated block</returns> +/* Allocates a block from the desired heap and returns a pointer +to the block. Optionally zeros the block before returning + +Parameters: + heap - A pointer to your heap structure + elements - The number of elements to allocate + alignment - The alignment (or size) of each element in bytes + zero - A flag to zero the block before returning the block + +Returns: A pointer to the allocated block +*/ VNLIB_HEAP_API void* VNLIB_CC heapAlloc(HeapHandle heap, uint64_t elements, uint64_t alignment, int zero); -/// <summary> -/// Reallocates a block on the desired heap and returns a pointer to the new block. If reallocation -/// is not supported, you should only return 0 and leave the block unmodified. The data in the valid -/// size of the block MUST remain unmodified. -/// </summary> -/// <param name="heap">A pointer to your heap structure</param> -/// <param name="block">A pointer to the block to reallocate</param> -/// <param name="elements">The new size of the block, in elements</param> -/// <param name="alignment">The element size or block alignment</param> -/// <param name="zero">A flag to zero the block (or the new size) before returning.</param> -/// <returns>A pointer to the reallocated block, or zero if the operation failed or is not supported</returns> +/* Reallocates a block on the desired heap and returns a pointer to the new block. If reallocation +is not supported, you should only return 0 and leave the block unmodified. The data in the valid +size of the block MUST remain unmodified. + +Parameters: + heap - A pointer to your heap structure + block - A pointer to the block to reallocate + elements - The new size of the block, in elements + alignment - The element size or block alignment + zero - A flag to zero the block (or the new size) before returning. + +Returns: A pointer to the reallocated block, or zero if the operation failed or is not supported +*/ VNLIB_HEAP_API void* VNLIB_CC heapRealloc(HeapHandle heap, void* block, uint64_t elements, uint64_t alignment, int zero); -/// <summary> -/// Frees a previously allocated block on the desired heap. -/// </summary> -/// <param name="heap">A pointer to your heap structure</param> -/// <param name="block">A pointer to the block to free</param> -/// <returns>A value that indicates the result of the operation, nonzero if success, 0 if a failure occurred </returns> +/* Frees a previously allocated block on the desired heap. +Parameters: + heap - A pointer to your heap structure + block - A pointer to the block to free + +Returns: A value that indicates the result of the operation, nonzero if success, 0 if a failure occurred +*/ VNLIB_HEAP_API ERRNO VNLIB_CC heapFree(HeapHandle heap, void* block); -#endif // !NATIVE_HEAP_API
\ No newline at end of file +#endif /* !NATIVE_HEAP_API */ diff --git a/lib/Utils.Memory/vnlib_mimalloc/CMakeLists.txt b/lib/Utils.Memory/vnlib_mimalloc/CMakeLists.txt index f1ef4b9..4a2a946 100644 --- a/lib/Utils.Memory/vnlib_mimalloc/CMakeLists.txt +++ b/lib/Utils.Memory/vnlib_mimalloc/CMakeLists.txt @@ -1,6 +1,18 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.10) project(vnlib_mimalloc C) +set(CMAKE_PROJECT_NAME "vnlib_mimalloc") + +option(ENABLE_GREEDY "Enable greedy allocator configuration" ON) +set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The build configuration type") + +#Setup the compiler options +set(CMAKE_C_STANDARD 11) #c11 is required for mimalloc static assertions +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) #enable position independent code (for shared libraries with exports) + +string(TOLOWER ${CMAKE_BUILD_TYPE} build_type) +message(STATUS "Build type is '${build_type}'") #export header files to the main project file(GLOB HEADERS *.h) @@ -8,12 +20,8 @@ file(GLOB HEADERS *.h) #Add indepednent source files to the project file(GLOB VNLIB_MIMALLOC_SOURCES *.c) -#set options for greedy allocator defaults -option(ENABLE_GREEDY "Enable greedy allocator configuration" ON) - #create my shared library add_library(${CMAKE_PROJECT_NAME} SHARED ${VNLIB_MIMALLOC_SOURCES} ${HEADERS}) -#also create static library add_library(${CMAKE_PROJECT_NAME}_static STATIC ${VNLIB_MIMALLOC_SOURCES} ${HEADERS}) #if on unix lib will be appended, so we can adjust @@ -21,42 +29,22 @@ if(UNIX) set_target_properties(${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_NAME}_static PROPERTIES OUTPUT_NAME vn_mimalloc) endif() -#Setup the compiler options -set(CMAKE_C_STANDARD 90) -set(CMAKE_C_STANDARD_REQUIRED ON) - -#enable position independent code (for shared libraries with exports) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - -message(STATUS "Build type is '${CMAKE_BUILD_TYPE}'") - -#if debug -add_compile_definitions($<$<CONFIG:Debug>:DEBUG>) - -if(ENABLE_GREEDY) - add_compile_definitions(VNLIB_MIMALLOC_GREEDY) -endif() - #setup flags for windows compilation if(MSVC) - - #global windows cl flags - add_compile_options( - /Qspectre - /sdl - /TC - /GS - /machine:x64 - - $<$<CONFIG:Debug>:/FC> - $<$<CONFIG:Debug>:/showIncludes> - ) + + #if debug + target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE $<$<CONFIG:Debug>:DEBUG>) #only target our project target_compile_options( ${CMAKE_PROJECT_NAME} PRIVATE + /Qspectre + /sdl + /TC + /GS + #disable warnings for struct padding and spectre mitigation wuen WX is enabled $<$<CONFIG:Debug>:/wd5045> $<$<CONFIG:Debug>:/wd4820> @@ -69,10 +57,15 @@ if(MSVC) $<$<CONFIG:Debug>:/WX> #warnings as errors (only for our project) $<$<CONFIG:Debug>:/Zi> $<$<CONFIG:Debug>:/Zo> + $<$<CONFIG:Debug>:/FC> + $<$<CONFIG:Debug>:/showIncludes> ) #set build macros - add_compile_definitions( + target_compile_definitions( + ${CMAKE_PROJECT_NAME} + PRIVATE + $<$<CONFIG:DEBUG>:DEBUG> $<$<CONFIG:RELEASE>:RELEASE> ) @@ -80,65 +73,55 @@ if(MSVC) #configure gcc flags elseif(CMAKE_COMPILER_IS_GNUCC) - add_compile_options( - -Wextra - -fstack-protector - - $<$<CONFIG:Debug>:-g> - $<$<CONFIG:Debug>:-Og> - $<$<CONFIG:Debug>:-Wall> - $<$<CONFIG:Debug>:-Werror> - ) - - #only target our project - target_compile_options( + target_compile_options( ${CMAKE_PROJECT_NAME} PRIVATE - $<$<CONFIG:Debug>:-Wall> - $<$<CONFIG:Debug>:-pedantic> - ) -endif() - -#include mimalloc headers -include_directories(vendor/include) - -if(MSVC) - - #find the mimalloc static library for windows builds - find_library(VNLIB_MIMALLOC_DEBUG_LIB - NAMES mimalloc-static - PATHS vendor/build/Debug - ) - - find_library(VNLIB_MIMALLOC_RELEASE_LIB - NAMES mimalloc-static - PATHS vendor/build/Release + -Wextra + -fstack-protector ) - #target static libraries for all configs - target_link_libraries(${CMAKE_PROJECT_NAME} - $<$<CONFIG:Debug>:${VNLIB_MIMALLOC_DEBUG_LIB}> - #set release for all release configs - $<$<CONFIG:MinSizeRel>:${VNLIB_MIMALLOC_RELEASE_LIB}> - $<$<CONFIG:RelWithDepInfo>:${VNLIB_MIMALLOC_RELEASE_LIB}> - $<$<CONFIG:Release>:${VNLIB_MIMALLOC_RELEASE_LIB}> - ) + #enable debug compiler options + if(build_type STREQUAL "debug") + target_compile_options( + ${CMAKE_PROJECT_NAME} + PRIVATE -elseif(UNIX) + -g #enable debugger info + -Og #disable optimizations + -Wall #enable all warnings + -Werror #treat warnings as errors + -pedantic #enable pedantic mode + ) - #find the mimalloc library for unix builds - find_library(VNLIB_MIMALLOC_LIB - NAMES mimalloc - PATHS vendor/build - ) + target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE DEBUG) - #add the mimalloc library to the project - target_link_libraries(${CMAKE_PROJECT_NAME} ${VNLIB_MIMALLOC_LIB}) + endif() else() + message(FATAL_ERROR "Unsupported compiler, sorry. Submit an issue for your platform and I'll work on it :)") +endif() - #failure - message(FATAL_ERROR "Unsupported platform configuration for mimalloc library") -endif()
\ No newline at end of file +#include mimalloc headers +include_directories(vendor/include) + +################################## +# # +# Include mimalloc library # +# # +################################## + +set(MI_BUILD_TESTS OFF) +set(MI_BUILD_STATIC ON) +set(MI_BUILD_SHARED OFF) +set(MI_OVERRIDE OFF) +set(MI_WIN_REDIRECT OFF) + +add_subdirectory( + ${CMAKE_CURRENT_SOURCE_DIR}/vendor + ${CMAKE_CURRENT_BINARY_DIR}/mimalloc +) + +target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE mimalloc-static) +target_link_libraries(${CMAKE_PROJECT_NAME}_static PRIVATE mimalloc-static) diff --git a/lib/Utils.Memory/vnlib_mimalloc/NativeHeapApi.h b/lib/Utils.Memory/vnlib_mimalloc/NativeHeapApi.h index 6a994b2..1738d19 100644 --- a/lib/Utils.Memory/vnlib_mimalloc/NativeHeapApi.h +++ b/lib/Utils.Memory/vnlib_mimalloc/NativeHeapApi.h @@ -5,13 +5,13 @@ * Package: NativeHeapApi * File: NativeHeapApi.h * -* This library is free software; you can redistribute it and/or +* This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License -* as published by the Free Software Foundation; either version 2.1 -* of the License, or (at your option) any later version. +* as published by the Free Software Foundation; either version 2.1 +* of the License, or (at your option) any later version. * -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * @@ -30,78 +30,60 @@ #define _P_IS_WINDOWS #endif -//Set api export calling convention (allow used to override) +/* Set api export calling convention (allow used to override) */ #ifndef VNLIB_CC #ifdef _P_IS_WINDOWS - //STD for importing to other languages such as .NET - #define VNLIB_CC __stdcall + /* STD for importing to other languages such as.NET */ + #define VNLIB_CC __stdcall #else #define VNLIB_CC #endif -#endif // !NC_CC +#endif /* !VNLIB_CC */ -#ifndef VNLIB_EXPORT //Allow users to disable the export/impoty macro if using source code directly +#ifndef VNLIB_HEAP_API /* Allow users to disable the export/impoty macro if using source code directly */ #ifdef VNLIB_EXPORTING #ifdef _P_IS_WINDOWS #define VNLIB_HEAP_API __declspec(dllexport) #else #define VNLIB_HEAP_API __attribute__((visibility("default"))) - #endif // _NC_IS_WINDOWS + #endif /* _P_IS_WINDOWS */ #else #ifdef _P_IS_WINDOWS #define VNLIB_HEAP_API __declspec(dllimport) #else #define VNLIB_HEAP_API - #endif // _P_IS_WINDOWS - #endif // !VNLIB_EXPORTING -#endif // !VNLIB_EXPORT + #endif /* _P_IS_WINDOWS */ + #endif /* !VNLIB_EXPORTING */ +#endif /* !VNLIB_EXPORT */ -/// <summary> -/// Internal heap creation flags passed to the creation method by the library loader -/// </summary> +/* Internal heap creation flags passed to the creation method by the library loader */ typedef enum HeapCreationFlags { - /// <summary> - /// Default/no flags - /// </summary> + /* Default/no flags */ HEAP_CREATION_NO_FLAGS, - /// <summary> - /// Specifies that all allocations be zeroed before returning to caller - /// </summary> + /* Specifies that all allocations be zeroed before returning to caller */ HEAP_CREATION_GLOBAL_ZERO = 0x01, - /// <summary> - /// Specifies that the heap should use internal locking, aka its not thread safe - /// and needs to be made thread safe - /// </summary> + /* Specifies that the heap should use internal locking, aka its not thread safe + and needs to be made thread safe */ HEAP_CREATION_SERIALZE_ENABLED = 0x02, - /// <summary> - /// Specifies that the requested heap will be a shared heap for the process/library - /// </summary> + /* Specifies that the requested heap will be a shared heap for the process/library */ HEAP_CREATION_IS_SHARED = 0x04, - /// <summary> - /// Specifies that the heap will support block reallocation - /// </summary> - HEAP_CREATION_SUPPORTS_REALLOC = 0x08, + /* Specifies that the heap will support block reallocation */ + HEAP_CREATION_SUPPORTS_REALLOC = 0x08 } HeapCreationFlags; #ifdef _P_IS_WINDOWS - typedef void* LPVOID; -#endif // !WIN32 +typedef void* LPVOID; +#endif /* !WIN32 */ -/// <summary> -/// The vnlib ERRNO type, integer/process dependent, -/// internally represented as a pointer -/// </summary> +/* The vnlib ERRNO type, integer/process dependent, +internally represented as a pointer */ typedef void* ERRNO; -/// <summary> -/// A pointer to a heap structure that was stored during heap creation -/// </summary> +/* A pointer to a heap structure that was stored during heap creation */ typedef void* HeapHandle; -/// <summary> -/// A structure for heap initialization -/// </summary> +/* A structure for heap initialization */ typedef struct UnmanagedHeapDescriptor { HeapHandle HeapPointer; @@ -109,56 +91,60 @@ typedef struct UnmanagedHeapDescriptor HeapCreationFlags CreationFlags; } UnmanagedHeapDescriptor; -/// <summary> -/// Gets the shared heap handle for the process/library -/// </summary> -/// <returns>A pointer to the shared heap</returns> +/* Gets the shared heap handle for the process/library +Returns: A pointer to the shared heap +*/ VNLIB_HEAP_API HeapHandle VNLIB_CC heapGetSharedHeapHandle(void); -/// <summary> -/// The heap creation method. You must set the flags->HeapPointer = your heap -/// structure -/// </summary> -/// <param name="flags">Creation flags passed by the caller to create the heap. This structure will be initialized, and may be modified</param> -/// <returns>A boolean value that indicates the result of the operation</returns> +/* The heap creation method. You must set the flags->HeapPointer = your heap +structure. +Parameters: + flags - Creation flags passed by the caller to create the heap. This structure will be initialized, and may be modified +Returns: A boolean value that indicates the result of the operation +*/ VNLIB_HEAP_API ERRNO VNLIB_CC heapCreate(UnmanagedHeapDescriptor* flags); -/// <summary> -/// Destroys a previously created heap -/// </summary> -/// <param name="heap">The pointer to your custom heap structure from heap creation</param> +/* Destroys a previously created heap +Parameters: + heap - The pointer to your custom heap structure from heap creation +*/ VNLIB_HEAP_API ERRNO VNLIB_CC heapDestroy(HeapHandle heap); -/// <summary> -/// Allocates a block from the desired heap and returns a pointer -/// to the block. Optionally zeros the block before returning -/// </summary> -/// <param name="heap">A pointer to your heap structure</param> -/// <param name="elements">The number of elements to allocate</param> -/// <param name="alignment">The alignment (or size) of each element in bytes</param> -/// <param name="zero">A flag to zero the block before returning the block</param> -/// <returns>A pointer to the allocated block</returns> +/* Allocates a block from the desired heap and returns a pointer +to the block. Optionally zeros the block before returning + +Parameters: + heap - A pointer to your heap structure + elements - The number of elements to allocate + alignment - The alignment (or size) of each element in bytes + zero - A flag to zero the block before returning the block + +Returns: A pointer to the allocated block +*/ VNLIB_HEAP_API void* VNLIB_CC heapAlloc(HeapHandle heap, uint64_t elements, uint64_t alignment, int zero); -/// <summary> -/// Reallocates a block on the desired heap and returns a pointer to the new block. If reallocation -/// is not supported, you should only return 0 and leave the block unmodified. The data in the valid -/// size of the block MUST remain unmodified. -/// </summary> -/// <param name="heap">A pointer to your heap structure</param> -/// <param name="block">A pointer to the block to reallocate</param> -/// <param name="elements">The new size of the block, in elements</param> -/// <param name="alignment">The element size or block alignment</param> -/// <param name="zero">A flag to zero the block (or the new size) before returning.</param> -/// <returns>A pointer to the reallocated block, or zero if the operation failed or is not supported</returns> +/* Reallocates a block on the desired heap and returns a pointer to the new block. If reallocation +is not supported, you should only return 0 and leave the block unmodified. The data in the valid +size of the block MUST remain unmodified. + +Parameters: + heap - A pointer to your heap structure + block - A pointer to the block to reallocate + elements - The new size of the block, in elements + alignment - The element size or block alignment + zero - A flag to zero the block (or the new size) before returning. + +Returns: A pointer to the reallocated block, or zero if the operation failed or is not supported +*/ VNLIB_HEAP_API void* VNLIB_CC heapRealloc(HeapHandle heap, void* block, uint64_t elements, uint64_t alignment, int zero); -/// <summary> -/// Frees a previously allocated block on the desired heap. -/// </summary> -/// <param name="heap">A pointer to your heap structure</param> -/// <param name="block">A pointer to the block to free</param> -/// <returns>A value that indicates the result of the operation, nonzero if success, 0 if a failure occurred </returns> +/* Frees a previously allocated block on the desired heap. +Parameters: + heap - A pointer to your heap structure + block - A pointer to the block to free + +Returns: A value that indicates the result of the operation, nonzero if success, 0 if a failure occurred +*/ VNLIB_HEAP_API ERRNO VNLIB_CC heapFree(HeapHandle heap, void* block); -#endif // !NATIVE_HEAP_API
\ No newline at end of file +#endif /* !NATIVE_HEAP_API */ diff --git a/lib/Utils.Memory/vnlib_mimalloc/Taskfile.yaml b/lib/Utils.Memory/vnlib_mimalloc/Taskfile.yaml index e9e9153..acf8851 100644 --- a/lib/Utils.Memory/vnlib_mimalloc/Taskfile.yaml +++ b/lib/Utils.Memory/vnlib_mimalloc/Taskfile.yaml @@ -17,20 +17,16 @@ tasks: default: desc: "Builds the entire project from source code without using the VNBuild build system for target machines" cmds: - #build with defaults - - task: build - - cmd: echo "Your vnlib_mimalloc dll file can be found in '{{.USER_WORKING_DIR}}/build'" + #init cmake build with greedy enabled + - cmake -Bbuild/ -DCMAKE_BUILD_TYPE=Release -DENABLE_GREEDY=1 {{.CMAKE_ARGS}} + - cmake --build build/ --config Release + - cmd: echo "Your vnlib_mimalloc library file can be found in '{{.USER_WORKING_DIR}}/build'" silent: true build: - cmds: - #build the mimalloc library first - - cd vendor/ && cmake -B./build -DMI_BUILD_STATIC=1 {{.MIMALLOC_CMAKE_ARGS}} -DMI_BUILD_TESTS=0 -DMI_OVERRIDE=0 -DMI_WIN_REDIRECT=0 - - cd vendor/ && cmake --build build/ --config Debug - - cd vendor/ && cmake --build build/ --config Release - + cmds: #build our library - - cmake -B./build -DENABLE_GREEDY=1 {{.CMAKE_ARGS}} + - cmake -B./build -DENABLE_GREEDY=1 {{.CMAKE_ARGS}} - cmake --build build/ --config Debug - cmake --build build/ --config Release @@ -80,9 +76,8 @@ tasks: clean: ignore_error: true - cmds: - - cmd: powershell -Command "Remove-Item -Recurse './bin'" - - cmd: powershell -Command "Remove-Item -Recurse './build'" - - cmd: powershell -Command "Remove-Item -Recurse '../mimalloc/build'" + cmds: + - for: [ bin/, build/ ] + cmd: powershell Remove-Item -Recurse '{{.ITEM}}' -Force
\ No newline at end of file diff --git a/lib/Utils.Memory/vnlib_rpmalloc/CMakeLists.txt b/lib/Utils.Memory/vnlib_rpmalloc/CMakeLists.txt index 5e04d03..706050c 100644 --- a/lib/Utils.Memory/vnlib_rpmalloc/CMakeLists.txt +++ b/lib/Utils.Memory/vnlib_rpmalloc/CMakeLists.txt @@ -1,6 +1,18 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.10) project(vnlib_rpmalloc C) +set(CMAKE_PROJECT_NAME "vnlib_rpmalloc") + +option(ENABLE_GREEDY "Enable greedy allocator configuration" ON) +set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The build configuration type") + +#Setup the compiler options +set(CMAKE_C_STANDARD 11) #c11 is required for rpmalloc static assertions +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) #enable position independent code (for shared libraries with exports) + +string(TOLOWER ${CMAKE_BUILD_TYPE} build_type) +message(STATUS "Build type is '${build_type}'") #export header files to the main project file(GLOB HEADERS *.h) @@ -14,12 +26,8 @@ set(VNLIB_RPMALLOC_SOURCES #add rpmalloc includes, there will only be one library include_directories(vendor) -#set options for greedy allocator defaults -option(ENABLE_GREEDY "Enable greedy allocator configuration" ON) - -#create my shared library +#create shared/static libs add_library(${CMAKE_PROJECT_NAME} SHARED ${VNLIB_RPMALLOC_SOURCES} ${HEADERS}) -#also create static library add_library(${CMAKE_PROJECT_NAME}_static STATIC ${VNLIB_RPMALLOC_SOURCES} ${HEADERS}) #if on unix lib will be appended, so we can adjust @@ -27,43 +35,17 @@ if(UNIX) set_target_properties(${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_NAME}_static PROPERTIES OUTPUT_NAME vn_rpmalloc) endif() -#Setup the compiler options -set(CMAKE_C_STANDARD 90) -set(CMAKE_C_STANDARD_REQUIRED ON) - -#enable position independent code (for shared libraries with exports) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - -message(STATUS "Build type is '${CMAKE_BUILD_TYPE}'") - -#if debug -add_compile_definitions($<$<CONFIG:Debug>:DEBUG>) - -if(ENABLE_GREEDY) - add_compile_definitions(VNLIB_RPMALLOC_GREEDY) -endif() #setup flags for windows compilation if(MSVC) - - #global windows cl flags + add_compile_options( /Qspectre /sdl /TC /GS - /machine:x64 - - $<$<CONFIG:Debug>:/FC> - $<$<CONFIG:Debug>:/showIncludes> - ) - #only target our project - target_compile_options( - ${CMAKE_PROJECT_NAME} - PRIVATE - - #disable warnings for struct padding and spectre mitigation wuen WX is enabled + #disable warnings for struct padding and spectre mitigation when WX is enabled $<$<CONFIG:Debug>:/wd5045> $<$<CONFIG:Debug>:/wd4820> $<$<CONFIG:Debug>:/wd4574> @@ -72,13 +54,14 @@ if(MSVC) $<$<CONFIG:Debug>:/options:strict> #disable warnings for struct padding and spectre mitigation wuen WX is enabled $<$<CONFIG:Debug>:/Wall> - $<$<CONFIG:Debug>:/WX> #warnings as errors (only for our project) - $<$<CONFIG:Debug>:/Zi> - $<$<CONFIG:Debug>:/Zo> + $<$<CONFIG:Debug>:/WX> #warnings as errors (only for our project) + $<$<CONFIG:Debug>:/Zi> #enable debug info + $<$<CONFIG:Debug>:/Zo> + $<$<CONFIG:Debug>:/FC> #full path in diagnostics + $<$<CONFIG:Debug>:/showIncludes> ) - #set build macros - add_compile_definitions( + add_compile_definitions( $<$<CONFIG:DEBUG>:DEBUG> $<$<CONFIG:RELEASE>:RELEASE> ) @@ -89,52 +72,57 @@ elseif(CMAKE_COMPILER_IS_GNUCC) add_compile_options( -Wextra -fstack-protector - - $<$<CONFIG:Debug>:-g> - $<$<CONFIG:Debug>:-Og> - $<$<CONFIG:Debug>:-Wall> - $<$<CONFIG:Debug>:-Werror> ) - #only target our project - target_compile_options( - ${CMAKE_PROJECT_NAME} - PRIVATE - $<$<CONFIG:Debug>:-Wall> - $<$<CONFIG:Debug>:-pedantic> - ) + #enable debug compiler options + if(build_type STREQUAL "debug") + add_compile_options( + -g #enable debugger info + -Og #disable optimizations + -Wall #enable all warnings + -Werror #treat warnings as errors + -pedantic #enable pedantic mode + ) + endif() +else() + message(FATAL_ERROR "Unsupported compiler, sorry. Submit an issue for your platform and I'll work on it :)") endif() #enable required features -add_definitions(-DRPMALLOC_FIRST_CLASS_HEAPS=1) -add_definitions(-DENABLE_ADAPTIVE_THREAD_CACHE=1) +add_compile_definitions( + RPMALLOC_FIRST_CLASS_HEAPS=1 + ENABLE_ADAPTIVE_THREAD_CACHE=1 -#add some debugging/tracing for debug mode -add_compile_definitions($<$<CONFIG:Debug>:ENABLE_VALIDATE_ARGS=1>) -add_compile_definitions($<$<CONFIG:Debug>:ENABLE_ASSERTS=1>) + #add some debugging/tracing for debug mode + $<$<CONFIG:Debug>:ENABLE_TRACE=1> + $<$<CONFIG:Debug>:ENABLE_VALIDATE_ARGS=1> +) if(ENABLE_GREEDY) -#if greedy is enabled, add greedy options -add_definitions(-DENABLE_UNLIMITED_CACHE=1) -add_definitions(-DENABLE_UNLIMITED_GLOBAL_CACHE=1) -add_definitions(-DENABLE_UNLIMITED_THREAD_CACHE=1) + add_compile_definitions( + #if greedy is enabled, add greedy options + ENABLE_UNLIMITED_CACHE=1 + ENABLE_UNLIMITED_GLOBAL_CACHE=1 + ENABLE_UNLIMITED_THREAD_CACHE=1 -#On by default but we otherwise disable global cache to really reduce commited size -add_definitions(-DENABLE_GLOBAL_CACHE=1) -add_definitions(-DENABLE_UNLIMITED_GLOBAL_CACHE=1) + #On by default but we otherwise disable global cache to really reduce commited size + ENABLE_GLOBAL_CACHE=1 + ENABLE_UNLIMITED_GLOBAL_CACHE=1 + ) else() -#disable greedy definitions -add_definitions(-DENABLE_UNLIMITED_CACHE 0) -add_definitions(-DENABLE_UNLIMITED_GLOBAL_CACHE=0) -add_definitions(-DENABLE_UNLIMITED_THREAD_CACHE=0) -add_definitions(-DENABLE_GLOBAL_CACHE=0) + add_compile_definitions( + #disable greedy definitions + ENABLE_UNLIMITED_CACHE=0 + ENABLE_UNLIMITED_GLOBAL_CACHE=0 + ENABLE_UNLIMITED_THREAD_CACHE=0 + ENABLE_GLOBAL_CACHE=0 -#also disable unlimited global cache to release spans to OS -add_definitions(-DENABLE_UNLIMITED_GLOBAL_CACHE=0) + #also disable unlimited global cache to release spans to OS + ENABLE_UNLIMITED_GLOBAL_CACHE=0 + ) endif() - diff --git a/lib/Utils.Memory/vnlib_rpmalloc/NativeHeapApi.h b/lib/Utils.Memory/vnlib_rpmalloc/NativeHeapApi.h index 6a994b2..1738d19 100644 --- a/lib/Utils.Memory/vnlib_rpmalloc/NativeHeapApi.h +++ b/lib/Utils.Memory/vnlib_rpmalloc/NativeHeapApi.h @@ -5,13 +5,13 @@ * Package: NativeHeapApi * File: NativeHeapApi.h * -* This library is free software; you can redistribute it and/or +* This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License -* as published by the Free Software Foundation; either version 2.1 -* of the License, or (at your option) any later version. +* as published by the Free Software Foundation; either version 2.1 +* of the License, or (at your option) any later version. * -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * @@ -30,78 +30,60 @@ #define _P_IS_WINDOWS #endif -//Set api export calling convention (allow used to override) +/* Set api export calling convention (allow used to override) */ #ifndef VNLIB_CC #ifdef _P_IS_WINDOWS - //STD for importing to other languages such as .NET - #define VNLIB_CC __stdcall + /* STD for importing to other languages such as.NET */ + #define VNLIB_CC __stdcall #else #define VNLIB_CC #endif -#endif // !NC_CC +#endif /* !VNLIB_CC */ -#ifndef VNLIB_EXPORT //Allow users to disable the export/impoty macro if using source code directly +#ifndef VNLIB_HEAP_API /* Allow users to disable the export/impoty macro if using source code directly */ #ifdef VNLIB_EXPORTING #ifdef _P_IS_WINDOWS #define VNLIB_HEAP_API __declspec(dllexport) #else #define VNLIB_HEAP_API __attribute__((visibility("default"))) - #endif // _NC_IS_WINDOWS + #endif /* _P_IS_WINDOWS */ #else #ifdef _P_IS_WINDOWS #define VNLIB_HEAP_API __declspec(dllimport) #else #define VNLIB_HEAP_API - #endif // _P_IS_WINDOWS - #endif // !VNLIB_EXPORTING -#endif // !VNLIB_EXPORT + #endif /* _P_IS_WINDOWS */ + #endif /* !VNLIB_EXPORTING */ +#endif /* !VNLIB_EXPORT */ -/// <summary> -/// Internal heap creation flags passed to the creation method by the library loader -/// </summary> +/* Internal heap creation flags passed to the creation method by the library loader */ typedef enum HeapCreationFlags { - /// <summary> - /// Default/no flags - /// </summary> + /* Default/no flags */ HEAP_CREATION_NO_FLAGS, - /// <summary> - /// Specifies that all allocations be zeroed before returning to caller - /// </summary> + /* Specifies that all allocations be zeroed before returning to caller */ HEAP_CREATION_GLOBAL_ZERO = 0x01, - /// <summary> - /// Specifies that the heap should use internal locking, aka its not thread safe - /// and needs to be made thread safe - /// </summary> + /* Specifies that the heap should use internal locking, aka its not thread safe + and needs to be made thread safe */ HEAP_CREATION_SERIALZE_ENABLED = 0x02, - /// <summary> - /// Specifies that the requested heap will be a shared heap for the process/library - /// </summary> + /* Specifies that the requested heap will be a shared heap for the process/library */ HEAP_CREATION_IS_SHARED = 0x04, - /// <summary> - /// Specifies that the heap will support block reallocation - /// </summary> - HEAP_CREATION_SUPPORTS_REALLOC = 0x08, + /* Specifies that the heap will support block reallocation */ + HEAP_CREATION_SUPPORTS_REALLOC = 0x08 } HeapCreationFlags; #ifdef _P_IS_WINDOWS - typedef void* LPVOID; -#endif // !WIN32 +typedef void* LPVOID; +#endif /* !WIN32 */ -/// <summary> -/// The vnlib ERRNO type, integer/process dependent, -/// internally represented as a pointer -/// </summary> +/* The vnlib ERRNO type, integer/process dependent, +internally represented as a pointer */ typedef void* ERRNO; -/// <summary> -/// A pointer to a heap structure that was stored during heap creation -/// </summary> +/* A pointer to a heap structure that was stored during heap creation */ typedef void* HeapHandle; -/// <summary> -/// A structure for heap initialization -/// </summary> +/* A structure for heap initialization */ typedef struct UnmanagedHeapDescriptor { HeapHandle HeapPointer; @@ -109,56 +91,60 @@ typedef struct UnmanagedHeapDescriptor HeapCreationFlags CreationFlags; } UnmanagedHeapDescriptor; -/// <summary> -/// Gets the shared heap handle for the process/library -/// </summary> -/// <returns>A pointer to the shared heap</returns> +/* Gets the shared heap handle for the process/library +Returns: A pointer to the shared heap +*/ VNLIB_HEAP_API HeapHandle VNLIB_CC heapGetSharedHeapHandle(void); -/// <summary> -/// The heap creation method. You must set the flags->HeapPointer = your heap -/// structure -/// </summary> -/// <param name="flags">Creation flags passed by the caller to create the heap. This structure will be initialized, and may be modified</param> -/// <returns>A boolean value that indicates the result of the operation</returns> +/* The heap creation method. You must set the flags->HeapPointer = your heap +structure. +Parameters: + flags - Creation flags passed by the caller to create the heap. This structure will be initialized, and may be modified +Returns: A boolean value that indicates the result of the operation +*/ VNLIB_HEAP_API ERRNO VNLIB_CC heapCreate(UnmanagedHeapDescriptor* flags); -/// <summary> -/// Destroys a previously created heap -/// </summary> -/// <param name="heap">The pointer to your custom heap structure from heap creation</param> +/* Destroys a previously created heap +Parameters: + heap - The pointer to your custom heap structure from heap creation +*/ VNLIB_HEAP_API ERRNO VNLIB_CC heapDestroy(HeapHandle heap); -/// <summary> -/// Allocates a block from the desired heap and returns a pointer -/// to the block. Optionally zeros the block before returning -/// </summary> -/// <param name="heap">A pointer to your heap structure</param> -/// <param name="elements">The number of elements to allocate</param> -/// <param name="alignment">The alignment (or size) of each element in bytes</param> -/// <param name="zero">A flag to zero the block before returning the block</param> -/// <returns>A pointer to the allocated block</returns> +/* Allocates a block from the desired heap and returns a pointer +to the block. Optionally zeros the block before returning + +Parameters: + heap - A pointer to your heap structure + elements - The number of elements to allocate + alignment - The alignment (or size) of each element in bytes + zero - A flag to zero the block before returning the block + +Returns: A pointer to the allocated block +*/ VNLIB_HEAP_API void* VNLIB_CC heapAlloc(HeapHandle heap, uint64_t elements, uint64_t alignment, int zero); -/// <summary> -/// Reallocates a block on the desired heap and returns a pointer to the new block. If reallocation -/// is not supported, you should only return 0 and leave the block unmodified. The data in the valid -/// size of the block MUST remain unmodified. -/// </summary> -/// <param name="heap">A pointer to your heap structure</param> -/// <param name="block">A pointer to the block to reallocate</param> -/// <param name="elements">The new size of the block, in elements</param> -/// <param name="alignment">The element size or block alignment</param> -/// <param name="zero">A flag to zero the block (or the new size) before returning.</param> -/// <returns>A pointer to the reallocated block, or zero if the operation failed or is not supported</returns> +/* Reallocates a block on the desired heap and returns a pointer to the new block. If reallocation +is not supported, you should only return 0 and leave the block unmodified. The data in the valid +size of the block MUST remain unmodified. + +Parameters: + heap - A pointer to your heap structure + block - A pointer to the block to reallocate + elements - The new size of the block, in elements + alignment - The element size or block alignment + zero - A flag to zero the block (or the new size) before returning. + +Returns: A pointer to the reallocated block, or zero if the operation failed or is not supported +*/ VNLIB_HEAP_API void* VNLIB_CC heapRealloc(HeapHandle heap, void* block, uint64_t elements, uint64_t alignment, int zero); -/// <summary> -/// Frees a previously allocated block on the desired heap. -/// </summary> -/// <param name="heap">A pointer to your heap structure</param> -/// <param name="block">A pointer to the block to free</param> -/// <returns>A value that indicates the result of the operation, nonzero if success, 0 if a failure occurred </returns> +/* Frees a previously allocated block on the desired heap. +Parameters: + heap - A pointer to your heap structure + block - A pointer to the block to free + +Returns: A value that indicates the result of the operation, nonzero if success, 0 if a failure occurred +*/ VNLIB_HEAP_API ERRNO VNLIB_CC heapFree(HeapHandle heap, void* block); -#endif // !NATIVE_HEAP_API
\ No newline at end of file +#endif /* !NATIVE_HEAP_API */ diff --git a/lib/Utils.Memory/vnlib_rpmalloc/Taskfile.yaml b/lib/Utils.Memory/vnlib_rpmalloc/Taskfile.yaml index b9d5d70..40bdc7c 100644 --- a/lib/Utils.Memory/vnlib_rpmalloc/Taskfile.yaml +++ b/lib/Utils.Memory/vnlib_rpmalloc/Taskfile.yaml @@ -10,16 +10,17 @@ version: '3' vars: PROJECT_NAME: 'vnlib_rpmalloc' - MODULE_NAME: 'vnlib.core' tasks: default: desc: "Builds the entire project from source code without using the VNBuild build system for target machines" cmds: - #build with defaults - - task: build - - cmd: echo "Your vnlib_rpmalloc dll file can be found in '{{.USER_WORKING_DIR}}/build'" + #build with defaults + #init cmake build with greedy enabled + - cmake -Bbuild/ -DCMAKE_BUILD_TYPE=Release -DENABLE_GREEDY=1 {{.CMAKE_ARGS}} + - cmake --build build/ --config Release + - cmd: echo "Your vnlib_rpmalloc library file can be found in '{{.USER_WORKING_DIR}}/build'" silent: true build: @@ -76,9 +77,8 @@ tasks: cmds: - powershell -Command "tar --exclude build/* --exclude bin/* --exclude vendor/build/* -czf 'bin/src.tgz' ." - clean: ignore_error: true - cmds: - - cmd: powershell -Command "Remove-Item -Recurse 'bin/'" - - cmd: powershell -Command "Remove-Item -Recurse 'build/'"
\ No newline at end of file + cmds: + - for: [ bin/, build/ ] + cmd: powershell Remove-Item -Recurse '{{.ITEM}}' -Force
\ No newline at end of file diff --git a/lib/Utils.Memory/vnlib_rpmalloc/build.readme.txt b/lib/Utils.Memory/vnlib_rpmalloc/build.readme.txt index 77f2193..79a7091 100644 --- a/lib/Utils.Memory/vnlib_rpmalloc/build.readme.txt +++ b/lib/Utils.Memory/vnlib_rpmalloc/build.readme.txt @@ -1,4 +1,4 @@ -vnlib_rpmalloc Copyright (C) 2023 Vaughn Nugent +vnlib_rpmalloc Copyright (C) 2024 Vaughn Nugent vnlib_rpmalloc is a wrapper library for rpmalloc by Mattias Jansson that implements the NativeHeapApi functions, and exports them by default for use as a library. The CMake configuration is setup to produce both diff --git a/lib/Utils.Memory/vnlib_rpmalloc/vnlib_rpmalloc.c b/lib/Utils.Memory/vnlib_rpmalloc/vnlib_rpmalloc.c index 2b63dcc..c1a836b 100644 --- a/lib/Utils.Memory/vnlib_rpmalloc/vnlib_rpmalloc.c +++ b/lib/Utils.Memory/vnlib_rpmalloc/vnlib_rpmalloc.c @@ -134,7 +134,10 @@ int pthread_create(pthread_t* thread, thread_starter_arg* starter_arg = rpmalloc(sizeof(thread_starter_arg)); starter_arg->real_start = start_routine; starter_arg->real_arg = arg; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" return (*(int (*)(pthread_t*, const pthread_attr_t*, void* (*)(void*), void*))real_pthread_create)(thread, attr, thread_starter, starter_arg); +#pragma GCC diagnostic pop } #endif diff --git a/lib/Utils.Memory/vnlib_rpmalloc/vnlib_rpmalloc.vcxitems b/lib/Utils.Memory/vnlib_rpmalloc/vnlib_rpmalloc.vcxitems index eeda4c8..44fef45 100644 --- a/lib/Utils.Memory/vnlib_rpmalloc/vnlib_rpmalloc.vcxitems +++ b/lib/Utils.Memory/vnlib_rpmalloc/vnlib_rpmalloc.vcxitems @@ -27,6 +27,7 @@ <None Include="$(MSBuildThisFileDirectory)Taskfile.yaml" /> </ItemGroup> <ItemGroup> + <ClInclude Include="$(MSBuildThisFileDirectory)NativeHeapApi.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)vendor\rpmalloc.h" /> </ItemGroup> </Project>
\ No newline at end of file |