From 278b58728c5b55b54410aa8c3d948a4626d01fdc Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 16 Nov 2020 18:13:19 +0100 Subject: [PATCH] Wrap lz4 in tracy namespace, etc. --- common/tracy_lz4.cpp | 13 +++++-------- common/tracy_lz4.hpp | 35 +++++++++++++++++++---------------- common/tracy_lz4hc.cpp | 9 +++++++-- common/tracy_lz4hc.hpp | 28 ++++++++++------------------ 4 files changed, 41 insertions(+), 44 deletions(-) diff --git a/common/tracy_lz4.cpp b/common/tracy_lz4.cpp index 9f5e9bfa..951c1d5e 100644 --- a/common/tracy_lz4.cpp +++ b/common/tracy_lz4.cpp @@ -114,7 +114,7 @@ #endif #define LZ4_STATIC_LINKING_ONLY /* LZ4_DISTANCE_MAX */ -#include "lz4.h" +#include "tracy_lz4.hpp" /* see also "memory routines" below */ @@ -303,6 +303,8 @@ typedef enum { fillOutput = 2 } limitedOutput_directive; +namespace tracy +{ /*-************************************ * Reading and writing into memory @@ -678,9 +680,6 @@ int LZ4_sizeofState(void) { return LZ4_STREAMSIZE; } /*-************************************ * Internal Definitions used in Tests **************************************/ -#if defined (__cplusplus) -extern "C" { -#endif int LZ4_compress_forceExtDict (LZ4_stream_t* LZ4_dict, const char* source, char* dest, int srcSize); @@ -688,10 +687,6 @@ int LZ4_decompress_safe_forceExtDict(const char* source, char* dest, int compressedSize, int maxOutputSize, const void* dictStart, size_t dictSize); -#if defined (__cplusplus) -} -#endif - /*-****************************** * Compression functions ********************************/ @@ -2493,3 +2488,5 @@ char* LZ4_slideInputBuffer (void* state) } #endif /* LZ4_COMMONDEFS_ONLY */ + +} diff --git a/common/tracy_lz4.hpp b/common/tracy_lz4.hpp index 7ab1e483..1ccdcff1 100644 --- a/common/tracy_lz4.hpp +++ b/common/tracy_lz4.hpp @@ -32,15 +32,13 @@ - LZ4 homepage : http://www.lz4.org - LZ4 source repository : https://github.com/lz4/lz4 */ -#if defined (__cplusplus) -extern "C" { -#endif -#ifndef LZ4_H_2983827168210 -#define LZ4_H_2983827168210 +#ifndef TRACY_LZ4_H_2983827168210 +#define TRACY_LZ4_H_2983827168210 /* --- Dependency --- */ #include /* size_t */ +#include /** @@ -109,6 +107,9 @@ extern "C" { #define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str) #define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION) +namespace tracy +{ + LZ4LIB_API int LZ4_versionNumber (void); /**< library version number; useful to check dll version */ LZ4LIB_API const char* LZ4_versionString (void); /**< library version string; useful to check dll version */ @@ -419,6 +420,8 @@ LZ4LIB_API int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecod */ LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* src, char* dst, int srcSize, int dstCapcity, const char* dictStart, int dictSize); +} + #endif /* LZ4_H_2983827168210 */ @@ -448,8 +451,8 @@ LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* src, char* dst, int sr #ifdef LZ4_STATIC_LINKING_ONLY -#ifndef LZ4_STATIC_3504398509 -#define LZ4_STATIC_3504398509 +#ifndef TRACY_LZ4_STATIC_3504398509 +#define TRACY_LZ4_STATIC_3504398509 #ifdef LZ4_PUBLISH_STATIC_FUNCTIONS #define LZ4LIB_STATIC_API LZ4LIB_API @@ -457,6 +460,8 @@ LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* src, char* dst, int sr #define LZ4LIB_STATIC_API #endif +namespace tracy +{ /*! LZ4_compress_fast_extState_fastReset() : * A variant of LZ4_compress_fast_extState(). @@ -560,13 +565,16 @@ LZ4LIB_STATIC_API void LZ4_attach_dictionary(LZ4_stream_t* workingStream, const #define LZ4_COMPRESS_INPLACE_MARGIN (LZ4_DISTANCE_MAX + 32) /* LZ4_DISTANCE_MAX can be safely replaced by srcSize when it's smaller */ #define LZ4_COMPRESS_INPLACE_BUFFER_SIZE(maxCompressedSize) ((maxCompressedSize) + LZ4_COMPRESS_INPLACE_MARGIN) /**< maxCompressedSize is generally LZ4_COMPRESSBOUND(inputSize), but can be set to any lower value, with the risk that compression can fail (return code 0(zero)) */ +} + #endif /* LZ4_STATIC_3504398509 */ #endif /* LZ4_STATIC_LINKING_ONLY */ +#ifndef TRACY_LZ4_H_98237428734687 +#define TRACY_LZ4_H_98237428734687 - -#ifndef LZ4_H_98237428734687 -#define LZ4_H_98237428734687 +namespace tracy +{ /*-************************************************************ * Private Definitions @@ -580,7 +588,6 @@ LZ4LIB_STATIC_API void LZ4_attach_dictionary(LZ4_stream_t* workingStream, const #define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG) /* required as macro for static allocation */ #if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) -# include typedef int8_t LZ4_i8; typedef uint8_t LZ4_byte; typedef uint16_t LZ4_u16; @@ -765,10 +772,6 @@ LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int or */ LZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr); +} #endif /* LZ4_H_98237428734687 */ - - -#if defined (__cplusplus) -} -#endif diff --git a/common/tracy_lz4hc.cpp b/common/tracy_lz4hc.cpp index 77c9f430..9c899b82 100644 --- a/common/tracy_lz4hc.cpp +++ b/common/tracy_lz4hc.cpp @@ -50,7 +50,7 @@ /*=== Dependency ===*/ #define LZ4_HC_STATIC_LINKING_ONLY -#include "lz4hc.h" +#include "tracy_lz4hc.hpp" /*=== Common definitions ===*/ @@ -63,7 +63,7 @@ #define LZ4_COMMONDEFS_ONLY #ifndef LZ4_SRC_INCLUDED -#include "lz4.c" /* LZ4_count, constants, mem */ +#include "tracy_lz4.cpp" /* LZ4_count, constants, mem */ #endif @@ -85,6 +85,9 @@ typedef enum { noDictCtx, usingDictCtxHc } dictCtx_directive; /* Make fields passed to, and updated by LZ4HC_encodeSequence explicit */ #define UPDATABLE(ip, op, anchor) &ip, &op, &anchor +namespace tracy +{ + static U32 LZ4HC_hashPtr(const void* ptr) { return HASH_FUNCTION(LZ4_read32(ptr)); } @@ -1613,3 +1616,5 @@ _return_label: #endif return retval; } + +} diff --git a/common/tracy_lz4hc.hpp b/common/tracy_lz4hc.hpp index 3d441fb6..18bf30d4 100644 --- a/common/tracy_lz4hc.hpp +++ b/common/tracy_lz4hc.hpp @@ -31,16 +31,12 @@ - LZ4 source repository : https://github.com/lz4/lz4 - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c */ -#ifndef LZ4_HC_H_19834876238432 -#define LZ4_HC_H_19834876238432 - -#if defined (__cplusplus) -extern "C" { -#endif +#ifndef TRACY_LZ4_HC_H_19834876238432 +#define TRACY_LZ4_HC_H_19834876238432 /* --- Dependency --- */ /* note : lz4hc requires lz4.h/lz4.c for compilation */ -#include "lz4.h" /* stddef, LZ4LIB_API, LZ4_DEPRECATED */ +#include "tracy_lz4.hpp" /* stddef, LZ4LIB_API, LZ4_DEPRECATED */ /* --- Useful constants --- */ @@ -49,6 +45,8 @@ extern "C" { #define LZ4HC_CLEVEL_OPT_MIN 10 #define LZ4HC_CLEVEL_MAX 12 +namespace tracy +{ /*-************************************ * Block Compression @@ -291,10 +289,7 @@ LZ4_DEPRECATED("use LZ4_initStreamHC() instead") LZ4LIB_API int LZ4_resetStre */ LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel); - -#if defined (__cplusplus) } -#endif #endif /* LZ4_HC_H_19834876238432 */ @@ -308,15 +303,14 @@ LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionL * after successfull usage in real-life scenarios. ***************************************************/ #ifdef LZ4_HC_STATIC_LINKING_ONLY /* protection macro */ -#ifndef LZ4_HC_SLO_098092834 -#define LZ4_HC_SLO_098092834 +#ifndef TRACY_LZ4_HC_SLO_098092834 +#define TRACY_LZ4_HC_SLO_098092834 #define LZ4_STATIC_LINKING_ONLY /* LZ4LIB_STATIC_API */ -#include "lz4.h" +#include "tracy_lz4.hpp" -#if defined (__cplusplus) -extern "C" { -#endif +namespace tracy +{ /*! LZ4_setCompressionLevel() : v1.8.0+ (experimental) * It's possible to change compression level @@ -405,9 +399,7 @@ LZ4LIB_STATIC_API void LZ4_attach_HC_dictionary( LZ4_streamHC_t *working_stream, const LZ4_streamHC_t *dictionary_stream); -#if defined (__cplusplus) } -#endif #endif /* LZ4_HC_SLO_098092834 */ #endif /* LZ4_HC_STATIC_LINKING_ONLY */