aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-04-20 12:23:40 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2024-04-20 12:23:40 -0400
commit107b058a38d6785b350826c6fb01bb64997c630a (patch)
treee0cb1664982934c6d87002864d50642f1d0b0645
parente07537a3dde8e16100ef1bcc2a54f9ade8ae856f (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
-rw-r--r--lib/Hashing.Portable/tests/VNLib.Hashing.PortableTests.csproj6
-rw-r--r--lib/Net.Compression/VNLib.Net.CompressionTests/VNLib.Net.CompressionTests.csproj6
-rw-r--r--lib/Net.Compression/vnlib_compress/CMakeLists.txt464
-rw-r--r--lib/Net.Compression/vnlib_compress/Taskfile.yaml57
-rw-r--r--lib/Net.Compression/vnlib_compress/compression.h16
-rw-r--r--lib/Net.Compression/vnlib_compress/feature_brotli.c6
-rw-r--r--lib/Net.Compression/vnlib_compress/util.h56
-rw-r--r--lib/Net.Http/src/Core/ConnectionInfo.cs3
-rw-r--r--lib/Net.Http/src/Core/HttpCookie.cs50
-rw-r--r--lib/Net.Http/src/Core/Response/HttpResponse.cs11
-rw-r--r--lib/Net.Http/src/Helpers/HttpHelpers.cs5
-rw-r--r--lib/Plugins.Essentials.ServiceStack/src/Construction/SsBuilderExtensions.cs6
-rw-r--r--lib/Plugins.Essentials.ServiceStack/src/PluginStackInitializer.cs2
-rw-r--r--lib/Plugins.Essentials/src/Extensions/SingleCookieController.cs4
-rw-r--r--lib/Utils.Memory/NativeHeapApi/src/NativeHeapApi.h160
-rw-r--r--lib/Utils.Memory/vnlib_mimalloc/CMakeLists.txt151
-rw-r--r--lib/Utils.Memory/vnlib_mimalloc/NativeHeapApi.h160
-rw-r--r--lib/Utils.Memory/vnlib_mimalloc/Taskfile.yaml23
-rw-r--r--lib/Utils.Memory/vnlib_rpmalloc/CMakeLists.txt130
-rw-r--r--lib/Utils.Memory/vnlib_rpmalloc/NativeHeapApi.h160
-rw-r--r--lib/Utils.Memory/vnlib_rpmalloc/Taskfile.yaml16
-rw-r--r--lib/Utils.Memory/vnlib_rpmalloc/build.readme.txt2
-rw-r--r--lib/Utils.Memory/vnlib_rpmalloc/vnlib_rpmalloc.c3
-rw-r--r--lib/Utils.Memory/vnlib_rpmalloc/vnlib_rpmalloc.vcxitems1
-rw-r--r--lib/Utils/tests/VNLib.UtilsTests.csproj6
25 files changed, 629 insertions, 875 deletions
diff --git a/lib/Hashing.Portable/tests/VNLib.Hashing.PortableTests.csproj b/lib/Hashing.Portable/tests/VNLib.Hashing.PortableTests.csproj
index db95906..1834464 100644
--- a/lib/Hashing.Portable/tests/VNLib.Hashing.PortableTests.csproj
+++ b/lib/Hashing.Portable/tests/VNLib.Hashing.PortableTests.csproj
@@ -15,9 +15,9 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
- <PackageReference Include="MSTest.TestAdapter" Version="3.2.2" />
- <PackageReference Include="MSTest.TestFramework" Version="3.2.2" />
- <PackageReference Include="coverlet.collector" Version="6.0.1">
+ <PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
+ <PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
+ <PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
diff --git a/lib/Net.Compression/VNLib.Net.CompressionTests/VNLib.Net.CompressionTests.csproj b/lib/Net.Compression/VNLib.Net.CompressionTests/VNLib.Net.CompressionTests.csproj
index fb462d1..24fc844 100644
--- a/lib/Net.Compression/VNLib.Net.CompressionTests/VNLib.Net.CompressionTests.csproj
+++ b/lib/Net.Compression/VNLib.Net.CompressionTests/VNLib.Net.CompressionTests.csproj
@@ -9,9 +9,9 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
- <PackageReference Include="MSTest.TestAdapter" Version="3.2.2" />
- <PackageReference Include="MSTest.TestFramework" Version="3.2.2" />
- <PackageReference Include="coverlet.collector" Version="6.0.1">
+ <PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
+ <PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
+ <PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
diff --git a/lib/Net.Compression/vnlib_compress/CMakeLists.txt b/lib/Net.Compression/vnlib_compress/CMakeLists.txt
index f963c41..c3eb723 100644
--- a/lib/Net.Compression/vnlib_compress/CMakeLists.txt
+++ b/lib/Net.Compression/vnlib_compress/CMakeLists.txt
@@ -1,95 +1,181 @@
-cmake_minimum_required(VERSION 3.0)
+cmake_minimum_required(VERSION 3.10)
project(vnlib_compress C)
-
-#export header files to the main project
-file(GLOB COMP_HEADERS *.h)
-
-#Add indepednent source files to the project
-set(VNLIB_COMPRESS_SOURCES compression.c)
+set(CMAKE_PROJECT_NAME "vnlib_compress")
#set options for enable botli and zlib
option(ENABLE_BROTLI "Enable brotli compression" ON)
option(ENABLE_ZLIB "Enable zlib compression" ON)
option(ENABLE_RPMALLOC "Enable local source code vnlib_rpmalloc memory allocator" OFF)
+option(COMPRESS_BUILD_SHARED "Produces a shared library instead of a static library" ON)
+option(USE_STATIC_RUNTIME "Use the static runtime library" OFF)
+set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The build configuration type")
+
+string(TOLOWER ${CMAKE_BUILD_TYPE} build_type)
+message(STATUS "Build type is '${build_type}'")
-set(THIRD_PARTY_DIR ./third-party)
+#export all header files to the main project
+file(GLOB COMP_HEADERS *.h)
+set(VNLIB_COMPRESS_SOURCES
+ compression.c
+)
+
+include(FetchContent)
+
+###############################
+#
+# DOWNLOAD DEPENDENCIES
+#
+###############################
-#add feature specific source files to the project
if(ENABLE_BROTLI)
+
+ message(STATUS "Downloading brotli compression as a local dependency")
+
+ set(BROTLI_BUNDLED_MODE OFF) #explicitly set bundled mode to off
+ set(BROTLI_EMSCRIPTEN OFF) #disable emscripten support
+ set(BUILD_SHARED_LIBS OFF) #disable shared library building, as only static is needed
+
+ FetchContent_Declare(
+ lib_brotli
+ GIT_REPOSITORY https://github.com/google/brotli.git
+ GIT_TAG 1b3a5ccb6e7b9384b741437532f4dae0730c61f2
+ GIT_PROGRESS TRUE
+ )
+
+ FetchContent_GetProperties(lib_brotli)
+ FetchContent_MakeAvailable(lib_brotli)
+
+ #add include directories for brotli
+ include_directories(${lib_brotli_SOURCE_DIR}/c/include)
+
+ #add the brotli source files to the project
list(APPEND VNLIB_COMPRESS_SOURCES feature_brotli.c)
- #define the brotli feature macro to enable zlib support
- add_definitions(-DVNLIB_COMPRESSOR_BROTLI_ENABLED)
+ add_compile_definitions(VNLIB_COMPRESSOR_BROTLI_ENABLED)
endif()
if(ENABLE_ZLIB)
+
+ #by default the cloudlfare fork should build a static lib. It will be large
+ message(STATUS "Downloading ZLIB as a local dependency")
+
+ set(SKIP_INSTALL_ALL ON) #do not install zlib files
+
+ #add zlib source files to the project
+ FetchContent_Declare(
+ lib_cf_zlib
+ GIT_REPOSITORY https://github.com/cloudflare/zlib.git
+ GIT_TAG 92530568d2c128b4432467b76a3b54d93d6350bd
+ GIT_PROGRESS TRUE
+ )
+
+ #Get project properties
+ FetchContent_GetProperties(lib_cf_zlib)
+ FetchContent_MakeAvailable(lib_cf_zlib)
+
+ #add include directories for zlib
+ include_directories(${lib_cf_zlib_SOURCE_DIR})
+
+ #enable the feature code for zlib and add the source files
list(APPEND VNLIB_COMPRESS_SOURCES feature_zlib.c)
- #define the zlib feature macro to enable zlib support
- add_definitions(-DVNLIB_COMPRESSOR_ZLIB_ENABLED)
+ add_compile_definitions(VNLIB_COMPRESSOR_ZLIB_ENABLED)
endif()
-#create my shared library
-add_library(${CMAKE_PROJECT_NAME} SHARED ${VNLIB_COMPRESS_SOURCES} ${COMP_HEADERS})
-#also create static library
-add_library(${CMAKE_PROJECT_NAME}_static STATIC ${VNLIB_COMPRESS_SOURCES} ${COMP_HEADERS})
+#Add support for rpmalloc memmory allocator
+if(ENABLE_RPMALLOC)
-#if on unix lib will be appended, so we can adjust
-if(UNIX)
- set_target_properties(${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_NAME}_static PROPERTIES OUTPUT_NAME vn_compress)
+ #enable greedy mode for rpmalloc
+ set(ENABLE_GREEDY ON)
+
+ add_subdirectory(
+ ../../Utils.Memory/vnlib_rpmalloc/
+ ${CMAKE_CURRENT_BINARY_DIR}/vnlib_rpmalloc/
+ )
+
+ add_compile_definitions(VNLIB_CUSTOM_MALLOC_ENABLE)
endif()
#Setup the compiler options
-set(CMAKE_C_STANDARD 90)
set(CMAKE_C_STANDARD_REQUIRED ON)
+set(CMAKE_POSITION_INDEPENDENT_CODE ON) #enable position independent code (for shared libraries with exports)
+
+###############################
+#
+# CONFIGURE LIBRARY BUILD
+#
+###############################
+
+if(COMPRESS_BUILD_SHARED)
+ set(TARGET_NAME ${CMAKE_PROJECT_NAME})
+ add_library(${TARGET_NAME} SHARED ${VNLIB_COMPRESS_SOURCES} ${COMP_HEADERS})
+else()
+ set(TARGET_NAME ${CMAKE_PROJECT_NAME}_static)
+ add_library(${TARGET_NAME} STATIC ${VNLIB_COMPRESS_SOURCES} ${COMP_HEADERS})
+endif()
-#enable position independent code (for shared libraries with exports)
-set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+target_compile_features(${TARGET_NAME} PRIVATE c_std_90) #force compiler to use c90 standard for library
+
+#if on unix lib will be appended, so we can adjust
+if(UNIX)
+ set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME vn_compress)
+endif()
#since were buildiing in tree, set the export defintiions
-add_definitions(-DVNLIB_EXPORTING)
+target_compile_definitions(${TARGET_NAME} PRIVATE VNLIB_EXPORTING)
+
+if(ENABLE_BROTLI)
+ #link the encoder-only library to the main project
+ target_link_libraries(${TARGET_NAME} PRIVATE brotlienc)
+endif()
+
+if(ENABLE_ZLIB)
+ #workaround cloudlfare fork bug. SSE is always enabled with x64 on Windows
+ if(MSVC)
+ target_compile_definitions(zlib PRIVATE HAS_SSE42 PRIVATE HAS_SSE2)
+ endif()
+
+ target_link_libraries(${TARGET_NAME} PRIVATE zlib)
+endif()
-message(STATUS "Build type is '${CMAKE_BUILD_TYPE}'")
+#link rpmalloc to the main project
+if(ENABLE_RPMALLOC)
+ target_link_libraries(${TARGET_NAME} PRIVATE vnlib_rpmalloc_static)
+ add_dependencies(${TARGET_NAME} vnlib_rpmalloc_static)
-#include checks for zlib and brotli
-include(CheckTypeSize)
-include(CheckFunctionExists)
-include(CheckIncludeFile)
-include(CheckCCompilerFlag)
-enable_testing()
+ #Include the nativeheap api header
+ target_include_directories(${TARGET_NAME} PRIVATE ../../Utils.Memory/vnlib_rpmalloc/)
+endif()
#setup flags for windows compilation
if(MSVC)
-
- #global windows cl flags
- add_compile_options(
+ target_compile_options(
+ ${TARGET_NAME}
+ PRIVATE
+
/Qspectre
/sdl
/TC
/GS
-
- $<$<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 when WX is enabled
+ $<$<CONFIG:Debug>:/wd5045>
+ $<$<CONFIG:Debug>:/wd4820>
#for debug configs
$<$<CONFIG:Debug>:/options:strict>
- #disable warnings for struct padding and spectre mitigation wuen WX is enabled
- $<$<CONFIG:Debug>:/wd5045>
- $<$<CONFIG:Debug>:/wd4820>
+ $<$<CONFIG:Debug>:/FC> #full path in diagnostics
$<$<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>:/showIncludes>
)
#set build macros
- add_compile_definitions(
+ target_compile_definitions(
+ ${TARGET_NAME}
+ PRIVATE
+
$<$<CONFIG:DEBUG>:DEBUG>
$<$<CONFIG:RELEASE>:RELEASE>
)
@@ -97,215 +183,33 @@ 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(
- ${CMAKE_PROJECT_NAME}
+ target_compile_options(
+ ${TARGET_NAME}
PRIVATE
- $<$<CONFIG:Debug>:-Wall>
- $<$<CONFIG:Debug>:-pedantic>
- )
-endif()
-
-#check for brotli encoding only feature enablement
-if(ENABLE_BROTLI)
-
- #macros for brotli
- set(BROTLI_DEFINITIONS)
-
- set(LIBM_LIBRARY)
- check_function_exists(log2 LOG2_RES)
-
- if(NOT LOG2_RES)
-
- set(orig_req_libs "${CMAKE_REQUIRED_LIBRARIES}")
- set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};m")
-
- check_function_exists(log2 LOG2_LIBM_RES)
-
- if(LOG2_LIBM_RES)
- set(LIBM_LIBRARY "m")
- list(APPEND BROTLI_DEFINITIONS -DBROTLI_HAVE_LOG2=1)
- else()
- list(APPEND BROTLI_DEFINITIONS -DBROTLI_HAVE_LOG2=0)
- endif()
-
- set(CMAKE_REQUIRED_LIBRARIES "${orig_req_libs}")
- unset(LOG2_LIBM_RES)
- unset(orig_req_libs)
- else()
- list(APPEND BROTLI_DEFINITIONS -DBROTLI_HAVE_LOG2=1)
- endif()
- unset(LOG2_RES)
-
- #target definitions from brotli cmakelists
- if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
- list(APPEND BROTLI_DEFINITIONS -DOS_LINUX)
- elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
- list(APPEND BROTLI_DEFINITIONS -DOS_FREEBSD)
- elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
- list(APPEND BROTLI_DEFINITIONS -DOS_MACOSX)
- set(CMAKE_MACOS_RPATH TRUE)
- endif()
-
- #add the include directory for brotli so we can include the header files
- include_directories(${THIRD_PARTY_DIR}/brotli/c/include)
-
- #get common sources
- file(GLOB BROTLI_SOURCES ${THIRD_PARTY_DIR}/brotli/c/common/*.c)
-
- #we need to add the brotli encoder source files to the project
- file(GLOB BROTLI_ENC_SOURCES ${THIRD_PARTY_DIR}/brotli/c/enc/*.c)
-
- #add brotli as a static library to link later
- add_library(lib_brotli STATIC ${BROTLI_SOURCES} ${BROTLI_ENC_SOURCES})
-
- target_link_libraries(${CMAKE_PROJECT_NAME} lib_brotli)
-
- #add the definitions to the brotli project only
- target_compile_definitions(lib_brotli PRIVATE ${BROTLI_DEFINITIONS})
-
-endif()
-
-#check for zlib feature enablement, supports madler and cloudflare forks
-if(ENABLE_ZLIB)
-
- #add the include directory for zlib so we can include the header files
- include_directories(${THIRD_PARTY_DIR}/zlib)
-
- set(ZLIB_DEFINITIONS)
- set(Z_C_FLAGS)
-
- #we only need to add the zlib deflate source files to the project
- set(ZLIB_SOURCES
- ${THIRD_PARTY_DIR}/zlib/deflate.c
- ${THIRD_PARTY_DIR}/zlib/adler32.c
- ${THIRD_PARTY_DIR}/zlib/crc32.c
- ${THIRD_PARTY_DIR}/zlib/zutil.c
- ${THIRD_PARTY_DIR}/zlib/trees.c
+ -Wextra
+ -fstack-protector
)
-
- check_type_size(off64_t OFF64_T)
- check_function_exists(fseeko HAVE_FSEEKO)
-
- if(HAVE_OFF64_T)
- list(APPEND ZLIB_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
- endif()
- #add fseeko if we have it
- if(NOT HAVE_FSEEKO)
- list(APPEND ZLIB_DEFINITIONS -DNO_FSEEKO)
- endif()
-
- if(MSVC)
-
- set(CMAKE_DEBUG_POSTFIX "d")
-
- list(APPEND ZLIB_DEFINITIONS
- -D_CRT_SECURE_NO_DEPRECATE
- -D_CRT_NONSTDC_NO_DEPRECATE
+ #enable debug compiler options
+ if(build_type STREQUAL "debug")
+ target_compile_options(
+ ${TARGET_NAME}
+ PRIVATE
+
+ -g #enable debugger info
+ -Og #disable optimizations
+ -Wall #enable all warnings
+ -Werror #treat warnings as errors
+ -pedantic #enable pedantic mode
)
-
- #NOTE
- #During CI a pre-compiled library will be built.
- #We cannot depend on users having the the same instructions as the build machine
- #So some optimizations are disabled for the pre-compiled library
-
- if(NOT CI_PRECOMPILE)
-
- #setup avx compiler support on Windows
- check_c_compiler_flag(/arch:AVX HAS_AVX)
- if (HAS_AVX)
- list(APPEND Z_C_FLAGS /arch:AVX)
- list(APPEND ZLIB_DEFINITIONS -DHAS_AVX)
- endif()
-
- endif()
-
- #All x64 machines have SSE2, so we can use it as
- #and the Windows compiler will automatically use it
- #so we only need to set the definition
- list(APPEND Z_C_FLAGS /arch:SSE2)
- list(APPEND ZLIB_DEFINITIONS -DHAS_SSE2 -DHAS_SSE42)
-
- elseif(UNIX)
-
- #for cloudflare intrinsic detections
- check_c_compiler_flag(-march=armv8-a+crc ARM_CRC)
- check_c_compiler_flag(-msse2 HAS_SSE2)
- check_c_compiler_flag(-mssse3 HAS_SSSE3)
- check_c_compiler_flag(-msse4.2 HAS_SSE42)
- check_c_compiler_flag(-mpclmul HAS_PCLMUL)
-
- if(ARM_CRC)
- list(APPEND Z_C_FLAGS -march=armv8-a+crc)
-
- if(EXISTS "{THIRD_PARTY_DIR}/zlib/adler32_simd.c")
- list(APPEND ZLIB_DEFINITIONS -DADLER32_SIMD_NEON)
- list(APPEND ZLIB_SOURCES ${THIRD_PARTY_DIR}/zlib/adler32_simd.c)
- endif()
-
- else()
- if(HAS_SSE2)
- list(APPEND Z_C_FLAGS -msse2)
- list(APPEND ZLIB_DEFINITIONS -DHAS_SSE2)
- #excluding inflate specific optimizations
- endif()
- if(HAS_SSSE3)
- list(APPEND Z_C_FLAGS -mssse3)
-
- #add cloudflare intrinsic optimizations, may not be present if using non-cloudflare fork
- if(EXISTS "${THIRD_PARTY_DIR}/zlib/adler32_simd.c")
- list(APPEND ZLIB_DEFINITIONS -DHAS_SSSE3 -DADLER32_SIMD_SSSE3)
- list(APPEND ZLIB_SOURCES ${THIRD_PARTY_DIR}/zlib/adler32_simd.c)
- endif()
-
- endif()
- if(HAS_SSE42)
- list(APPEND Z_C_FLAGS -msse4.2)
- list(APPEND ZLIB_DEFINITIONS -DHAS_SSE42)
- endif()
- if(HAS_PCLMUL)
- list(APPEND Z_C_FLAGS -mpclmul)
-
- #add cloudflare intrinsic optimizations for PCMLONGMUL crc32, may not be present if using non-cloudflare fork
- if(EXISTS "${THIRD_PARTY_DIR}/zlib/crc32_simd.c")
- list(APPEND ZLIB_DEFINITIONS -DHAS_PCLMUL)
- list(APPEND ZLIB_SOURCES ${THIRD_PARTY_DIR}/zlib/crc32_simd.c)
- endif()
-
- endif()
- endif()
- endif()
-
-
-
- #add zlib as a library to link later
- add_library(lib_deflate STATIC ${ZLIB_SOURCES})
+ target_compile_definitions(${TARGET_NAME} PRIVATE DEBUG)
- if(MSVC)
- #allways targeting x64 machines
- set_target_properties(lib_deflate PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64")
endif()
- #add the definitions to the zlib project only
- target_compile_definitions(lib_deflate PRIVATE ${ZLIB_DEFINITIONS})
-
- #only target zlib project with compiler flags
- target_compile_options(lib_deflate PRIVATE ${Z_C_FLAGS})
-
- target_link_libraries(${CMAKE_PROJECT_NAME} lib_deflate)
+else()
+ message(FATAL_ERROR "Unsupported compiler, sorry. Submit an issue for your platform and I'll work on it :)")
endif()
if(NATIVE_HEAP_LIB_PATH)
@@ -314,63 +218,7 @@ if(NATIVE_HEAP_LIB_PATH)
include_directories(${NATIVE_HEAP_INCLUDES})
#If manual heap linking is enabled, we need to link the native heap library
- target_link_libraries(${CMAKE_PROJECT_NAME} ${NATIVE_HEAP_LIB_PATH})
-
- #Disable rpmalloc if we are linking a custom native heap
- set(ENABLE_RPMALLOC OFF)
-
- #add defintion to enable custom malloc heap overrides
- target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE VNLIB_CUSTOM_MALLOC_ENABLE)
-
-endif()
-
-#Add support for rpmalloc memmory allocator
-if(ENABLE_RPMALLOC)
-
- #Include the nativeheap api header
- include_directories(../../Utils.Memory/NativeHeapApi/src)
-
- if(MSVC)
+ target_link_libraries(${TARGET_NAME} PRIVATE ${NATIVE_HEAP_LIB_PATH})
+ target_compile_definitions(${TARGET_NAME} PRIVATE VNLIB_CUSTOM_MALLOC_ENABLE) #configure src
- #find the rpmalloc static library for windows builds
- find_library(VNLIB_RPMALLOC_DEBUG_LIB
- NAMES vnlib_rpmalloc_static
- PATHS ../../Utils.Memory/vnlib_rpmalloc/build/Debug
- )
-
- find_library(VNLIB_RPMALLOC_RELEASE_LIB
- NAMES vnlib_rpmalloc_static
- PATHS ../../Utils.Memory/vnlib_rpmalloc/build/Release
- )
-
- #target static libraries for all configs
- target_link_libraries(${CMAKE_PROJECT_NAME}
- $<$<CONFIG:Debug>:${VNLIB_RPMALLOC_DEBUG_LIB}>
- #set release for all release configs
- $<$<CONFIG:MinSizeRel>:${VNLIB_RPMALLOC_RELEASE_LIB}>
- $<$<CONFIG:RelWithDepInfo>:${VNLIB_RPMALLOC_RELEASE_LIB}>
- $<$<CONFIG:Release>:${VNLIB_RPMALLOC_RELEASE_LIB}>
- )
-
- elseif(UNIX)
-
- #find the rpmalloc library for unix builds
- find_library(VNLIB_RPMALLOC_LIB
- NAMES libvn_rpmalloc
- PATHS ../../Utils.Memory/vnlib_rpmalloc/build
- )
-
- #add the rpmalloc library to the project
- target_link_libraries(${CMAKE_PROJECT_NAME} ${VNLIB_RPMALLOC_LIB})
-
- else()
-
- #failure
- message(FATAL_ERROR "Unsupported platform configuration for rpmalloc")
-
- endif()
-
- #add defintion to enable custom malloc heap overrides
- target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE VNLIB_CUSTOM_MALLOC_ENABLE)
-
-endif()
+endif() \ No newline at end of file
diff --git a/lib/Net.Compression/vnlib_compress/Taskfile.yaml b/lib/Net.Compression/vnlib_compress/Taskfile.yaml
index fff756d..4ddc464 100644
--- a/lib/Net.Compression/vnlib_compress/Taskfile.yaml
+++ b/lib/Net.Compression/vnlib_compress/Taskfile.yaml
@@ -9,50 +9,21 @@
version: '3'
vars:
- THIRD_PARTY_DIR: './third-party'
PROJECT_NAME: 'vnlib_compress'
- ZLIB_GIT_REPO: 'https://github.com/cloudflare/zlib.git'
- BROTLI_GIT_REPO: 'https://github.com/google/brotli.git'
tasks:
default:
cmds:
- - cmd: echo "Building vnlib_compress"
+ - cmd: echo "Building {{.PROJECT_NAME}}"
silent: true
-
- #make third-party dir before cloning libs
- - cmd: powershell -Command "mkdir '{{.THIRD_PARTY_DIR}}' -Force"
- platforms: [windows]
- ignore_error: true
- - cmd: mkdir -p '{{.THIRD_PARTY_DIR}}'
- platforms: [linux, darwin]
- ignore_error: true
-
- - task: zlib
- - task: brotli
-
- #invoke cmake for build
- - cmake -B./build {{.CMAKE_ARGS}}
-
- #build for platform
- - cmake --build build/ --config Release
-
+ - cmake -Bbuild/ -DCMAKE_BUILD_TYPE=Release {{.CMAKE_ARGS}}
+ - cmake --build build/ --config Release
#called by ci pipline to build the winx64 project
build:
cmds:
- #make third-party dir before cloning libs
- - cmd: powershell -Command "mkdir '{{.THIRD_PARTY_DIR}}' -Force"
- platforms: [windows]
- ignore_error: true
- - cmd: mkdir -p '{{.THIRD_PARTY_DIR}}'
- platforms: [linux, darwin]
- ignore_error: true
- - task: zlib
- - task: brotli
-
#the CI pipline may have issues reading modules if the third-party dir is not cleaned every time a build runs, only an issue after build
- defer: { task: clean-third-party }
@@ -85,31 +56,15 @@ tasks:
clean:
ignore_error: true
cmds:
- - for: [ bin/, build/, third-party/ ]
+ - for: [ bin/, build/ ]
cmd: powershell Remove-Item -Recurse '{{.ITEM}}' -Force
-
- #update or install the cloudflare fork of zlib library
- zlib:
- internal: true
- status:
- - cd {{.THIRD_PARTY_DIR}} && git clone {{.ZLIB_GIT_REPO}}
- cmds:
- - cd {{.THIRD_PARTY_DIR}}/zlib && git pull
-
- #update or install the google brotli library
- brotli:
- internal: true
- status:
- - cd {{.THIRD_PARTY_DIR}} && git clone {{.BROTLI_GIT_REPO}}
- cmds:
- - cd {{.THIRD_PARTY_DIR}}/brotli && git pull
clean-third-party:
internal: false
ignore_error: true
cmds:
- - cmd: powershell rm -Recurse -Force '{{.THIRD_PARTY_DIR}}'
+ - cmd: powershell rm -Recurse -Force 'build/_deps/'
platforms: [windows]
- - cmd: rm -rf {{.THIRD_PARTY_DIR}}
+ - cmd: rm -rf 'build/_deps/'
platforms: [linux, darwin]
\ No newline at end of file
diff --git a/lib/Net.Compression/vnlib_compress/compression.h b/lib/Net.Compression/vnlib_compress/compression.h
index a6a6104..3d03145 100644
--- a/lib/Net.Compression/vnlib_compress/compression.h
+++ b/lib/Net.Compression/vnlib_compress/compression.h
@@ -44,31 +44,31 @@
#define _IS_WINDOWS
#endif
-//Set api export calling convention (allow used to override)
+/*Set api export calling convention(allow used to override)*/
#ifndef VNLIB_COMPRESS_CC
#ifdef _IS_WINDOWS
- //STD for importing to other languages such as .NET
+ /*STD for importing to other languages such as.NET*/
#define VNLIB_COMPRESS_CC __stdcall
#else
#define VNLIB_COMPRESS_CC
#endif
-#endif // !VNLIB_CC
+#endif /* !VNLIB_CC */
-#ifndef VNLIB_COMPRESS_EXPORT //Allow users to disable the export/impoty macro if using source code directly
+#ifndef VNLIB_COMPRESS_EXPORT /*Allow users to disable the export/impoty macro if using source code directly*/
#ifdef VNLIB_COMPRESS_EXPORTING
#ifdef _IS_WINDOWS
#define VNLIB_COMPRESS_EXPORT __declspec(dllexport)
#else
#define VNLIB_COMPRESS_EXPORT __attribute__((visibility("default")))
- #endif // IS_WINDOWS
+ #endif /* IS_WINDOWS */
#else
#ifdef _IS_WINDOWS
#define VNLIB_COMPRESS_EXPORT __declspec(dllimport)
#else
#define VNLIB_COMPRESS_EXPORT
- #endif // IS_WINDOWS
- #endif // !VNLIB_EXPORTING
-#endif // !VNLIB_EXPORT
+ #endif /* IS_WINDOWS */
+ #endif /* !VNLIB_EXPORTING */
+#endif /* !VNLIB_EXPORT */
#ifndef _In_
#define _In_
diff --git a/lib/Net.Compression/vnlib_compress/feature_brotli.c b/lib/Net.Compression/vnlib_compress/feature_brotli.c
index d5ba141..361c61a 100644
--- a/lib/Net.Compression/vnlib_compress/feature_brotli.c
+++ b/lib/Net.Compression/vnlib_compress/feature_brotli.c
@@ -223,14 +223,14 @@ int BrCompressBlock(const CompressorState* state, CompressionOperation* operatio
int64_t BrGetCompressedSize(const CompressorState* state, uint64_t length, int32_t flush)
{
- (void)flush;
+ size_t size;
+
+ (void)sizeof(flush);
/*
* When the flush flag is set, the caller is requesting the
* entire size of the compressed data, which can include metadata
*/
- size_t size;
-
validateCompState(state)
if (length <= 0)
diff --git a/lib/Net.Compression/vnlib_compress/util.h b/lib/Net.Compression/vnlib_compress/util.h
index c29de4b..292e3bf 100644
--- a/lib/Net.Compression/vnlib_compress/util.h
+++ b/lib/Net.Compression/vnlib_compress/util.h
@@ -30,6 +30,8 @@
* will be enabled when heapapi.h is included.
*/
#ifdef VNLIB_CUSTOM_MALLOC_ENABLE
+ /* Since static linking ie snabled, heapapi must have extern symbol not dllimport */
+ #define VNLIB_HEAP_API extern
#include <NativeHeapApi.h>
#endif
@@ -37,32 +39,28 @@
#define IS_WINDOWS
#endif
-/* If not Windows, define inline */
-#ifndef IS_WINDOWS
- #ifndef inline
- #define inline __inline__
- #endif // !inline
-#endif // !IS_WINDOWS
-
-/* If not Windows, define inline */
-#ifndef IS_WINDOWS
- #ifndef inline
- #define inline __inline__
- #endif // !inline
-#endif // !IS_WINDOWS
-
-//NULL
+#if defined(IS_WINDOWS) || defined(inline) || defined(__clang__)
+ #define _cp_fn_inline inline
+#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 allows usage of inline keyword */
+ #define _cp_fn_inline inline
+#elif defined(__GNUC__) || defined(__GNUG__)
+ #define _cp_fn_inline __inline__
+#else
+ #define _cp_fn_inline
+ #pragma message("Warning: No inline keyword defined for this compiler")
+#endif
+
#ifndef NULL
#define NULL ((void*)0)
-#endif // !NULL
+#endif /* !NULL */
#ifndef TRUE
#define TRUE 1
-#endif // !TRUE
+#endif /* !TRUE */
#ifndef FALSE
#define FALSE 0
-#endif // !FALSE
+#endif /* !FALSE */
/*
* Add debug runtime assertions
@@ -76,6 +74,9 @@
#define CHECK_NULL_PTR(ptr) if(!ptr) return ERR_INVALID_PTR;
#ifdef NATIVE_HEAP_API /* Defined in the NativeHeapApi */
+
+ #include <stddef.h>
+
/*
* Add overrides for malloc, calloc, and free that use
* the nativeheap api to allocate memory
@@ -84,23 +85,32 @@
* api consistency.
*/
- static inline void* vnmalloc(size_t num, size_t size)
+ static _cp_fn_inline void* vnmalloc(size_t num, size_t size)
{
return heapAlloc(heapGetSharedHeapHandle(), num, size, FALSE);
}
- static inline void* vncalloc(size_t num, size_t size)
+ static _cp_fn_inline void* vncalloc(size_t num, size_t size)
{
return heapAlloc(heapGetSharedHeapHandle(), num, size, TRUE);
}
- static inline void vnfree(void* ptr)
+ static _cp_fn_inline void vnfree(void* ptr)
{
+ #ifdef DEBUG
+
ERRNO result;
result = heapFree(heapGetSharedHeapHandle(), ptr);
- //track failed free results
+ /* track failed free results */
assert(result > 0);
+
+ #else
+
+ heapFree(heapGetSharedHeapHandle(), ptr);
+
+ #endif
+
}
#else
@@ -125,6 +135,6 @@
*/
#define vncalloc(num, size) calloc(num, size)
-#endif // NATIVE_HEAP_API
+#endif /* NATIVE_HEAP_API */
#endif /* !UTIL_H_ */ \ No newline at end of file
diff --git a/lib/Net.Http/src/Core/ConnectionInfo.cs b/lib/Net.Http/src/Core/ConnectionInfo.cs
index 3af2b44..bcc5fe7 100644
--- a/lib/Net.Http/src/Core/ConnectionInfo.cs
+++ b/lib/Net.Http/src/Core/ConnectionInfo.cs
@@ -110,8 +110,9 @@ namespace VNLib.Net.Http
Secure = secure | CrossOrigin,
HttpOnly = httpOnly
};
+
//Set the cookie
- Context.Response.AddCookie(cookie);
+ Context.Response.AddCookie(in cookie);
}
internal ConnectionInfo(HttpContext ctx)
diff --git a/lib/Net.Http/src/Core/HttpCookie.cs b/lib/Net.Http/src/Core/HttpCookie.cs
index e19aaec..b805e3e 100644
--- a/lib/Net.Http/src/Core/HttpCookie.cs
+++ b/lib/Net.Http/src/Core/HttpCookie.cs
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2023 Vaughn Nugent
+* Copyright (c) 2024 Vaughn Nugent
*
* Library: VNLib
* Package: VNLib.Net.Http
@@ -30,44 +30,43 @@ using VNLib.Utils.Extensions;
namespace VNLib.Net.Http.Core
{
- internal sealed class HttpCookie : IStringSerializeable, IEquatable<HttpCookie>
+ internal readonly struct HttpCookie(string name) : IStringSerializeable, IEquatable<HttpCookie>
{
- public string Name { get; }
- public string? Value { get; init; }
- public string? Domain { get; init; }
- public string? Path { get; init; }
- public TimeSpan MaxAge { get; init; }
- public CookieSameSite SameSite { get; init; }
- public bool Secure { get; init; }
- public bool HttpOnly { get; init; }
- public bool IsSession { get; init; }
-
- public HttpCookie(string name) => Name = name;
-
- public string Compile()
- {
- throw new NotImplementedException();
- }
+ public readonly string Name { get; } = name;
+ public readonly string? Value { get; init; }
+ public readonly string? Domain { get; init; }
+ public readonly string? Path { get; init; }
+ public readonly TimeSpan MaxAge { get; init; }
+ public readonly CookieSameSite SameSite { get; init; }
+ public readonly bool Secure { get; init; }
+ public readonly bool HttpOnly { get; init; }
+ public readonly bool IsSession { get; init; }
+
+ public readonly string Compile() => throw new NotImplementedException();
- public void Compile(ref ForwardOnlyWriter<char> writer)
+ public readonly void Compile(ref ForwardOnlyWriter<char> writer)
{
//set the name of the cookie
writer.Append(Name);
writer.Append('=');
+
//set name
writer.Append(Value);
+
//Only set the max age parameter if the cookie is not a session cookie
if (!IsSession)
{
writer.Append("; Max-Age=");
writer.Append((int)MaxAge.TotalSeconds);
}
+
//Make sure domain is set
if (!string.IsNullOrWhiteSpace(Domain))
{
writer.Append("; Domain=");
writer.Append(Domain);
}
+
//Check and set path
if (!string.IsNullOrWhiteSpace(Path))
{
@@ -75,7 +74,9 @@ namespace VNLib.Net.Http.Core
writer.Append("; Path=");
writer.Append(Path);
}
+
writer.Append("; SameSite=");
+
//Set the samesite flag based on the enum value
switch (SameSite)
{
@@ -90,28 +91,31 @@ namespace VNLib.Net.Http.Core
writer.Append("Lax");
break;
}
+
//Set httponly flag
if (HttpOnly)
{
writer.Append("; HttpOnly");
}
+
//Set secure flag
if (Secure)
{
writer.Append("; Secure");
}
}
- public ERRNO Compile(Span<char> buffer)
+
+ public readonly ERRNO Compile(Span<char> buffer)
{
ForwardOnlyWriter<char> writer = new(buffer);
Compile(ref writer);
return writer.Written;
}
- public override int GetHashCode() => Name.GetHashCode();
+ public readonly override int GetHashCode() => string.GetHashCode(Name, StringComparison.OrdinalIgnoreCase);
- public override bool Equals(object? obj) => obj is HttpCookie other && Equals(other);
+ public readonly override bool Equals(object? obj) => obj is HttpCookie other && Equals(other);
- public bool Equals(HttpCookie? other) => other != null && Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase);
+ public readonly bool Equals(HttpCookie other) => Name.Equals(other.Name, StringComparison.OrdinalIgnoreCase);
}
} \ No newline at end of file
diff --git a/lib/Net.Http/src/Core/Response/HttpResponse.cs b/lib/Net.Http/src/Core/Response/HttpResponse.cs
index 06f114c..1340dac 100644
--- a/lib/Net.Http/src/Core/Response/HttpResponse.cs
+++ b/lib/Net.Http/src/Core/Response/HttpResponse.cs
@@ -44,7 +44,9 @@ namespace VNLib.Net.Http.Core.Response
, IStringSerializeable
#endif
{
- private readonly HashSet<HttpCookie> Cookies = [];
+ const int DefaultCookieCapacity = 2;
+
+ private readonly Dictionary<string, HttpCookie> Cookies = new(DefaultCookieCapacity, StringComparer.OrdinalIgnoreCase);
private readonly DirectStream ReusableDirectStream = new();
private readonly ChunkedStream ReusableChunkedStream = new(manager.ChunkAccumulatorBuffer, ContextInfo);
private readonly HeaderDataAccumulator Writer = new(manager.ResponseHeaderBuffer, ContextInfo);
@@ -86,7 +88,7 @@ namespace VNLib.Net.Http.Core.Response
/// </summary>
/// <param name="cookie">Cookie to add</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- internal void AddCookie(HttpCookie cookie) => Cookies.Add(cookie);
+ internal void AddCookie(in HttpCookie cookie) => Cookies[cookie.Name] = cookie;
/// <summary>
/// Compiles and flushes all headers to the header accumulator ready for sending
@@ -132,7 +134,7 @@ namespace VNLib.Net.Http.Core.Response
//Write cookies if any are set
if (Cookies.Count > 0)
{
- foreach (HttpCookie cookie in Cookies)
+ foreach (HttpCookie cookie in Cookies.Values)
{
writer.Append("Set-Cookie: ");
@@ -298,6 +300,7 @@ namespace VNLib.Net.Http.Core.Response
{
ReusableChunkedStream.OnRelease();
ReusableDirectStream.OnRelease();
+ Cookies.TrimExcess(DefaultCookieCapacity);
}
///<inheritdoc/>
@@ -428,7 +431,7 @@ namespace VNLib.Net.Http.Core.Response
}
//Enumerate and write
- foreach (HttpCookie cookie in Cookies)
+ foreach (HttpCookie cookie in Cookies.Values)
{
writer.Append("Set-Cookie: ");
diff --git a/lib/Net.Http/src/Helpers/HttpHelpers.cs b/lib/Net.Http/src/Helpers/HttpHelpers.cs
index 86511a5..86616f8 100644
--- a/lib/Net.Http/src/Helpers/HttpHelpers.cs
+++ b/lib/Net.Http/src/Helpers/HttpHelpers.cs
@@ -172,7 +172,7 @@ namespace VNLib.Net.Http
return ComputeCodeHashLookup(
Enum.GetValues<HttpMethod>()
//Exclude the not supported method
- .Except(new HttpMethod[] { HttpMethod.None })
+ .Except([ HttpMethod.None ])
.Select(m => KeyValuePair.Create(m.ToString(), m))
).ToFrozenDictionary();
}
@@ -284,6 +284,9 @@ namespace VNLib.Net.Http
/// <returns>True if first 2 bytes of each address match (Big Endian)</returns>
public static bool IsLocalSubnet(this IPAddress first, IPAddress other)
{
+ ArgumentNullException.ThrowIfNull(first);
+ ArgumentNullException.ThrowIfNull(other);
+
if(first.AddressFamily != other.AddressFamily)
{
return false;
diff --git a/lib/Plugins.Essentials.ServiceStack/src/Construction/SsBuilderExtensions.cs b/lib/Plugins.Essentials.ServiceStack/src/Construction/SsBuilderExtensions.cs
index 5512e49..4195553 100644
--- a/lib/Plugins.Essentials.ServiceStack/src/Construction/SsBuilderExtensions.cs
+++ b/lib/Plugins.Essentials.ServiceStack/src/Construction/SsBuilderExtensions.cs
@@ -285,7 +285,8 @@ namespace VNLib.Plugins.Essentials.ServiceStack.Construction
Instance.AddServices(plugin.Services);
//Add all exposed middleware to the chain
- plugin.OnPluginServiceEvent<ICollection<IHttpMiddleware>>(p => p.TryForeach(Instance.Options.MiddlewareChain.Add));
+ plugin.OnPluginServiceEvent<IEnumerable<IHttpMiddleware>>(p => p.ForEach(Instance.Options.MiddlewareChain.Add));
+ plugin.OnPluginServiceEvent<IHttpMiddleware[]>(p => p.ForEach(Instance.Options.MiddlewareChain.Add));
}
///<inheritdoc/>
@@ -296,7 +297,8 @@ namespace VNLib.Plugins.Essentials.ServiceStack.Construction
Instance.RemoveServices(plugin.Services);
//Remove all middleware from the chain
- plugin.OnPluginServiceEvent<ICollection<IHttpMiddleware>>(p => p.TryForeach(Instance.Options.MiddlewareChain.Remove));
+ plugin.OnPluginServiceEvent<IEnumerable<IHttpMiddleware>>(p => p.ForEach(Instance.Options.MiddlewareChain.Remove));
+ plugin.OnPluginServiceEvent<IHttpMiddleware[]>(p => p.ForEach(Instance.Options.MiddlewareChain.Remove));
}
}
diff --git a/lib/Plugins.Essentials.ServiceStack/src/PluginStackInitializer.cs b/lib/Plugins.Essentials.ServiceStack/src/PluginStackInitializer.cs
index 5a33425..5f4e6e0 100644
--- a/lib/Plugins.Essentials.ServiceStack/src/PluginStackInitializer.cs
+++ b/lib/Plugins.Essentials.ServiceStack/src/PluginStackInitializer.cs
@@ -273,7 +273,7 @@ namespace VNLib.Plugins.Essentials.ServiceStack
public void Load()
{
Plugin.Load();
- Plugin.GetAllExportedServices(Services);
+ Plugin.GetAllExportedServices(_container);
//Finally notify of load
Listener.OnPluginLoaded(this);
diff --git a/lib/Plugins.Essentials/src/Extensions/SingleCookieController.cs b/lib/Plugins.Essentials/src/Extensions/SingleCookieController.cs
index 2d41e4c..f3b02dc 100644
--- a/lib/Plugins.Essentials/src/Extensions/SingleCookieController.cs
+++ b/lib/Plugins.Essentials/src/Extensions/SingleCookieController.cs
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2023 Vaughn Nugent
+* Copyright (c) 2024 Vaughn Nugent
*
* Library: VNLib
* Package: VNLib.Plugins.Essentials
@@ -92,7 +92,7 @@ namespace VNLib.Plugins.Essentials.Extensions
private void SetCookieInternal(IHttpEvent entity, string value, bool force)
{
//Only set cooke if already exists or force is true
- if (entity.Server.RequestCookies.ContainsKey(value) || force)
+ if (entity.Server.RequestCookies.ContainsKey(Name) || force)
{
//Build and set cookie
HttpCookie cookie = new(Name, value)
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
diff --git a/lib/Utils/tests/VNLib.UtilsTests.csproj b/lib/Utils/tests/VNLib.UtilsTests.csproj
index 9a8891e..83013ff 100644
--- a/lib/Utils/tests/VNLib.UtilsTests.csproj
+++ b/lib/Utils/tests/VNLib.UtilsTests.csproj
@@ -17,9 +17,9 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
- <PackageReference Include="MSTest.TestAdapter" Version="3.2.2" />
- <PackageReference Include="MSTest.TestFramework" Version="3.2.2" />
- <PackageReference Include="coverlet.collector" Version="6.0.1">
+ <PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
+ <PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
+ <PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>