diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Net.Compression/third-party/readme.md | 3 | ||||
-rw-r--r-- | lib/Net.Compression/vnlib_compress/CMakeLists.txt | 54 | ||||
-rw-r--r-- | lib/Net.Compression/vnlib_compress/Taskfile.yaml | 47 | ||||
-rw-r--r-- | lib/Net.Compression/vnlib_compress/compression.c | 19 | ||||
-rw-r--r-- | lib/Net.Compression/vnlib_compress/compression.h | 53 | ||||
-rw-r--r-- | lib/Net.Compression/vnlib_compress/feature_brotli.c | 3 | ||||
-rw-r--r-- | lib/Net.Compression/vnlib_compress/feature_zlib.c | 6 | ||||
-rw-r--r-- | lib/Net.Compression/vnlib_compress/util.h | 56 | ||||
-rw-r--r-- | lib/Net.Compression/vnlib_compress/vnlib_compress.vcxitems | 1 |
9 files changed, 153 insertions, 89 deletions
diff --git a/lib/Net.Compression/third-party/readme.md b/lib/Net.Compression/third-party/readme.md deleted file mode 100644 index f10eb0e..0000000 --- a/lib/Net.Compression/third-party/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# Third party - -This directory should contain the required third party libraries. Their should be a directory called `zlib` which includes the zlib source files, and a directory called `brotli` which includes the brotli source files. See the [readme](../readme.md) for more information diff --git a/lib/Net.Compression/vnlib_compress/CMakeLists.txt b/lib/Net.Compression/vnlib_compress/CMakeLists.txt index 977b9a1..f963c41 100644 --- a/lib/Net.Compression/vnlib_compress/CMakeLists.txt +++ b/lib/Net.Compression/vnlib_compress/CMakeLists.txt @@ -13,6 +13,8 @@ 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) +set(THIRD_PARTY_DIR ./third-party) + #add feature specific source files to the project if(ENABLE_BROTLI) list(APPEND VNLIB_COMPRESS_SOURCES feature_brotli.c) @@ -157,13 +159,13 @@ if(ENABLE_BROTLI) endif() #add the include directory for brotli so we can include the header files - include_directories(../third-party/brotli/c/include) + include_directories(${THIRD_PARTY_DIR}/brotli/c/include) #get common sources - file(GLOB BROTLI_SOURCES ../third-party/brotli/c/common/*.c) + 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/brotli/c/enc/*.c) + 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}) @@ -179,18 +181,18 @@ endif() if(ENABLE_ZLIB) #add the include directory for zlib so we can include the header files - include_directories(../third-party/zlib) + 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/zlib/deflate.c - ../third-party/zlib/adler32.c - ../third-party/zlib/crc32.c - ../third-party/zlib/zutil.c - ../third-party/zlib/trees.c + ${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 ) check_type_size(off64_t OFF64_T) @@ -214,11 +216,21 @@ if(ENABLE_ZLIB) -D_CRT_NONSTDC_NO_DEPRECATE ) - #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) + + #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 @@ -239,9 +251,9 @@ if(ENABLE_ZLIB) if(ARM_CRC) list(APPEND Z_C_FLAGS -march=armv8-a+crc) - if(EXISTS "../third-party/zlib/adler32_simd.c") + if(EXISTS "{THIRD_PARTY_DIR}/zlib/adler32_simd.c") list(APPEND ZLIB_DEFINITIONS -DADLER32_SIMD_NEON) - list(APPEND ZLIB_SOURCES ../third-party/zlib/adler32_simd.c) + list(APPEND ZLIB_SOURCES ${THIRD_PARTY_DIR}/zlib/adler32_simd.c) endif() else() @@ -254,9 +266,9 @@ if(ENABLE_ZLIB) list(APPEND Z_C_FLAGS -mssse3) #add cloudflare intrinsic optimizations, may not be present if using non-cloudflare fork - if(EXISTS "../third-party/zlib/adler32_simd.c") + if(EXISTS "${THIRD_PARTY_DIR}/zlib/adler32_simd.c") list(APPEND ZLIB_DEFINITIONS -DHAS_SSSE3 -DADLER32_SIMD_SSSE3) - list(APPEND ZLIB_SOURCES ../third-party/zlib/adler32_simd.c) + list(APPEND ZLIB_SOURCES ${THIRD_PARTY_DIR}/zlib/adler32_simd.c) endif() endif() @@ -268,9 +280,9 @@ if(ENABLE_ZLIB) 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/zlib/crc32_simd.c") + if(EXISTS "${THIRD_PARTY_DIR}/zlib/crc32_simd.c") list(APPEND ZLIB_DEFINITIONS -DHAS_PCLMUL) - list(APPEND ZLIB_SOURCES ../third-party/zlib/crc32_simd.c) + list(APPEND ZLIB_SOURCES ${THIRD_PARTY_DIR}/zlib/crc32_simd.c) endif() endif() @@ -344,7 +356,7 @@ if(ENABLE_RPMALLOC) #find the rpmalloc library for unix builds find_library(VNLIB_RPMALLOC_LIB - NAMES _vnrpmalloc + NAMES libvn_rpmalloc PATHS ../../Utils.Memory/vnlib_rpmalloc/build ) diff --git a/lib/Net.Compression/vnlib_compress/Taskfile.yaml b/lib/Net.Compression/vnlib_compress/Taskfile.yaml index 28b3ff0..fd22c22 100644 --- a/lib/Net.Compression/vnlib_compress/Taskfile.yaml +++ b/lib/Net.Compression/vnlib_compress/Taskfile.yaml @@ -9,8 +9,10 @@ version: '3' vars: - THIRD_PARTY_DIR: '../third-party' + 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: @@ -35,26 +37,59 @@ tasks: #build for platform - 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 + + #invoke cmake for build (notify that we are precompiling for ci pipeline and rpmalloc lib should be local) + - cmake -B./build -DCI_PRECOMPILE=ON -DENABLE_RPMALLOC=ON + + #build for platform + - cmake --build build/ --config Debug + - cmake --build build/ --config Release #when build succeeds, archive the output into a tgz postbuild_success: + vars: + #required files to include in tar + TAR_FILES: "{{.PROJECT_NAME}}.dll {{.PROJECT_NAME}}.pdb {{.PROJECT_NAME}}.lib license.txt" cmds: - cmd: powershell mkdir -Force './bin' #copy source code to target - - powershell -Command "tar --exclude build/* --exclude .vs/* --exclude bin/* -czf bin/src.tgz ." + - cmd: powershell -Command "tar --exclude build/* --exclude .vs/* --exclude bin/* --exclude third-party/* -czf bin/src.tgz ." + + #copy license file to debug and release output + - cmd: powershell -Command "cp ../LICENSE build/Debug/license.txt" + - cmd: powershell -Command "cp ../LICENSE build/Release/license.txt" + + #create static-build archives + - cd build/Debug && tar -czf ../../bin/win-x64-debug.tgz {{.TAR_FILES}} + - cd build/Release && tar -czf ../../bin/win-x64-release.tgz {{.TAR_FILES}} #Remove the output dirs on clean clean: ignore_error: true cmds: - - cmd: powershell Remove-Item -Recurse './bin' + - for: [ bin/, build/, third-party/ ] + 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 https://github.com/cloudflare/zlib.git + - cd {{.THIRD_PARTY_DIR}} && git clone {{.ZLIB_GIT_REPO}} cmds: - cd {{.THIRD_PARTY_DIR}}/zlib && git pull @@ -62,7 +97,7 @@ tasks: brotli: internal: true status: - - cd {{.THIRD_PARTY_DIR}} && git clone https://github.com/google/brotli.git + - cd {{.THIRD_PARTY_DIR}} && git clone {{.BROTLI_GIT_REPO}} cmds: - cd {{.THIRD_PARTY_DIR}}/brotli && git pull
\ No newline at end of file diff --git a/lib/Net.Compression/vnlib_compress/compression.c b/lib/Net.Compression/vnlib_compress/compression.c index a414609..bf3ffbe 100644 --- a/lib/Net.Compression/vnlib_compress/compression.c +++ b/lib/Net.Compression/vnlib_compress/compression.c @@ -29,7 +29,10 @@ * this is a good compromise. */ +#define VNLIB_COMPRESS_EXPORTING 1 + #include "compression.h" +#include "util.h" #ifdef VNLIB_COMPRESSOR_BROTLI_ENABLED #include "feature_brotli.h" @@ -44,7 +47,7 @@ Gets the supported compressors, this is defined at compile time and is a convenience method for the user to know what compressors are supported at runtime. */ -VNLIB_EXPORT CompressorType VNLIB_CC GetSupportedCompressors(void) +VNLIB_COMPRESS_EXPORT CompressorType VNLIB_COMPRESS_CC GetSupportedCompressors(void) { /* * Supported compressors are defined at compile time @@ -69,7 +72,7 @@ VNLIB_EXPORT CompressorType VNLIB_CC GetSupportedCompressors(void) return supported; } -VNLIB_EXPORT CompressorType VNLIB_CC GetCompressorType(_In_ const void* compressor) +VNLIB_COMPRESS_EXPORT CompressorType VNLIB_COMPRESS_CC GetCompressorType(_In_ const void* compressor) { if (!compressor) { @@ -79,7 +82,7 @@ VNLIB_EXPORT CompressorType VNLIB_CC GetCompressorType(_In_ const void* compress return ((CompressorState*)compressor)->type; } -VNLIB_EXPORT CompressionLevel VNLIB_CC GetCompressorLevel(_In_ const void* compressor) +VNLIB_COMPRESS_EXPORT CompressionLevel VNLIB_COMPRESS_CC GetCompressorLevel(_In_ const void* compressor) { if (!compressor) { @@ -89,7 +92,7 @@ VNLIB_EXPORT CompressionLevel VNLIB_CC GetCompressorLevel(_In_ const void* compr return ((CompressorState*)compressor)->level; } -VNLIB_EXPORT int64_t VNLIB_CC GetCompressorBlockSize(_In_ const void* compressor) +VNLIB_COMPRESS_EXPORT int64_t VNLIB_COMPRESS_CC GetCompressorBlockSize(_In_ const void* compressor) { if (!compressor) { @@ -99,7 +102,7 @@ VNLIB_EXPORT int64_t VNLIB_CC GetCompressorBlockSize(_In_ const void* compressor return (int64_t)((CompressorState*)compressor)->blockSize; } -VNLIB_EXPORT void* VNLIB_CC AllocateCompressor(CompressorType type, CompressionLevel level) +VNLIB_COMPRESS_EXPORT void* VNLIB_COMPRESS_CC AllocateCompressor(CompressorType type, CompressionLevel level) { int result; CompressorState* state; @@ -191,7 +194,7 @@ VNLIB_EXPORT void* VNLIB_CC AllocateCompressor(CompressorType type, CompressionL } } -VNLIB_EXPORT int VNLIB_CC FreeCompressor(_In_ void* compressor) +VNLIB_COMPRESS_EXPORT int VNLIB_COMPRESS_CC FreeCompressor(_In_ void* compressor) { CompressorState* comp; int errorCode; @@ -244,7 +247,7 @@ VNLIB_EXPORT int VNLIB_CC FreeCompressor(_In_ void* compressor) return errorCode; } -VNLIB_EXPORT int64_t VNLIB_CC GetCompressedSize(_In_ const void* compressor, uint64_t inputLength, int32_t flush) +VNLIB_COMPRESS_EXPORT int64_t VNLIB_COMPRESS_CC GetCompressedSize(_In_ const void* compressor, uint64_t inputLength, int32_t flush) { CompressorState* comp; int64_t result; @@ -299,7 +302,7 @@ VNLIB_EXPORT int64_t VNLIB_CC GetCompressedSize(_In_ const void* compressor, uin * indicate failure. * @param compressor */ -VNLIB_EXPORT int VNLIB_CC CompressBlock(_In_ const void* compressor, CompressionOperation* operation) +VNLIB_COMPRESS_EXPORT int VNLIB_COMPRESS_CC CompressBlock(_In_ const void* compressor, CompressionOperation* operation) { int result; CompressorState* comp; diff --git a/lib/Net.Compression/vnlib_compress/compression.h b/lib/Net.Compression/vnlib_compress/compression.h index ae3bb8f..0524a01 100644 --- a/lib/Net.Compression/vnlib_compress/compression.h +++ b/lib/Net.Compression/vnlib_compress/compression.h @@ -38,9 +38,44 @@ #ifndef COMPRESSION_H_ #define COMPRESSION_H_ -#include "util.h" #include <stdint.h> +#if defined(_MSC_VER) || defined(WIN32) || defined(_WIN32) + #define _IS_WINDOWS +#endif + +//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 + #define VNLIB_COMPRESS_CC __stdcall + #else + #define VNLIB_COMPRESS_CC + #endif +#endif // !VNLIB_CC + +#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 + #else + #ifdef _IS_WINDOWS + #define VNLIB_COMPRESS_EXPORT __declspec(dllimport) + #else + #define VNLIB_COMPRESS_EXPORT + #endif // IS_WINDOWS + #endif // !VNLIB_EXPORTING +#endif // !VNLIB_EXPORT + +/* +* ERRORS AND CONSTANTS +*/ +#define ERR_INVALID_PTR -1 +#define ERR_OUT_OF_MEMORY -2 + #define ERR_COMP_TYPE_NOT_SUPPORTED -9 #define ERR_COMP_LEVEL_NOT_SUPPORTED -10 #define ERR_INVALID_INPUT_DATA -11 @@ -157,7 +192,7 @@ typedef struct CompressionOperationStruct { /* * Public API functions */ -VNLIB_EXPORT CompressorType VNLIB_CC GetSupportedCompressors(void); +VNLIB_COMPRESS_EXPORT CompressorType VNLIB_COMPRESS_CC GetSupportedCompressors(void); /* * Returns the suggested block size for the underlying compressor. @@ -165,7 +200,7 @@ VNLIB_EXPORT CompressorType VNLIB_CC GetSupportedCompressors(void); * @param compressor A pointer to the desired compressor instance to query. * @return The suggested block size for the underlying compressor in bytes */ -VNLIB_EXPORT int64_t VNLIB_CC GetCompressorBlockSize(_In_ const void* compressor); +VNLIB_COMPRESS_EXPORT int64_t VNLIB_COMPRESS_CC GetCompressorBlockSize(_In_ const void* compressor); /* * Gets the compressor type of the specified compressor instance. @@ -173,7 +208,7 @@ VNLIB_EXPORT int64_t VNLIB_CC GetCompressorBlockSize(_In_ const void* compressor * @param compressor A pointer to the desired compressor instance to query. * @return The type of the specified compressor instance. */ -VNLIB_EXPORT CompressorType VNLIB_CC GetCompressorType(_In_ const void* compressor); +VNLIB_COMPRESS_EXPORT CompressorType VNLIB_COMPRESS_CC GetCompressorType(_In_ const void* compressor); /* * Gets the compression level of the specified compressor instance. @@ -181,7 +216,7 @@ VNLIB_EXPORT CompressorType VNLIB_CC GetCompressorType(_In_ const void* compress * @param compressor A pointer to the desired compressor instance to query. * @return The compression level of the specified compressor instance. */ -VNLIB_EXPORT CompressionLevel VNLIB_CC GetCompressorLevel(_In_ const void* compressor); +VNLIB_COMPRESS_EXPORT CompressionLevel VNLIB_COMPRESS_CC GetCompressorLevel(_In_ const void* compressor); /* * Allocates a new compressor instance on the native heap of the desired compressor type. @@ -191,7 +226,7 @@ VNLIB_EXPORT CompressionLevel VNLIB_CC GetCompressorLevel(_In_ const void* compr * @return A pointer to the newly allocated compressor instance. NULL if the compressor could not be allocated. */ -VNLIB_EXPORT void* VNLIB_CC AllocateCompressor(CompressorType type, CompressionLevel level); +VNLIB_COMPRESS_EXPORT void* VNLIB_COMPRESS_CC AllocateCompressor(CompressorType type, CompressionLevel level); /* * Frees a previously allocated compressor instance. @@ -199,7 +234,7 @@ VNLIB_EXPORT void* VNLIB_CC AllocateCompressor(CompressorType type, CompressionL * @param compressor A pointer to the desired compressor instance to free. * @return The underlying compressor's native return code. */ -VNLIB_EXPORT int VNLIB_CC FreeCompressor(_In_ void* compressor); +VNLIB_COMPRESS_EXPORT int VNLIB_COMPRESS_CC FreeCompressor(_In_ void* compressor); /* * Computes the maximum compressed size of the specified input data. This is not supported @@ -209,7 +244,7 @@ VNLIB_EXPORT int VNLIB_CC FreeCompressor(_In_ void* compressor); * @param inputLength The length of the input data in bytes. * @return The maximum compressed size of the specified input data in bytes. */ -VNLIB_EXPORT int64_t VNLIB_CC GetCompressedSize(_In_ const void* compressor, uint64_t inputLength, int32_t flush); +VNLIB_COMPRESS_EXPORT int64_t VNLIB_COMPRESS_CC GetCompressedSize(_In_ const void* compressor, uint64_t inputLength, int32_t flush); /* @@ -219,6 +254,6 @@ VNLIB_EXPORT int64_t VNLIB_CC GetCompressedSize(_In_ const void* compressor, uin * @param operation A pointer to the compression operation structure * @return The underlying compressor's native return code */ -VNLIB_EXPORT int VNLIB_CC CompressBlock(_In_ const void* compressor, CompressionOperation* operation); +VNLIB_COMPRESS_EXPORT int VNLIB_COMPRESS_CC CompressBlock(_In_ const void* compressor, CompressionOperation* operation); #endif /* !VNLIB_COMPRESS_MAIN_H_ */
\ No newline at end of file diff --git a/lib/Net.Compression/vnlib_compress/feature_brotli.c b/lib/Net.Compression/vnlib_compress/feature_brotli.c index 924f1af..d5ba141 100644 --- a/lib/Net.Compression/vnlib_compress/feature_brotli.c +++ b/lib/Net.Compression/vnlib_compress/feature_brotli.c @@ -19,8 +19,9 @@ * along with vnlib_compress. If not, see http://www.gnu.org/licenses/. */ -#include "feature_brotli.h" #include <brotli/encode.h> +#include "feature_brotli.h" +#include "util.h" #define validateCompState(state) \ if (!state) return ERR_INVALID_PTR; \ diff --git a/lib/Net.Compression/vnlib_compress/feature_zlib.c b/lib/Net.Compression/vnlib_compress/feature_zlib.c index 9993b43..a07f106 100644 --- a/lib/Net.Compression/vnlib_compress/feature_zlib.c +++ b/lib/Net.Compression/vnlib_compress/feature_zlib.c @@ -22,10 +22,12 @@ /* * Include the stub header and also the zlib header */ -#include "feature_zlib.h" -#include <zlib.h> +#include <zlib.h> +#include "feature_zlib.h" +#include "util.h" + #define validateCompState(state) \ if (!state) return ERR_INVALID_PTR; \ if (!state->compressor) return ERR_GZ_INVALID_STATE; \ diff --git a/lib/Net.Compression/vnlib_compress/util.h b/lib/Net.Compression/vnlib_compress/util.h index 8930da7..34659d8 100644 --- a/lib/Net.Compression/vnlib_compress/util.h +++ b/lib/Net.Compression/vnlib_compress/util.h @@ -24,50 +24,25 @@ #ifndef UTIL_H_ #define UTIL_H_ -#include <stdlib.h> - -/* -* Stub missing types and constants for GCC -*/ - /* * If a custom allocator is enabled, use the native heap api -* header and assume linking is enabled +* header and assume linking is enabled. Heap functions below +* will be enabled when heapapi.h is included. */ #ifdef VNLIB_CUSTOM_MALLOC_ENABLE -#include <NativeHeapApi.h> + #include <NativeHeapApi.h> #endif #if defined(_MSC_VER) || defined(WIN32) || defined(_WIN32) #define IS_WINDOWS #endif -//Set api export calling convention (allow used to override) -#ifndef VNLIB_CC - #ifdef IS_WINDOWS - //STD for importing to other languages such as .NET - #define VNLIB_CC __stdcall - #else - #define VNLIB_CC - #endif -#endif // !VNLIB_CC - -#ifndef VNLIB_EXPORT //Allow users to disable the export/impoty macro if using source code directly - #ifdef VNLIB_EXPORTING - #ifdef IS_WINDOWS - #define VNLIB_EXPORT __declspec(dllexport) - #else - #define VNLIB_EXPORT __attribute__((visibility("default"))) - #endif // IS_WINDOWS - #else - #ifdef IS_WINDOWS - #define VNLIB_EXPORT __declspec(dllimport) - #else - #define VNLIB_EXPORT - #endif // IS_WINDOWS - #endif // !VNLIB_EXPORTING -#endif // !VNLIB_EXPORT - +/* 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 @@ -102,16 +77,14 @@ #define assert(x) {} #endif -/* -* ERRORS AND CONSTANTS -*/ -#define ERR_INVALID_PTR -1 -#define ERR_OUT_OF_MEMORY -2 #ifdef NATIVE_HEAP_API /* Defined in the NativeHeapApi */ /* * Add overrides for malloc, calloc, and free that use * the nativeheap api to allocate memory + * + * Inline fuctions are used to enforce type safety and + * api consistency. */ static inline void* vnmalloc(size_t num, size_t size) @@ -136,6 +109,11 @@ #else /* + * Required for built-in memory api + */ + #include <stdlib.h> + + /* * Stub method for malloc. All calls to vnmalloc should be freed with vnfree. */ #define vnmalloc(num, size) malloc(num * size) diff --git a/lib/Net.Compression/vnlib_compress/vnlib_compress.vcxitems b/lib/Net.Compression/vnlib_compress/vnlib_compress.vcxitems index 0bfdcbf..c9664ca 100644 --- a/lib/Net.Compression/vnlib_compress/vnlib_compress.vcxitems +++ b/lib/Net.Compression/vnlib_compress/vnlib_compress.vcxitems @@ -21,6 +21,7 @@ <ItemGroup> <ClInclude Include="$(MSBuildThisFileDirectory)feature_brotli.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)compression.h" /> + <ClInclude Include="$(MSBuildThisFileDirectory)memory.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)util.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)feature_zlib.h" /> </ItemGroup> |