brotli 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/main.yml +34 -0
- data/.github/workflows/publish.yml +34 -0
- data/Gemfile +6 -2
- data/Rakefile +18 -6
- data/bin/before_install.sh +9 -0
- data/brotli.gemspec +7 -13
- data/ext/brotli/brotli.c +209 -11
- data/ext/brotli/buffer.c +1 -7
- data/ext/brotli/buffer.h +1 -1
- data/ext/brotli/extconf.rb +45 -26
- data/lib/brotli/version.rb +1 -1
- data/smoke.sh +1 -1
- data/test/brotli_test.rb +104 -0
- data/test/brotli_writer_test.rb +36 -0
- data/test/test_helper.rb +8 -0
- data/vendor/brotli/c/common/constants.c +15 -0
- data/vendor/brotli/c/common/constants.h +149 -6
- data/vendor/brotli/c/{dec/context.h → common/context.c} +91 -186
- data/vendor/brotli/c/common/context.h +113 -0
- data/vendor/brotli/c/common/dictionary.bin +0 -0
- data/vendor/brotli/c/common/dictionary.bin.br +0 -0
- data/vendor/brotli/c/common/dictionary.c +11 -2
- data/vendor/brotli/c/common/dictionary.h +4 -4
- data/vendor/brotli/c/common/platform.c +22 -0
- data/vendor/brotli/c/common/platform.h +594 -0
- data/vendor/brotli/c/common/transform.c +291 -0
- data/vendor/brotli/c/common/transform.h +85 -0
- data/vendor/brotli/c/common/version.h +8 -1
- data/vendor/brotli/c/dec/bit_reader.c +29 -1
- data/vendor/brotli/c/dec/bit_reader.h +91 -100
- data/vendor/brotli/c/dec/decode.c +665 -437
- data/vendor/brotli/c/dec/huffman.c +65 -84
- data/vendor/brotli/c/dec/huffman.h +67 -14
- data/vendor/brotli/c/dec/prefix.h +1 -20
- data/vendor/brotli/c/dec/state.c +32 -45
- data/vendor/brotli/c/dec/state.h +173 -55
- data/vendor/brotli/c/enc/backward_references.c +27 -16
- data/vendor/brotli/c/enc/backward_references.h +7 -7
- data/vendor/brotli/c/enc/backward_references_hq.c +155 -116
- data/vendor/brotli/c/enc/backward_references_hq.h +22 -23
- data/vendor/brotli/c/enc/backward_references_inc.h +32 -22
- data/vendor/brotli/c/enc/bit_cost.c +1 -1
- data/vendor/brotli/c/enc/bit_cost.h +5 -5
- data/vendor/brotli/c/enc/block_encoder_inc.h +7 -6
- data/vendor/brotli/c/enc/block_splitter.c +5 -6
- data/vendor/brotli/c/enc/block_splitter.h +1 -1
- data/vendor/brotli/c/enc/block_splitter_inc.h +26 -17
- data/vendor/brotli/c/enc/brotli_bit_stream.c +107 -123
- data/vendor/brotli/c/enc/brotli_bit_stream.h +19 -38
- data/vendor/brotli/c/enc/cluster.c +1 -1
- data/vendor/brotli/c/enc/cluster.h +1 -1
- data/vendor/brotli/c/enc/cluster_inc.h +6 -3
- data/vendor/brotli/c/enc/command.c +28 -0
- data/vendor/brotli/c/enc/command.h +52 -42
- data/vendor/brotli/c/enc/compress_fragment.c +21 -22
- data/vendor/brotli/c/enc/compress_fragment.h +1 -1
- data/vendor/brotli/c/enc/compress_fragment_two_pass.c +102 -69
- data/vendor/brotli/c/enc/compress_fragment_two_pass.h +1 -1
- data/vendor/brotli/c/enc/dictionary_hash.c +1827 -1101
- data/vendor/brotli/c/enc/dictionary_hash.h +2 -1
- data/vendor/brotli/c/enc/encode.c +358 -195
- data/vendor/brotli/c/enc/encoder_dict.c +33 -0
- data/vendor/brotli/c/enc/encoder_dict.h +43 -0
- data/vendor/brotli/c/enc/entropy_encode.c +16 -14
- data/vendor/brotli/c/enc/entropy_encode.h +7 -7
- data/vendor/brotli/c/enc/entropy_encode_static.h +3 -3
- data/vendor/brotli/c/enc/fast_log.c +105 -0
- data/vendor/brotli/c/enc/fast_log.h +20 -99
- data/vendor/brotli/c/enc/find_match_length.h +5 -6
- data/vendor/brotli/c/enc/hash.h +145 -103
- data/vendor/brotli/c/enc/hash_composite_inc.h +125 -0
- data/vendor/brotli/c/enc/hash_forgetful_chain_inc.h +93 -53
- data/vendor/brotli/c/enc/hash_longest_match64_inc.h +54 -53
- data/vendor/brotli/c/enc/hash_longest_match_inc.h +58 -54
- data/vendor/brotli/c/enc/hash_longest_match_quickly_inc.h +95 -63
- data/vendor/brotli/c/enc/hash_rolling_inc.h +212 -0
- data/vendor/brotli/c/enc/hash_to_binary_tree_inc.h +46 -43
- data/vendor/brotli/c/enc/histogram.c +9 -6
- data/vendor/brotli/c/enc/histogram.h +6 -3
- data/vendor/brotli/c/enc/histogram_inc.h +1 -1
- data/vendor/brotli/c/enc/literal_cost.c +5 -5
- data/vendor/brotli/c/enc/literal_cost.h +2 -2
- data/vendor/brotli/c/enc/memory.c +5 -16
- data/vendor/brotli/c/enc/memory.h +52 -1
- data/vendor/brotli/c/enc/metablock.c +171 -36
- data/vendor/brotli/c/enc/metablock.h +13 -8
- data/vendor/brotli/c/enc/metablock_inc.h +2 -2
- data/vendor/brotli/c/enc/params.h +46 -0
- data/vendor/brotli/c/enc/prefix.h +3 -4
- data/vendor/brotli/c/enc/quality.h +29 -24
- data/vendor/brotli/c/enc/ringbuffer.h +19 -12
- data/vendor/brotli/c/enc/static_dict.c +49 -45
- data/vendor/brotli/c/enc/static_dict.h +4 -3
- data/vendor/brotli/c/enc/static_dict_lut.h +1 -1
- data/vendor/brotli/c/enc/utf8_util.c +21 -21
- data/vendor/brotli/c/enc/utf8_util.h +1 -1
- data/vendor/brotli/c/enc/write_bits.h +35 -38
- data/vendor/brotli/c/include/brotli/decode.h +13 -8
- data/vendor/brotli/c/include/brotli/encode.h +54 -8
- data/vendor/brotli/c/include/brotli/port.h +225 -83
- data/vendor/brotli/c/include/brotli/types.h +0 -7
- metadata +28 -87
- data/.travis.yml +0 -30
- data/spec/brotli_spec.rb +0 -88
- data/spec/inflate_spec.rb +0 -75
- data/spec/spec_helper.rb +0 -4
- data/vendor/brotli/c/dec/port.h +0 -168
- data/vendor/brotli/c/dec/transform.h +0 -300
- data/vendor/brotli/c/enc/context.h +0 -184
- data/vendor/brotli/c/enc/port.h +0 -184
@@ -9,18 +9,13 @@
|
|
9
9
|
#ifndef BROTLI_ENC_WRITE_BITS_H_
|
10
10
|
#define BROTLI_ENC_WRITE_BITS_H_
|
11
11
|
|
12
|
-
#include
|
13
|
-
#include <stdio.h> /* printf */
|
14
|
-
|
12
|
+
#include "../common/platform.h"
|
15
13
|
#include <brotli/types.h>
|
16
|
-
#include "./port.h"
|
17
14
|
|
18
15
|
#if defined(__cplusplus) || defined(c_plusplus)
|
19
16
|
extern "C" {
|
20
17
|
#endif
|
21
18
|
|
22
|
-
/*#define BIT_WRITER_DEBUG */
|
23
|
-
|
24
19
|
/* This function writes bits into bytes in increasing addresses, and within
|
25
20
|
a byte least-significant-bit first.
|
26
21
|
|
@@ -31,55 +26,57 @@ extern "C" {
|
|
31
26
|
|
32
27
|
0000 0RRR 0000 0000 0000 0000
|
33
28
|
|
34
|
-
Now, we could write 5 or less bits in MSB by just
|
29
|
+
Now, we could write 5 or less bits in MSB by just shifting by 3
|
35
30
|
and OR'ing to BYTE-0.
|
36
31
|
|
37
32
|
For n bits, we take the last 5 bits, OR that with high bits in BYTE-0,
|
38
33
|
and locate the rest in BYTE+1, BYTE+2, etc. */
|
39
34
|
static BROTLI_INLINE void BrotliWriteBits(size_t n_bits,
|
40
35
|
uint64_t bits,
|
41
|
-
size_t
|
42
|
-
uint8_t
|
43
|
-
|
36
|
+
size_t* BROTLI_RESTRICT pos,
|
37
|
+
uint8_t* BROTLI_RESTRICT array) {
|
38
|
+
BROTLI_LOG(("WriteBits %2d 0x%08x%08x %10d\n", (int)n_bits,
|
39
|
+
(uint32_t)(bits >> 32), (uint32_t)(bits & 0xFFFFFFFF),
|
40
|
+
(int)*pos));
|
41
|
+
BROTLI_DCHECK((bits >> n_bits) == 0);
|
42
|
+
BROTLI_DCHECK(n_bits <= 56);
|
43
|
+
#if defined(BROTLI_LITTLE_ENDIAN)
|
44
44
|
/* This branch of the code can write up to 56 bits at a time,
|
45
45
|
7 bits are lost by being perhaps already in *p and at least
|
46
46
|
1 bit is needed to initialize the bit-stream ahead (i.e. if 7
|
47
47
|
bits are in *p and we write 57 bits, then the next write will
|
48
48
|
access a byte that was never initialized). */
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
v |= bits << (*pos & 7);
|
57
|
-
BROTLI_UNALIGNED_STORE64LE(p, v); /* Set some bits. */
|
58
|
-
*pos += n_bits;
|
49
|
+
{
|
50
|
+
uint8_t* p = &array[*pos >> 3];
|
51
|
+
uint64_t v = (uint64_t)(*p); /* Zero-extend 8 to 64 bits. */
|
52
|
+
v |= bits << (*pos & 7);
|
53
|
+
BROTLI_UNALIGNED_STORE64LE(p, v); /* Set some bits. */
|
54
|
+
*pos += n_bits;
|
55
|
+
}
|
59
56
|
#else
|
60
|
-
/* implicit &
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
57
|
+
/* implicit & 0xFF is assumed for uint8_t arithmetics */
|
58
|
+
{
|
59
|
+
uint8_t* array_pos = &array[*pos >> 3];
|
60
|
+
const size_t bits_reserved_in_first_byte = (*pos & 7);
|
61
|
+
size_t bits_left_to_write;
|
62
|
+
bits <<= bits_reserved_in_first_byte;
|
63
|
+
*array_pos++ |= (uint8_t)bits;
|
64
|
+
for (bits_left_to_write = n_bits + bits_reserved_in_first_byte;
|
65
|
+
bits_left_to_write >= 9;
|
66
|
+
bits_left_to_write -= 8) {
|
67
|
+
bits >>= 8;
|
68
|
+
*array_pos++ = (uint8_t)bits;
|
69
|
+
}
|
70
|
+
*array_pos = 0;
|
71
|
+
*pos += n_bits;
|
71
72
|
}
|
72
|
-
*array_pos = 0;
|
73
|
-
*pos += n_bits;
|
74
73
|
#endif
|
75
74
|
}
|
76
75
|
|
77
76
|
static BROTLI_INLINE void BrotliWriteBitsPrepareStorage(
|
78
|
-
size_t pos, uint8_t
|
79
|
-
|
80
|
-
|
81
|
-
#endif
|
82
|
-
assert((pos & 7) == 0);
|
77
|
+
size_t pos, uint8_t* array) {
|
78
|
+
BROTLI_LOG(("WriteBitsPrepareStorage %10d\n", (int)pos));
|
79
|
+
BROTLI_DCHECK((pos & 7) == 0);
|
83
80
|
array[pos >> 3] = 0;
|
84
81
|
}
|
85
82
|
|
@@ -34,11 +34,11 @@ typedef struct BrotliDecoderStateStruct BrotliDecoderState;
|
|
34
34
|
typedef enum {
|
35
35
|
/** Decoding error, e.g. corrupted input or memory allocation problem. */
|
36
36
|
BROTLI_DECODER_RESULT_ERROR = 0,
|
37
|
-
/** Decoding successfully completed */
|
37
|
+
/** Decoding successfully completed. */
|
38
38
|
BROTLI_DECODER_RESULT_SUCCESS = 1,
|
39
|
-
/** Partially done; should be called again with more input */
|
39
|
+
/** Partially done; should be called again with more input. */
|
40
40
|
BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT = 2,
|
41
|
-
/** Partially done; should be called again with more output */
|
41
|
+
/** Partially done; should be called again with more output. */
|
42
42
|
BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT = 3
|
43
43
|
} BrotliDecoderResult;
|
44
44
|
|
@@ -83,10 +83,10 @@ typedef enum {
|
|
83
83
|
BROTLI_ERROR_CODE(_ERROR_FORMAT_, WINDOW_BITS, -13) SEPARATOR \
|
84
84
|
BROTLI_ERROR_CODE(_ERROR_FORMAT_, PADDING_1, -14) SEPARATOR \
|
85
85
|
BROTLI_ERROR_CODE(_ERROR_FORMAT_, PADDING_2, -15) SEPARATOR \
|
86
|
+
BROTLI_ERROR_CODE(_ERROR_FORMAT_, DISTANCE, -16) SEPARATOR \
|
86
87
|
\
|
87
|
-
/* -
|
88
|
+
/* -17..-18 codes are reserved */ \
|
88
89
|
\
|
89
|
-
BROTLI_ERROR_CODE(_ERROR_, COMPOUND_DICTIONARY, -18) SEPARATOR \
|
90
90
|
BROTLI_ERROR_CODE(_ERROR_, DICTIONARY_NOT_SET, -19) SEPARATOR \
|
91
91
|
BROTLI_ERROR_CODE(_ERROR_, INVALID_ARGUMENTS, -20) SEPARATOR \
|
92
92
|
\
|
@@ -135,7 +135,11 @@ typedef enum BrotliDecoderParameter {
|
|
135
135
|
* Ring buffer is allocated according to window size, despite the real size of
|
136
136
|
* the content.
|
137
137
|
*/
|
138
|
-
BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION = 0
|
138
|
+
BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION = 0,
|
139
|
+
/**
|
140
|
+
* Flag that determines if "Large Window Brotli" is used.
|
141
|
+
*/
|
142
|
+
BROTLI_DECODER_PARAM_LARGE_WINDOW = 1
|
139
143
|
} BrotliDecoderParameter;
|
140
144
|
|
141
145
|
/**
|
@@ -159,10 +163,11 @@ BROTLI_DEC_API BROTLI_BOOL BrotliDecoderSetParameter(
|
|
159
163
|
*
|
160
164
|
* @p alloc_func and @p free_func @b MUST be both zero or both non-zero. In the
|
161
165
|
* case they are both zero, default memory allocators are used. @p opaque is
|
162
|
-
* passed to @p alloc_func and @p free_func when they are called.
|
166
|
+
* passed to @p alloc_func and @p free_func when they are called. @p free_func
|
167
|
+
* has to return without doing anything when asked to free a NULL pointer.
|
163
168
|
*
|
164
169
|
* @param alloc_func custom memory allocation function
|
165
|
-
* @param free_func custom memory
|
170
|
+
* @param free_func custom memory free function
|
166
171
|
* @param opaque custom memory manager handle
|
167
172
|
* @returns @c 0 if instance can not be allocated or initialized
|
168
173
|
* @returns pointer to initialized ::BrotliDecoderState otherwise
|
@@ -27,6 +27,11 @@ extern "C" {
|
|
27
27
|
* @note equal to @c BROTLI_MAX_DISTANCE_BITS constant.
|
28
28
|
*/
|
29
29
|
#define BROTLI_MAX_WINDOW_BITS 24
|
30
|
+
/**
|
31
|
+
* Maximal value for ::BROTLI_PARAM_LGWIN parameter
|
32
|
+
* in "Large Window Brotli" (32-bit).
|
33
|
+
*/
|
34
|
+
#define BROTLI_LARGE_MAX_WINDOW_BITS 30
|
30
35
|
/** Minimal value for ::BROTLI_PARAM_LGBLOCK parameter. */
|
31
36
|
#define BROTLI_MIN_INPUT_BLOCK_BITS 16
|
32
37
|
/** Maximal value for ::BROTLI_PARAM_LGBLOCK parameter. */
|
@@ -176,7 +181,43 @@ typedef enum BrotliEncoderParameter {
|
|
176
181
|
*
|
177
182
|
* The default value is 0, which means that the total input size is unknown.
|
178
183
|
*/
|
179
|
-
BROTLI_PARAM_SIZE_HINT = 5
|
184
|
+
BROTLI_PARAM_SIZE_HINT = 5,
|
185
|
+
/**
|
186
|
+
* Flag that determines if "Large Window Brotli" is used.
|
187
|
+
*/
|
188
|
+
BROTLI_PARAM_LARGE_WINDOW = 6,
|
189
|
+
/**
|
190
|
+
* Recommended number of postfix bits (NPOSTFIX).
|
191
|
+
*
|
192
|
+
* Encoder may change this value.
|
193
|
+
*
|
194
|
+
* Range is from 0 to ::BROTLI_MAX_NPOSTFIX.
|
195
|
+
*/
|
196
|
+
BROTLI_PARAM_NPOSTFIX = 7,
|
197
|
+
/**
|
198
|
+
* Recommended number of direct distance codes (NDIRECT).
|
199
|
+
*
|
200
|
+
* Encoder may change this value.
|
201
|
+
*
|
202
|
+
* Range is from 0 to (15 << NPOSTFIX) in steps of (1 << NPOSTFIX).
|
203
|
+
*/
|
204
|
+
BROTLI_PARAM_NDIRECT = 8,
|
205
|
+
/**
|
206
|
+
* Number of bytes of input stream already processed by a different instance.
|
207
|
+
*
|
208
|
+
* @note It is important to configure all the encoder instances with same
|
209
|
+
* parameters (except this one) in order to allow all the encoded parts
|
210
|
+
* obey the same restrictions implied by header.
|
211
|
+
*
|
212
|
+
* If offset is not 0, then stream header is omitted.
|
213
|
+
* In any case output start is byte aligned, so for proper streams stitching
|
214
|
+
* "predecessor" stream must be flushed.
|
215
|
+
*
|
216
|
+
* Range is not artificially limited, but all the values greater or equal to
|
217
|
+
* maximal window size have the same effect. Values greater than 2**30 are not
|
218
|
+
* allowed.
|
219
|
+
*/
|
220
|
+
BROTLI_PARAM_STREAM_OFFSET = 9
|
180
221
|
} BrotliEncoderParameter;
|
181
222
|
|
182
223
|
/**
|
@@ -209,10 +250,11 @@ BROTLI_ENC_API BROTLI_BOOL BrotliEncoderSetParameter(
|
|
209
250
|
*
|
210
251
|
* @p alloc_func and @p free_func @b MUST be both zero or both non-zero. In the
|
211
252
|
* case they are both zero, default memory allocators are used. @p opaque is
|
212
|
-
* passed to @p alloc_func and @p free_func when they are called.
|
253
|
+
* passed to @p alloc_func and @p free_func when they are called. @p free_func
|
254
|
+
* has to return without doing anything when asked to free a NULL pointer.
|
213
255
|
*
|
214
256
|
* @param alloc_func custom memory allocation function
|
215
|
-
* @param free_func custom memory
|
257
|
+
* @param free_func custom memory free function
|
216
258
|
* @param opaque custom memory manager handle
|
217
259
|
* @returns @c 0 if instance can not be allocated or initialized
|
218
260
|
* @returns pointer to initialized ::BrotliEncoderState otherwise
|
@@ -230,10 +272,9 @@ BROTLI_ENC_API void BrotliEncoderDestroyInstance(BrotliEncoderState* state);
|
|
230
272
|
/**
|
231
273
|
* Calculates the output size bound for the given @p input_size.
|
232
274
|
*
|
233
|
-
* @warning Result is
|
234
|
-
*
|
235
|
-
*
|
236
|
-
* after every chunk of input.
|
275
|
+
* @warning Result is only valid if quality is at least @c 2 and, in
|
276
|
+
* case ::BrotliEncoderCompressStream was used, no flushes
|
277
|
+
* (::BROTLI_OPERATION_FLUSH) were performed.
|
237
278
|
*
|
238
279
|
* @param input_size size of projected input
|
239
280
|
* @returns @c 0 if result does not fit @c size_t
|
@@ -249,6 +290,11 @@ BROTLI_ENC_API size_t BrotliEncoderMaxCompressedSize(size_t input_size);
|
|
249
290
|
* @note If ::BrotliEncoderMaxCompressedSize(@p input_size) returns non-zero
|
250
291
|
* value, then output is guaranteed to be no longer than that.
|
251
292
|
*
|
293
|
+
* @note If @p lgwin is greater than ::BROTLI_MAX_WINDOW_BITS then resulting
|
294
|
+
* stream might be incompatible with RFC 7932; to decode such streams,
|
295
|
+
* decoder should be configured with
|
296
|
+
* ::BROTLI_DECODER_PARAM_LARGE_WINDOW = @c 1
|
297
|
+
*
|
252
298
|
* @param quality quality parameter value, e.g. ::BROTLI_DEFAULT_QUALITY
|
253
299
|
* @param lgwin lgwin parameter value, e.g. ::BROTLI_DEFAULT_WINDOW
|
254
300
|
* @param mode mode parameter value, e.g. ::BROTLI_DEFAULT_MODE
|
@@ -283,7 +329,7 @@ BROTLI_ENC_API BROTLI_BOOL BrotliEncoderCompress(
|
|
283
329
|
* that amount.
|
284
330
|
*
|
285
331
|
* @p total_out, if it is not a null-pointer, will be set to the number
|
286
|
-
* of bytes
|
332
|
+
* of bytes compressed since the last @p state initialization.
|
287
333
|
*
|
288
334
|
*
|
289
335
|
*
|
@@ -4,90 +4,261 @@
|
|
4
4
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
5
5
|
*/
|
6
6
|
|
7
|
-
/* Macros for compiler / platform specific
|
7
|
+
/* Macros for compiler / platform specific API declarations. */
|
8
8
|
|
9
9
|
#ifndef BROTLI_COMMON_PORT_H_
|
10
10
|
#define BROTLI_COMMON_PORT_H_
|
11
11
|
|
12
|
-
/*
|
13
|
-
|
14
|
-
|
12
|
+
/* The following macros were borrowed from https://github.com/nemequ/hedley
|
13
|
+
* with permission of original author - Evan Nemerson <evan@nemerson.com> */
|
14
|
+
|
15
|
+
/* >>> >>> >>> hedley macros */
|
16
|
+
|
17
|
+
#define BROTLI_MAKE_VERSION(major, minor, revision) \
|
18
|
+
(((major) * 1000000) + ((minor) * 1000) + (revision))
|
19
|
+
|
20
|
+
#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__)
|
21
|
+
#define BROTLI_GNUC_VERSION \
|
22
|
+
BROTLI_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
|
23
|
+
#elif defined(__GNUC__)
|
24
|
+
#define BROTLI_GNUC_VERSION BROTLI_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, 0)
|
15
25
|
#endif
|
16
26
|
|
17
|
-
#
|
18
|
-
#define
|
27
|
+
#if defined(BROTLI_GNUC_VERSION)
|
28
|
+
#define BROTLI_GNUC_VERSION_CHECK(major, minor, patch) \
|
29
|
+
(BROTLI_GNUC_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
30
|
+
#else
|
31
|
+
#define BROTLI_GNUC_VERSION_CHECK(major, minor, patch) (0)
|
19
32
|
#endif
|
20
33
|
|
21
|
-
#
|
22
|
-
#define
|
34
|
+
#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000)
|
35
|
+
#define BROTLI_MSVC_VERSION \
|
36
|
+
BROTLI_MAKE_VERSION((_MSC_FULL_VER / 10000000), \
|
37
|
+
(_MSC_FULL_VER % 10000000) / 100000, \
|
38
|
+
(_MSC_FULL_VER % 100000) / 100)
|
39
|
+
#elif defined(_MSC_FULL_VER)
|
40
|
+
#define BROTLI_MSVC_VERSION \
|
41
|
+
BROTLI_MAKE_VERSION((_MSC_FULL_VER / 1000000), \
|
42
|
+
(_MSC_FULL_VER % 1000000) / 10000, \
|
43
|
+
(_MSC_FULL_VER % 10000) / 10)
|
44
|
+
#elif defined(_MSC_VER)
|
45
|
+
#define BROTLI_MSVC_VERSION \
|
46
|
+
BROTLI_MAKE_VERSION(_MSC_VER / 100, _MSC_VER % 100, 0)
|
23
47
|
#endif
|
24
48
|
|
25
|
-
#if defined(
|
26
|
-
#define
|
49
|
+
#if !defined(_MSC_VER)
|
50
|
+
#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) (0)
|
51
|
+
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
52
|
+
#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \
|
53
|
+
(_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch)))
|
54
|
+
#elif defined(_MSC_VER) && (_MSC_VER >= 1200)
|
55
|
+
#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \
|
56
|
+
(_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch)))
|
27
57
|
#else
|
28
|
-
#define
|
58
|
+
#define BROTLI_MSVC_VERSION_CHECK(major, minor, patch) \
|
59
|
+
(_MSC_VER >= ((major * 100) + (minor)))
|
29
60
|
#endif
|
30
61
|
|
31
|
-
#if defined(
|
32
|
-
#define
|
62
|
+
#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE)
|
63
|
+
#define BROTLI_INTEL_VERSION \
|
64
|
+
BROTLI_MAKE_VERSION(__INTEL_COMPILER / 100, \
|
65
|
+
__INTEL_COMPILER % 100, \
|
66
|
+
__INTEL_COMPILER_UPDATE)
|
67
|
+
#elif defined(__INTEL_COMPILER)
|
68
|
+
#define BROTLI_INTEL_VERSION \
|
69
|
+
BROTLI_MAKE_VERSION(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
|
70
|
+
#endif
|
71
|
+
|
72
|
+
#if defined(BROTLI_INTEL_VERSION)
|
73
|
+
#define BROTLI_INTEL_VERSION_CHECK(major, minor, patch) \
|
74
|
+
(BROTLI_INTEL_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
33
75
|
#else
|
34
|
-
#define
|
76
|
+
#define BROTLI_INTEL_VERSION_CHECK(major, minor, patch) (0)
|
77
|
+
#endif
|
78
|
+
|
79
|
+
#if defined(__PGI) && \
|
80
|
+
defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__)
|
81
|
+
#define BROTLI_PGI_VERSION \
|
82
|
+
BROTLI_MAKE_VERSION(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__)
|
35
83
|
#endif
|
36
84
|
|
37
|
-
#if defined(
|
38
|
-
#define
|
39
|
-
|
40
|
-
#define BROTLI_MODERN_COMPILER 1
|
85
|
+
#if defined(BROTLI_PGI_VERSION)
|
86
|
+
#define BROTLI_PGI_VERSION_CHECK(major, minor, patch) \
|
87
|
+
(BROTLI_PGI_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
41
88
|
#else
|
42
|
-
#define
|
89
|
+
#define BROTLI_PGI_VERSION_CHECK(major, minor, patch) (0)
|
43
90
|
#endif
|
44
91
|
|
45
|
-
|
46
|
-
|
92
|
+
#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000)
|
93
|
+
#define BROTLI_SUNPRO_VERSION \
|
94
|
+
BROTLI_MAKE_VERSION( \
|
95
|
+
(((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), \
|
96
|
+
(((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), \
|
97
|
+
(__SUNPRO_C & 0xf) * 10)
|
98
|
+
#elif defined(__SUNPRO_C)
|
99
|
+
#define BROTLI_SUNPRO_VERSION \
|
100
|
+
BROTLI_MAKE_VERSION((__SUNPRO_C >> 8) & 0xf, \
|
101
|
+
(__SUNPRO_C >> 4) & 0xf, \
|
102
|
+
(__SUNPRO_C) & 0xf)
|
103
|
+
#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000)
|
104
|
+
#define BROTLI_SUNPRO_VERSION \
|
105
|
+
BROTLI_MAKE_VERSION( \
|
106
|
+
(((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), \
|
107
|
+
(((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), \
|
108
|
+
(__SUNPRO_CC & 0xf) * 10)
|
109
|
+
#elif defined(__SUNPRO_CC)
|
110
|
+
#define BROTLI_SUNPRO_VERSION \
|
111
|
+
BROTLI_MAKE_VERSION((__SUNPRO_CC >> 8) & 0xf, \
|
112
|
+
(__SUNPRO_CC >> 4) & 0xf, \
|
113
|
+
(__SUNPRO_CC) & 0xf)
|
114
|
+
#endif
|
47
115
|
|
48
|
-
|
116
|
+
#if defined(BROTLI_SUNPRO_VERSION)
|
117
|
+
#define BROTLI_SUNPRO_VERSION_CHECK(major, minor, patch) \
|
118
|
+
(BROTLI_SUNPRO_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
119
|
+
#else
|
120
|
+
#define BROTLI_SUNPRO_VERSION_CHECK(major, minor, patch) (0)
|
121
|
+
#endif
|
49
122
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
123
|
+
#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION)
|
124
|
+
#define BROTLI_ARM_VERSION \
|
125
|
+
BROTLI_MAKE_VERSION((__ARMCOMPILER_VERSION / 1000000), \
|
126
|
+
(__ARMCOMPILER_VERSION % 1000000) / 10000, \
|
127
|
+
(__ARMCOMPILER_VERSION % 10000) / 100)
|
128
|
+
#elif defined(__CC_ARM) && defined(__ARMCC_VERSION)
|
129
|
+
#define BROTLI_ARM_VERSION \
|
130
|
+
BROTLI_MAKE_VERSION((__ARMCC_VERSION / 1000000), \
|
131
|
+
(__ARMCC_VERSION % 1000000) / 10000, \
|
132
|
+
(__ARMCC_VERSION % 10000) / 100)
|
133
|
+
#endif
|
55
134
|
|
56
|
-
|
135
|
+
#if defined(BROTLI_ARM_VERSION)
|
136
|
+
#define BROTLI_ARM_VERSION_CHECK(major, minor, patch) \
|
137
|
+
(BROTLI_ARM_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
138
|
+
#else
|
139
|
+
#define BROTLI_ARM_VERSION_CHECK(major, minor, patch) (0)
|
140
|
+
#endif
|
57
141
|
|
58
|
-
|
59
|
-
|
60
|
-
|
142
|
+
#if defined(__ibmxl__)
|
143
|
+
#define BROTLI_IBM_VERSION \
|
144
|
+
BROTLI_MAKE_VERSION(__ibmxl_version__, \
|
145
|
+
__ibmxl_release__, \
|
146
|
+
__ibmxl_modification__)
|
147
|
+
#elif defined(__xlC__) && defined(__xlC_ver__)
|
148
|
+
#define BROTLI_IBM_VERSION \
|
149
|
+
BROTLI_MAKE_VERSION(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff)
|
150
|
+
#elif defined(__xlC__)
|
151
|
+
#define BROTLI_IBM_VERSION BROTLI_MAKE_VERSION(__xlC__ >> 8, __xlC__ & 0xff, 0)
|
152
|
+
#endif
|
61
153
|
|
62
|
-
|
63
|
-
#
|
64
|
-
|
65
|
-
#
|
154
|
+
#if defined(BROTLI_IBM_VERSION)
|
155
|
+
#define BROTLI_IBM_VERSION_CHECK(major, minor, patch) \
|
156
|
+
(BROTLI_IBM_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
157
|
+
#else
|
158
|
+
#define BROTLI_IBM_VERSION_CHECK(major, minor, patch) (0)
|
159
|
+
#endif
|
160
|
+
|
161
|
+
#if defined(__TI_COMPILER_VERSION__)
|
162
|
+
#define BROTLI_TI_VERSION \
|
163
|
+
BROTLI_MAKE_VERSION((__TI_COMPILER_VERSION__ / 1000000), \
|
164
|
+
(__TI_COMPILER_VERSION__ % 1000000) / 1000, \
|
165
|
+
(__TI_COMPILER_VERSION__ % 1000))
|
166
|
+
#endif
|
167
|
+
|
168
|
+
#if defined(BROTLI_TI_VERSION)
|
169
|
+
#define BROTLI_TI_VERSION_CHECK(major, minor, patch) \
|
170
|
+
(BROTLI_TI_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
171
|
+
#else
|
172
|
+
#define BROTLI_TI_VERSION_CHECK(major, minor, patch) (0)
|
173
|
+
#endif
|
174
|
+
|
175
|
+
#if defined(__IAR_SYSTEMS_ICC__)
|
176
|
+
#if __VER__ > 1000
|
177
|
+
#define BROTLI_IAR_VERSION \
|
178
|
+
BROTLI_MAKE_VERSION((__VER__ / 1000000), \
|
179
|
+
(__VER__ / 1000) % 1000, \
|
180
|
+
(__VER__ % 1000))
|
66
181
|
#else
|
67
|
-
#define
|
68
|
-
#
|
182
|
+
#define BROTLI_IAR_VERSION BROTLI_MAKE_VERSION(VER / 100, __VER__ % 100, 0)
|
183
|
+
#endif
|
69
184
|
#endif
|
70
185
|
|
71
|
-
#if
|
72
|
-
#define
|
186
|
+
#if defined(BROTLI_IAR_VERSION)
|
187
|
+
#define BROTLI_IAR_VERSION_CHECK(major, minor, patch) \
|
188
|
+
(BROTLI_IAR_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
73
189
|
#else
|
74
|
-
#define
|
190
|
+
#define BROTLI_IAR_VERSION_CHECK(major, minor, patch) (0)
|
191
|
+
#endif
|
192
|
+
|
193
|
+
#if defined(__TINYC__)
|
194
|
+
#define BROTLI_TINYC_VERSION \
|
195
|
+
BROTLI_MAKE_VERSION(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100)
|
196
|
+
#endif
|
197
|
+
|
198
|
+
#if defined(BROTLI_TINYC_VERSION)
|
199
|
+
#define BROTLI_TINYC_VERSION_CHECK(major, minor, patch) \
|
200
|
+
(BROTLI_TINYC_VERSION >= BROTLI_MAKE_VERSION(major, minor, patch))
|
201
|
+
#else
|
202
|
+
#define BROTLI_TINYC_VERSION_CHECK(major, minor, patch) (0)
|
203
|
+
#endif
|
204
|
+
|
205
|
+
#if defined(__has_attribute)
|
206
|
+
#define BROTLI_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \
|
207
|
+
__has_attribute(attribute)
|
208
|
+
#else
|
209
|
+
#define BROTLI_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \
|
210
|
+
BROTLI_GNUC_VERSION_CHECK(major, minor, patch)
|
211
|
+
#endif
|
212
|
+
|
213
|
+
#if defined(__has_builtin)
|
214
|
+
#define BROTLI_GNUC_HAS_BUILTIN(builtin, major, minor, patch) \
|
215
|
+
__has_builtin(builtin)
|
216
|
+
#else
|
217
|
+
#define BROTLI_GNUC_HAS_BUILTIN(builtin, major, minor, patch) \
|
218
|
+
BROTLI_GNUC_VERSION_CHECK(major, minor, patch)
|
219
|
+
#endif
|
220
|
+
|
221
|
+
#if defined(__has_feature)
|
222
|
+
#define BROTLI_HAS_FEATURE(feature) __has_feature(feature)
|
223
|
+
#else
|
224
|
+
#define BROTLI_HAS_FEATURE(feature) (0)
|
225
|
+
#endif
|
226
|
+
|
227
|
+
#if defined(ADDRESS_SANITIZER) || BROTLI_HAS_FEATURE(address_sanitizer) || \
|
228
|
+
defined(THREAD_SANITIZER) || BROTLI_HAS_FEATURE(thread_sanitizer) || \
|
229
|
+
defined(MEMORY_SANITIZER) || BROTLI_HAS_FEATURE(memory_sanitizer)
|
230
|
+
#define BROTLI_SANITIZED 1
|
231
|
+
#else
|
232
|
+
#define BROTLI_SANITIZED 0
|
75
233
|
#endif
|
76
234
|
|
77
235
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
78
|
-
#define
|
79
|
-
#elif
|
80
|
-
|
81
|
-
|
236
|
+
#define BROTLI_PUBLIC
|
237
|
+
#elif BROTLI_GNUC_VERSION_CHECK(3, 3, 0) || \
|
238
|
+
BROTLI_TI_VERSION_CHECK(8, 0, 0) || \
|
239
|
+
BROTLI_INTEL_VERSION_CHECK(16, 0, 0) || \
|
240
|
+
BROTLI_ARM_VERSION_CHECK(4, 1, 0) || \
|
241
|
+
BROTLI_IBM_VERSION_CHECK(13, 1, 0) || \
|
242
|
+
BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) || \
|
243
|
+
(BROTLI_TI_VERSION_CHECK(7, 3, 0) && \
|
244
|
+
defined(__TI_GNU_ATTRIBUTE_SUPPORT__) && defined(__TI_EABI__))
|
245
|
+
#define BROTLI_PUBLIC __attribute__ ((visibility ("default")))
|
82
246
|
#else
|
83
|
-
#define
|
247
|
+
#define BROTLI_PUBLIC
|
84
248
|
#endif
|
85
249
|
|
86
|
-
#
|
87
|
-
|
250
|
+
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
|
251
|
+
!defined(__STDC_NO_VLA__) && !defined(__cplusplus) && \
|
252
|
+
!defined(__PGI) && !defined(__PGIC__) && !defined(__TINYC__)
|
253
|
+
#define BROTLI_ARRAY_PARAM(name) (name)
|
254
|
+
#else
|
255
|
+
#define BROTLI_ARRAY_PARAM(name)
|
88
256
|
#endif
|
89
257
|
|
90
|
-
|
258
|
+
/* <<< <<< <<< end of hedley macros. */
|
259
|
+
|
260
|
+
#if defined(BROTLI_SHARED_COMPILATION)
|
261
|
+
#if defined(_WIN32)
|
91
262
|
#if defined(BROTLICOMMON_SHARED_COMPILATION)
|
92
263
|
#define BROTLI_COMMON_API __declspec(dllexport)
|
93
264
|
#else
|
@@ -103,44 +274,15 @@ OR:
|
|
103
274
|
#else
|
104
275
|
#define BROTLI_ENC_API __declspec(dllimport)
|
105
276
|
#endif /* BROTLIENC_SHARED_COMPILATION */
|
106
|
-
#else /*
|
277
|
+
#else /* _WIN32 */
|
278
|
+
#define BROTLI_COMMON_API BROTLI_PUBLIC
|
279
|
+
#define BROTLI_DEC_API BROTLI_PUBLIC
|
280
|
+
#define BROTLI_ENC_API BROTLI_PUBLIC
|
281
|
+
#endif /* _WIN32 */
|
282
|
+
#else /* BROTLI_SHARED_COMPILATION */
|
107
283
|
#define BROTLI_COMMON_API
|
108
284
|
#define BROTLI_DEC_API
|
109
285
|
#define BROTLI_ENC_API
|
110
286
|
#endif
|
111
287
|
|
112
|
-
#ifndef _MSC_VER
|
113
|
-
#if defined(__cplusplus) || !defined(__STRICT_ANSI__) || \
|
114
|
-
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
|
115
|
-
#define BROTLI_INLINE inline BROTLI_ATTRIBUTE_ALWAYS_INLINE
|
116
|
-
#else
|
117
|
-
#define BROTLI_INLINE
|
118
|
-
#endif
|
119
|
-
#else /* _MSC_VER */
|
120
|
-
#define BROTLI_INLINE __forceinline
|
121
|
-
#endif /* _MSC_VER */
|
122
|
-
|
123
|
-
#if !defined(__cplusplus) && !defined(c_plusplus) && \
|
124
|
-
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
|
125
|
-
#define BROTLI_RESTRICT restrict
|
126
|
-
#elif BROTLI_GCC_VERSION > 295 || defined(__llvm__)
|
127
|
-
#define BROTLI_RESTRICT __restrict
|
128
|
-
#else
|
129
|
-
#define BROTLI_RESTRICT
|
130
|
-
#endif
|
131
|
-
|
132
|
-
#if BROTLI_MODERN_COMPILER || __has_attribute(noinline)
|
133
|
-
#define BROTLI_NOINLINE __attribute__((noinline))
|
134
|
-
#else
|
135
|
-
#define BROTLI_NOINLINE
|
136
|
-
#endif
|
137
|
-
|
138
|
-
#if BROTLI_MODERN_COMPILER || __has_attribute(deprecated)
|
139
|
-
#define BROTLI_DEPRECATED __attribute__((deprecated))
|
140
|
-
#else
|
141
|
-
#define BROTLI_DEPRECATED
|
142
|
-
#endif
|
143
|
-
|
144
|
-
#define BROTLI_UNUSED(X) (void)(X)
|
145
|
-
|
146
288
|
#endif /* BROTLI_COMMON_PORT_H_ */
|