benchmark silo added
[c11concurrency-benchmarks.git] / silo / third-party / lz4 / lz4hc.h
1 /*\r
2    LZ4 HC - High Compression Mode of LZ4\r
3    Header File\r
4    Copyright (C) 2011-2013, Yann Collet.\r
5    BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)\r
6 \r
7    Redistribution and use in source and binary forms, with or without\r
8    modification, are permitted provided that the following conditions are\r
9    met:\r
10 \r
11        * Redistributions of source code must retain the above copyright\r
12    notice, this list of conditions and the following disclaimer.\r
13        * Redistributions in binary form must reproduce the above\r
14    copyright notice, this list of conditions and the following disclaimer\r
15    in the documentation and/or other materials provided with the\r
16    distribution.\r
17 \r
18    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
19    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
20    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
21    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
22    OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
23    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
24    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
25    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
26    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
27    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
28    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
29 \r
30    You can contact the author at :\r
31    - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html\r
32    - LZ4 source repository : http://code.google.com/p/lz4/\r
33 */\r
34 #pragma once\r
35 \r
36 \r
37 #if defined (__cplusplus)\r
38 extern "C" {\r
39 #endif\r
40 \r
41 \r
42 int LZ4_compressHC (const char* source, char* dest, int inputSize);\r
43 /*\r
44 LZ4_compressHC :\r
45     return : the number of bytes in compressed buffer dest\r
46              or 0 if compression fails.\r
47     note : destination buffer must be already allocated. \r
48         To avoid any problem, size it to handle worst cases situations (input data not compressible)\r
49         Worst case size evaluation is provided by function LZ4_compressBound() (see "lz4.h")\r
50 */\r
51 \r
52 int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);\r
53 /*\r
54 LZ4_compress_limitedOutput() :\r
55     Compress 'inputSize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'.\r
56     If it cannot achieve it, compression will stop, and result of the function will be zero.\r
57     This function never writes outside of provided output buffer.\r
58 \r
59     inputSize  : Max supported value is 1 GB\r
60     maxOutputSize : is maximum allowed size into the destination buffer (which must be already allocated)\r
61     return : the number of output bytes written in buffer 'dest'\r
62              or 0 if compression fails.\r
63 */\r
64 \r
65 \r
66 /* Note :\r
67 Decompression functions are provided within LZ4 source code (see "lz4.h") (BSD license)\r
68 */\r
69 \r
70 \r
71 /* Advanced Functions */\r
72 \r
73 void* LZ4_createHC (const char* slidingInputBuffer);\r
74 int   LZ4_compressHC_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize);\r
75 int   LZ4_compressHC_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize);\r
76 char* LZ4_slideInputBufferHC (void* LZ4HC_Data);\r
77 int   LZ4_freeHC (void* LZ4HC_Data);\r
78 \r
79 /* \r
80 These functions allow the compression of dependent blocks, where each block benefits from prior 64 KB within preceding blocks.\r
81 In order to achieve this, it is necessary to start creating the LZ4HC Data Structure, thanks to the function :\r
82 \r
83 void* LZ4_createHC (const char* slidingInputBuffer);\r
84 The result of the function is the (void*) pointer on the LZ4HC Data Structure.\r
85 This pointer will be needed in all other functions.\r
86 If the pointer returned is NULL, then the allocation has failed, and compression must be aborted.\r
87 The only parameter 'const char* slidingInputBuffer' must, obviously, point at the beginning of input buffer.\r
88 The input buffer must be already allocated, and size at least 192KB.\r
89 'slidingInputBuffer' will also be the 'const char* source' of the first block.\r
90 \r
91 All blocks are expected to lay next to each other within the input buffer, starting from 'slidingInputBuffer'.\r
92 To compress each block, use either LZ4_compressHC_continue() or LZ4_compressHC_limitedOutput_continue().\r
93 Their behavior are identical to LZ4_compressHC() or LZ4_compressHC_limitedOutput(), \r
94 but require the LZ4HC Data Structure as their first argument, and check that each block starts right after the previous one.\r
95 If next block does not begin immediately after the previous one, the compression will fail (return 0).\r
96 \r
97 When it's no longer possible to lay the next block after the previous one (not enough space left into input buffer), a call to : \r
98 char* LZ4_slideInputBufferHC(void* LZ4HC_Data);\r
99 must be performed. It will typically copy the latest 64KB of input at the beginning of input buffer.\r
100 Note that, for this function to work properly, minimum size of an input buffer must be 192KB.\r
101 ==> The memory position where the next input data block must start is provided as the result of the function.\r
102 \r
103 Compression can then resume, using LZ4_compressHC_continue() or LZ4_compressHC_limitedOutput_continue(), as usual.\r
104 \r
105 When compression is completed, a call to LZ4_freeHC() will release the memory used by the LZ4HC Data Structure.\r
106 */\r
107 \r
108 \r
109 #if defined (__cplusplus)\r
110 }\r
111 #endif\r