1333347Speter#include "svn_private_config.h" 2362181Sdim#ifdef SVN_INTERNAL_LZ4 3333347Speter/* 4333347Speter * LZ4 - Fast LZ compression algorithm 5333347Speter * Header File 6333347Speter * Copyright (C) 2011-2016, Yann Collet. 7333347Speter 8333347Speter BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) 9333347Speter 10333347Speter Redistribution and use in source and binary forms, with or without 11333347Speter modification, are permitted provided that the following conditions are 12333347Speter met: 13333347Speter 14333347Speter * Redistributions of source code must retain the above copyright 15333347Speter notice, this list of conditions and the following disclaimer. 16333347Speter * Redistributions in binary form must reproduce the above 17333347Speter copyright notice, this list of conditions and the following disclaimer 18333347Speter in the documentation and/or other materials provided with the 19333347Speter distribution. 20333347Speter 21333347Speter THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22333347Speter "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23333347Speter LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24333347Speter A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25333347Speter OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26333347Speter SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27333347Speter LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28333347Speter DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29333347Speter THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30333347Speter (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31333347Speter OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32333347Speter 33333347Speter You can contact the author at : 34333347Speter - LZ4 homepage : http://www.lz4.org 35333347Speter - LZ4 source repository : https://github.com/lz4/lz4 36333347Speter*/ 37333347Speter#ifndef LZ4_H_2983827168210 38333347Speter#define LZ4_H_2983827168210 39333347Speter 40333347Speter#if defined (__cplusplus) 41333347Speterextern "C" { 42333347Speter#endif 43333347Speter 44333347Speter/* --- Dependency --- */ 45333347Speter#include <stddef.h> /* size_t */ 46333347Speter 47333347Speter 48333347Speter/** 49333347Speter Introduction 50333347Speter 51333347Speter LZ4 is lossless compression algorithm, providing compression speed at 400 MB/s per core, 52333347Speter scalable with multi-cores CPU. It features an extremely fast decoder, with speed in 53333347Speter multiple GB/s per core, typically reaching RAM speed limits on multi-core systems. 54333347Speter 55333347Speter The LZ4 compression library provides in-memory compression and decompression functions. 56333347Speter Compression can be done in: 57333347Speter - a single step (described as Simple Functions) 58333347Speter - a single step, reusing a context (described in Advanced Functions) 59333347Speter - unbounded multiple steps (described as Streaming compression) 60333347Speter 61333347Speter lz4.h provides block compression functions. It gives full buffer control to user. 62333347Speter Decompressing an lz4-compressed block also requires metadata (such as compressed size). 63333347Speter Each application is free to encode such metadata in whichever way it wants. 64333347Speter 65333347Speter An additional format, called LZ4 frame specification (doc/lz4_Frame_format.md), 66333347Speter take care of encoding standard metadata alongside LZ4-compressed blocks. 67333347Speter If your application requires interoperability, it's recommended to use it. 68333347Speter A library is provided to take care of it, see lz4frame.h. 69333347Speter*/ 70333347Speter 71333347Speter/*^*************************************************************** 72333347Speter* Export parameters 73333347Speter*****************************************************************/ 74333347Speter/* 75333347Speter* LZ4_DLL_EXPORT : 76333347Speter* Enable exporting of functions when building a Windows DLL 77333347Speter*/ 78333347Speter#if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1) 79333347Speter# define LZ4LIB_API __declspec(dllexport) 80333347Speter#elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1) 81333347Speter# define LZ4LIB_API __declspec(dllimport) /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ 82333347Speter#else 83333347Speter# define LZ4LIB_API 84333347Speter#endif 85333347Speter 86333347Speter 87333347Speter/*========== Version =========== */ 88333347Speter#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */ 89333347Speter#define LZ4_VERSION_MINOR 7 /* for new (non-breaking) interface capabilities */ 90333347Speter#define LZ4_VERSION_RELEASE 5 /* for tweaks, bug-fixes, or development */ 91333347Speter 92333347Speter#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE) 93333347Speter 94333347Speter#define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE 95333347Speter#define LZ4_QUOTE(str) #str 96333347Speter#define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str) 97333347Speter#define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION) 98333347Speter 99333347SpeterLZ4LIB_API int LZ4_versionNumber (void); 100333347SpeterLZ4LIB_API const char* LZ4_versionString (void); 101333347Speter 102333347Speter 103333347Speter/*-************************************ 104333347Speter* Tuning parameter 105333347Speter**************************************/ 106333347Speter/*! 107333347Speter * LZ4_MEMORY_USAGE : 108333347Speter * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; etc.) 109333347Speter * Increasing memory usage improves compression ratio 110333347Speter * Reduced memory usage can improve speed, due to cache effect 111333347Speter * Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache 112333347Speter */ 113333347Speter#define LZ4_MEMORY_USAGE 14 114333347Speter 115333347Speter 116333347Speter/*-************************************ 117333347Speter* Simple Functions 118333347Speter**************************************/ 119333347Speter/*! LZ4_compress_default() : 120333347Speter Compresses 'sourceSize' bytes from buffer 'source' 121333347Speter into already allocated 'dest' buffer of size 'maxDestSize'. 122333347Speter Compression is guaranteed to succeed if 'maxDestSize' >= LZ4_compressBound(sourceSize). 123333347Speter It also runs faster, so it's a recommended setting. 124333347Speter If the function cannot compress 'source' into a more limited 'dest' budget, 125333347Speter compression stops *immediately*, and the function result is zero. 126333347Speter As a consequence, 'dest' content is not valid. 127333347Speter This function never writes outside 'dest' buffer, nor read outside 'source' buffer. 128333347Speter sourceSize : Max supported value is LZ4_MAX_INPUT_VALUE 129333347Speter maxDestSize : full or partial size of buffer 'dest' (which must be already allocated) 130333347Speter return : the number of bytes written into buffer 'dest' (necessarily <= maxOutputSize) 131333347Speter or 0 if compression fails */ 132333347SpeterLZ4LIB_API int LZ4_compress_default(const char* source, char* dest, int sourceSize, int maxDestSize); 133333347Speter 134333347Speter/*! LZ4_decompress_safe() : 135333347Speter compressedSize : is the precise full size of the compressed block. 136333347Speter maxDecompressedSize : is the size of destination buffer, which must be already allocated. 137333347Speter return : the number of bytes decompressed into destination buffer (necessarily <= maxDecompressedSize) 138333347Speter If destination buffer is not large enough, decoding will stop and output an error code (<0). 139333347Speter If the source stream is detected malformed, the function will stop decoding and return a negative result. 140333347Speter This function is protected against buffer overflow exploits, including malicious data packets. 141333347Speter It never writes outside output buffer, nor reads outside input buffer. 142333347Speter*/ 143333347SpeterLZ4LIB_API int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize); 144333347Speter 145333347Speter 146333347Speter/*-************************************ 147333347Speter* Advanced Functions 148333347Speter**************************************/ 149333347Speter#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */ 150333347Speter#define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16) 151333347Speter 152333347Speter/*! 153333347SpeterLZ4_compressBound() : 154333347Speter Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible) 155333347Speter This function is primarily useful for memory allocation purposes (destination buffer size). 156333347Speter Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example). 157333347Speter Note that LZ4_compress_default() compress faster when dest buffer size is >= LZ4_compressBound(srcSize) 158333347Speter inputSize : max supported value is LZ4_MAX_INPUT_SIZE 159333347Speter return : maximum output size in a "worst case" scenario 160333347Speter or 0, if input size is too large ( > LZ4_MAX_INPUT_SIZE) 161333347Speter*/ 162333347SpeterLZ4LIB_API int LZ4_compressBound(int inputSize); 163333347Speter 164333347Speter/*! 165333347SpeterLZ4_compress_fast() : 166333347Speter Same as LZ4_compress_default(), but allows to select an "acceleration" factor. 167333347Speter The larger the acceleration value, the faster the algorithm, but also the lesser the compression. 168333347Speter It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed. 169333347Speter An acceleration value of "1" is the same as regular LZ4_compress_default() 170333347Speter Values <= 0 will be replaced by ACCELERATION_DEFAULT (see lz4.c), which is 1. 171333347Speter*/ 172333347SpeterLZ4LIB_API int LZ4_compress_fast (const char* source, char* dest, int sourceSize, int maxDestSize, int acceleration); 173333347Speter 174333347Speter 175333347Speter/*! 176333347SpeterLZ4_compress_fast_extState() : 177333347Speter Same compression function, just using an externally allocated memory space to store compression state. 178333347Speter Use LZ4_sizeofState() to know how much memory must be allocated, 179333347Speter and allocate it on 8-bytes boundaries (using malloc() typically). 180333347Speter Then, provide it as 'void* state' to compression function. 181333347Speter*/ 182333347SpeterLZ4LIB_API int LZ4_sizeofState(void); 183333347SpeterLZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* source, char* dest, int inputSize, int maxDestSize, int acceleration); 184333347Speter 185333347Speter 186333347Speter/*! 187333347SpeterLZ4_compress_destSize() : 188333347Speter Reverse the logic, by compressing as much data as possible from 'source' buffer 189333347Speter into already allocated buffer 'dest' of size 'targetDestSize'. 190333347Speter This function either compresses the entire 'source' content into 'dest' if it's large enough, 191333347Speter or fill 'dest' buffer completely with as much data as possible from 'source'. 192333347Speter *sourceSizePtr : will be modified to indicate how many bytes where read from 'source' to fill 'dest'. 193333347Speter New value is necessarily <= old value. 194333347Speter return : Nb bytes written into 'dest' (necessarily <= targetDestSize) 195333347Speter or 0 if compression fails 196333347Speter*/ 197333347SpeterLZ4LIB_API int LZ4_compress_destSize (const char* source, char* dest, int* sourceSizePtr, int targetDestSize); 198333347Speter 199333347Speter 200333347Speter/*! 201333347SpeterLZ4_decompress_fast() : 202333347Speter originalSize : is the original and therefore uncompressed size 203333347Speter return : the number of bytes read from the source buffer (in other words, the compressed size) 204333347Speter If the source stream is detected malformed, the function will stop decoding and return a negative result. 205333347Speter Destination buffer must be already allocated. Its size must be a minimum of 'originalSize' bytes. 206333347Speter note : This function fully respect memory boundaries for properly formed compressed data. 207333347Speter It is a bit faster than LZ4_decompress_safe(). 208333347Speter However, it does not provide any protection against intentionally modified data stream (malicious input). 209333347Speter Use this function in trusted environment only (data to decode comes from a trusted source). 210333347Speter*/ 211333347SpeterLZ4LIB_API int LZ4_decompress_fast (const char* source, char* dest, int originalSize); 212333347Speter 213333347Speter/*! 214333347SpeterLZ4_decompress_safe_partial() : 215333347Speter This function decompress a compressed block of size 'compressedSize' at position 'source' 216333347Speter into destination buffer 'dest' of size 'maxDecompressedSize'. 217333347Speter The function tries to stop decompressing operation as soon as 'targetOutputSize' has been reached, 218333347Speter reducing decompression time. 219333347Speter return : the number of bytes decoded in the destination buffer (necessarily <= maxDecompressedSize) 220333347Speter Note : this number can be < 'targetOutputSize' should the compressed block to decode be smaller. 221333347Speter Always control how many bytes were decoded. 222333347Speter If the source stream is detected malformed, the function will stop decoding and return a negative result. 223333347Speter This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets 224333347Speter*/ 225333347SpeterLZ4LIB_API int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedSize, int targetOutputSize, int maxDecompressedSize); 226333347Speter 227333347Speter 228333347Speter/*-********************************************* 229333347Speter* Streaming Compression Functions 230333347Speter***********************************************/ 231333347Spetertypedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */ 232333347Speter 233333347Speter/*! LZ4_createStream() and LZ4_freeStream() : 234333347Speter * LZ4_createStream() will allocate and initialize an `LZ4_stream_t` structure. 235333347Speter * LZ4_freeStream() releases its memory. 236333347Speter */ 237333347SpeterLZ4LIB_API LZ4_stream_t* LZ4_createStream(void); 238333347SpeterLZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr); 239333347Speter 240333347Speter/*! LZ4_resetStream() : 241333347Speter * An LZ4_stream_t structure can be allocated once and re-used multiple times. 242333347Speter * Use this function to init an allocated `LZ4_stream_t` structure and start a new compression. 243333347Speter */ 244333347SpeterLZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr); 245333347Speter 246333347Speter/*! LZ4_loadDict() : 247333347Speter * Use this function to load a static dictionary into LZ4_stream. 248333347Speter * Any previous data will be forgotten, only 'dictionary' will remain in memory. 249333347Speter * Loading a size of 0 is allowed. 250333347Speter * Return : dictionary size, in bytes (necessarily <= 64 KB) 251333347Speter */ 252333347SpeterLZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize); 253333347Speter 254333347Speter/*! LZ4_compress_fast_continue() : 255333347Speter * Compress buffer content 'src', using data from previously compressed blocks as dictionary to improve compression ratio. 256333347Speter * Important : Previous data blocks are assumed to still be present and unmodified ! 257333347Speter * 'dst' buffer must be already allocated. 258333347Speter * If maxDstSize >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster. 259333347Speter * If not, and if compressed data cannot fit into 'dst' buffer size, compression stops, and function returns a zero. 260333347Speter */ 261333347SpeterLZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int maxDstSize, int acceleration); 262333347Speter 263333347Speter/*! LZ4_saveDict() : 264333347Speter * If previously compressed data block is not guaranteed to remain available at its memory location, 265333347Speter * save it into a safer place (char* safeBuffer). 266333347Speter * Note : you don't need to call LZ4_loadDict() afterwards, 267333347Speter * dictionary is immediately usable, you can therefore call LZ4_compress_fast_continue(). 268333347Speter * Return : saved dictionary size in bytes (necessarily <= dictSize), or 0 if error. 269333347Speter */ 270333347SpeterLZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int dictSize); 271333347Speter 272333347Speter 273333347Speter/*-********************************************** 274333347Speter* Streaming Decompression Functions 275333347Speter* Bufferless synchronous API 276333347Speter************************************************/ 277333347Spetertypedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* incomplete type (defined later) */ 278333347Speter 279333347Speter/* creation / destruction of streaming decompression tracking structure */ 280333347SpeterLZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void); 281333347SpeterLZ4LIB_API int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream); 282333347Speter 283333347Speter/*! LZ4_setStreamDecode() : 284333347Speter * Use this function to instruct where to find the dictionary. 285333347Speter * Setting a size of 0 is allowed (same effect as reset). 286333347Speter * @return : 1 if OK, 0 if error 287333347Speter */ 288333347SpeterLZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize); 289333347Speter 290333347Speter/*! 291333347SpeterLZ4_decompress_*_continue() : 292333347Speter These decoding functions allow decompression of multiple blocks in "streaming" mode. 293333347Speter Previously decoded blocks *must* remain available at the memory position where they were decoded (up to 64 KB) 294333347Speter In the case of a ring buffers, decoding buffer must be either : 295333347Speter - Exactly same size as encoding buffer, with same update rule (block boundaries at same positions) 296333347Speter In which case, the decoding & encoding ring buffer can have any size, including very small ones ( < 64 KB). 297333347Speter - Larger than encoding buffer, by a minimum of maxBlockSize more bytes. 298333347Speter maxBlockSize is implementation dependent. It's the maximum size you intend to compress into a single block. 299333347Speter In which case, encoding and decoding buffers do not need to be synchronized, 300333347Speter and encoding ring buffer can have any size, including small ones ( < 64 KB). 301333347Speter - _At least_ 64 KB + 8 bytes + maxBlockSize. 302333347Speter In which case, encoding and decoding buffers do not need to be synchronized, 303333347Speter and encoding ring buffer can have any size, including larger than decoding buffer. 304333347Speter Whenever these conditions are not possible, save the last 64KB of decoded data into a safe buffer, 305333347Speter and indicate where it is saved using LZ4_setStreamDecode() 306333347Speter*/ 307333347SpeterLZ4LIB_API int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxDecompressedSize); 308333347SpeterLZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize); 309333347Speter 310333347Speter 311333347Speter/*! LZ4_decompress_*_usingDict() : 312333347Speter * These decoding functions work the same as 313333347Speter * a combination of LZ4_setStreamDecode() followed by LZ4_decompress_*_continue() 314333347Speter * They are stand-alone, and don't need an LZ4_streamDecode_t structure. 315333347Speter */ 316333347SpeterLZ4LIB_API int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxDecompressedSize, const char* dictStart, int dictSize); 317333347SpeterLZ4LIB_API int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize); 318333347Speter 319333347Speter 320333347Speter/*^********************************************** 321333347Speter * !!!!!! STATIC LINKING ONLY !!!!!! 322333347Speter ***********************************************/ 323333347Speter/*-************************************ 324333347Speter * Private definitions 325333347Speter ************************************** 326333347Speter * Do not use these definitions. 327333347Speter * They are exposed to allow static allocation of `LZ4_stream_t` and `LZ4_streamDecode_t`. 328333347Speter * Using these definitions will expose code to API and/or ABI break in future versions of the library. 329333347Speter **************************************/ 330333347Speter#define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2) 331333347Speter#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE) 332333347Speter#define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG) /* required as macro for static allocation */ 333333347Speter 334333347Speter#if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) 335333347Speter#include <stdint.h> 336333347Speter 337333347Spetertypedef struct { 338333347Speter uint32_t hashTable[LZ4_HASH_SIZE_U32]; 339333347Speter uint32_t currentOffset; 340333347Speter uint32_t initCheck; 341333347Speter const uint8_t* dictionary; 342333347Speter uint8_t* bufferStart; /* obsolete, used for slideInputBuffer */ 343333347Speter uint32_t dictSize; 344333347Speter} LZ4_stream_t_internal; 345333347Speter 346333347Spetertypedef struct { 347333347Speter const uint8_t* externalDict; 348333347Speter size_t extDictSize; 349333347Speter const uint8_t* prefixEnd; 350333347Speter size_t prefixSize; 351333347Speter} LZ4_streamDecode_t_internal; 352333347Speter 353333347Speter#else 354333347Speter 355333347Spetertypedef struct { 356333347Speter unsigned int hashTable[LZ4_HASH_SIZE_U32]; 357333347Speter unsigned int currentOffset; 358333347Speter unsigned int initCheck; 359333347Speter const unsigned char* dictionary; 360333347Speter unsigned char* bufferStart; /* obsolete, used for slideInputBuffer */ 361333347Speter unsigned int dictSize; 362333347Speter} LZ4_stream_t_internal; 363333347Speter 364333347Spetertypedef struct { 365333347Speter const unsigned char* externalDict; 366333347Speter size_t extDictSize; 367333347Speter const unsigned char* prefixEnd; 368333347Speter size_t prefixSize; 369333347Speter} LZ4_streamDecode_t_internal; 370333347Speter 371333347Speter#endif 372333347Speter 373333347Speter/*! 374333347Speter * LZ4_stream_t : 375333347Speter * information structure to track an LZ4 stream. 376333347Speter * init this structure before first use. 377333347Speter * note : only use in association with static linking ! 378333347Speter * this definition is not API/ABI safe, 379333347Speter * and may change in a future version ! 380333347Speter */ 381333347Speter#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4) 382333347Speter#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(unsigned long long)) 383333347Speterunion LZ4_stream_u { 384333347Speter unsigned long long table[LZ4_STREAMSIZE_U64]; 385333347Speter LZ4_stream_t_internal internal_donotuse; 386333347Speter} ; /* previously typedef'd to LZ4_stream_t */ 387333347Speter 388333347Speter 389333347Speter/*! 390333347Speter * LZ4_streamDecode_t : 391333347Speter * information structure to track an LZ4 stream during decompression. 392333347Speter * init this structure using LZ4_setStreamDecode (or memset()) before first use 393333347Speter * note : only use in association with static linking ! 394333347Speter * this definition is not API/ABI safe, 395333347Speter * and may change in a future version ! 396333347Speter */ 397333347Speter#define LZ4_STREAMDECODESIZE_U64 4 398333347Speter#define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long)) 399333347Speterunion LZ4_streamDecode_u { 400333347Speter unsigned long long table[LZ4_STREAMDECODESIZE_U64]; 401333347Speter LZ4_streamDecode_t_internal internal_donotuse; 402333347Speter} ; /* previously typedef'd to LZ4_streamDecode_t */ 403333347Speter 404333347Speter 405333347Speter/*=************************************ 406333347Speter* Obsolete Functions 407333347Speter**************************************/ 408333347Speter/* Deprecation warnings */ 409333347Speter/* Should these warnings be a problem, 410333347Speter it is generally possible to disable them, 411333347Speter typically with -Wno-deprecated-declarations for gcc 412333347Speter or _CRT_SECURE_NO_WARNINGS in Visual. 413333347Speter Otherwise, it's also possible to define LZ4_DISABLE_DEPRECATE_WARNINGS */ 414333347Speter#ifdef LZ4_DISABLE_DEPRECATE_WARNINGS 415333347Speter# define LZ4_DEPRECATED(message) /* disable deprecation warnings */ 416333347Speter#else 417333347Speter# define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) 418333347Speter# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */ 419333347Speter# define LZ4_DEPRECATED(message) [[deprecated(message)]] 420333347Speter# elif (LZ4_GCC_VERSION >= 405) || defined(__clang__) 421333347Speter# define LZ4_DEPRECATED(message) __attribute__((deprecated(message))) 422333347Speter# elif (LZ4_GCC_VERSION >= 301) 423333347Speter# define LZ4_DEPRECATED(message) __attribute__((deprecated)) 424333347Speter# elif defined(_MSC_VER) 425333347Speter# define LZ4_DEPRECATED(message) __declspec(deprecated(message)) 426333347Speter# else 427333347Speter# pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler") 428333347Speter# define LZ4_DEPRECATED(message) 429333347Speter# endif 430333347Speter#endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */ 431333347Speter 432333347Speter/* Obsolete compression functions */ 433333347SpeterLZ4_DEPRECATED("use LZ4_compress_default() instead") int LZ4_compress (const char* source, char* dest, int sourceSize); 434333347SpeterLZ4_DEPRECATED("use LZ4_compress_default() instead") int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize); 435333347SpeterLZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize); 436333347SpeterLZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); 437333347SpeterLZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize); 438333347SpeterLZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize); 439333347Speter 440333347Speter/* Obsolete decompression functions */ 441333347Speter/* These function names are completely deprecated and must no longer be used. 442333347Speter They are only provided in lz4.c for compatibility with older programs. 443333347Speter - LZ4_uncompress is the same as LZ4_decompress_fast 444333347Speter - LZ4_uncompress_unknownOutputSize is the same as LZ4_decompress_safe 445333347Speter These function prototypes are now disabled; uncomment them only if you really need them. 446333347Speter It is highly recommended to stop using these prototypes and migrate to maintained ones */ 447333347Speter/* int LZ4_uncompress (const char* source, char* dest, int outputSize); */ 448333347Speter/* int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize); */ 449333347Speter 450333347Speter/* Obsolete streaming functions; use new streaming interface whenever possible */ 451333347SpeterLZ4_DEPRECATED("use LZ4_createStream() instead") void* LZ4_create (char* inputBuffer); 452333347SpeterLZ4_DEPRECATED("use LZ4_createStream() instead") int LZ4_sizeofStreamState(void); 453333347SpeterLZ4_DEPRECATED("use LZ4_resetStream() instead") int LZ4_resetStreamState(void* state, char* inputBuffer); 454333347SpeterLZ4_DEPRECATED("use LZ4_saveDict() instead") char* LZ4_slideInputBuffer (void* state); 455333347Speter 456333347Speter/* Obsolete streaming decoding functions */ 457333347SpeterLZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize); 458333347SpeterLZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize); 459333347Speter 460333347Speter 461333347Speter#if defined (__cplusplus) 462333347Speter} 463333347Speter#endif 464333347Speter 465333347Speter#endif /* LZ4_H_2983827168210 */ 466333347Speter#endif /* SVN_INTERNAL_LZ4 */ 467