BG XLC: Use tr1/unordered_map
[charm.git] / src / arch / util / lz4.h
blobd69d56f3795a1b56d9dd4e47aa4de749c3e8adb6
1 /*
2 LZ4 - Fast LZ compression algorithm
3 Header File
4 Copyright (C) 2011-2012, Yann Collet.
5 BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are
9 met:
11 * Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer.
13 * Redistributions in binary form must reproduce the above
14 copyright notice, this list of conditions and the following disclaimer
15 in the documentation and/or other materials provided with the
16 distribution.
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 You can contact the author at :
31 - LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
32 - LZ4 source repository : http://code.google.com/p/lz4/
34 #pragma once
36 #if defined (__cplusplus)
37 extern "C" {
38 #endif
41 //****************************
42 // Simple Functions
43 //****************************
45 int LZ4_compress (const char* source, char* dest, int isize);
46 int LZ4_uncompress (const char* source, char* dest, int osize);
49 LZ4_compress() :
50 Compresses 'isize' bytes from 'source' into 'dest'.
51 Destination buffer must be already allocated,
52 and must be sized to handle worst cases situations (input data not compressible)
53 Worst case size evaluation is provided by macro LZ4_compressBound()
55 isize : is the input size. Max supported value is ~1.9GB
56 return : the number of bytes written in buffer dest
59 LZ4_uncompress() :
60 osize : is the output size, therefore the original size
61 return : the number of bytes read in the source buffer
62 If the source stream is malformed, the function will stop decoding and return a negative result, indicating the byte position of the faulty instruction
63 This function never writes beyond dest + osize, and is therefore protected against malicious data packets
64 note : destination buffer must be already allocated.
65 its size must be a minimum of 'osize' bytes.
69 //****************************
70 // Advanced Functions
71 //****************************
73 #define LZ4_compressBound(isize) (isize + (isize/255) + 16)
76 LZ4_compressBound() :
77 Provides the maximum size that LZ4 may output in a "worst case" scenario (input data not compressible)
78 primarily useful for memory allocation of output buffer.
80 isize : is the input size. Max supported value is ~1.9GB
81 return : maximum output size in a "worst case" scenario
82 note : this function is limited by "int" range (2^31-1)
86 int LZ4_compress_limitedOutput (const char* source, char* dest, int isize, int maxOutputSize);
89 LZ4_compress_limitedOutput() :
90 Compress 'isize' bytes from 'source' into an output buffer 'dest' of maximum size 'maxOutputSize'.
91 If it cannot achieve it, compression will stop, and result of the function will be zero.
92 This function never writes outside of provided output buffer.
94 isize : is the input size. Max supported value is ~1.9GB
95 maxOutputSize : is the size of the destination buffer (which must be already allocated)
96 return : the number of bytes written in buffer 'dest'
97 or 0 if the compression fails
101 int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize);
104 LZ4_uncompress_unknownOutputSize() :
105 isize : is the input size, therefore the compressed size
106 maxOutputSize : is the size of the destination buffer (which must be already allocated)
107 return : the number of bytes decoded in the destination buffer (necessarily <= maxOutputSize)
108 If the source stream is malformed, the function will stop decoding and return a negative result, indicating the byte position of the faulty instruction
109 This function never writes beyond dest + maxOutputSize, and is therefore protected against malicious data packets
110 note : Destination buffer must be already allocated.
111 This version is slightly slower than LZ4_uncompress()
115 void lz4_wrapper_compress(void *src, void *dst, int in_size, int *out_size);
117 int lz4_wrapper_decompress(void *src, void *dst, int in_size, int out_size);
119 void lz4_init();
120 #if defined (__cplusplus)
122 #endif