/src/h2o/deps/brotli/c/enc/port.h
Line | Count | Source |
1 | | /* Copyright 2013 Google Inc. All Rights Reserved. |
2 | | |
3 | | Distributed under MIT license. |
4 | | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
5 | | */ |
6 | | |
7 | | /* Macros for endianness, branch prediction and unaligned loads and stores. */ |
8 | | |
9 | | #ifndef BROTLI_ENC_PORT_H_ |
10 | | #define BROTLI_ENC_PORT_H_ |
11 | | |
12 | | #include <assert.h> |
13 | | #include <string.h> /* memcpy */ |
14 | | |
15 | | #include <brotli/port.h> |
16 | | #include <brotli/types.h> |
17 | | |
18 | | #if defined OS_LINUX || defined OS_CYGWIN |
19 | | #include <endian.h> |
20 | | #elif defined OS_FREEBSD |
21 | | #include <machine/endian.h> |
22 | | #elif defined OS_MACOSX |
23 | | #include <machine/endian.h> |
24 | | /* Let's try and follow the Linux convention */ |
25 | | #define __BYTE_ORDER BYTE_ORDER |
26 | | #define __LITTLE_ENDIAN LITTLE_ENDIAN |
27 | | #endif |
28 | | |
29 | | /* define the macro BROTLI_LITTLE_ENDIAN |
30 | | using the above endian definitions from endian.h if |
31 | | endian.h was included */ |
32 | | #ifdef __BYTE_ORDER |
33 | | #if __BYTE_ORDER == __LITTLE_ENDIAN |
34 | | #define BROTLI_LITTLE_ENDIAN |
35 | | #endif |
36 | | |
37 | | #else |
38 | | |
39 | | #if defined(__LITTLE_ENDIAN__) |
40 | | #define BROTLI_LITTLE_ENDIAN |
41 | | #endif |
42 | | #endif /* __BYTE_ORDER */ |
43 | | |
44 | | #if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) |
45 | | #define BROTLI_LITTLE_ENDIAN |
46 | | #endif |
47 | | |
48 | | /* Enable little-endian optimization for x64 architecture on Windows. */ |
49 | | #if (defined(_WIN32) || defined(_WIN64)) && defined(_M_X64) |
50 | | #define BROTLI_LITTLE_ENDIAN |
51 | | #endif |
52 | | |
53 | | /* Portable handling of unaligned loads, stores, and copies. |
54 | | On some platforms, like ARM, the copy functions can be more efficient |
55 | | then a load and a store. */ |
56 | | |
57 | | #if defined(BROTLI_LITTLE_ENDIAN) && (\ |
58 | | defined(ARCH_PIII) || defined(ARCH_ATHLON) || \ |
59 | | defined(ARCH_K8) || defined(_ARCH_PPC)) |
60 | | |
61 | | /* x86 and x86-64 can perform unaligned loads/stores directly; |
62 | | modern PowerPC hardware can also do unaligned integer loads and stores; |
63 | | but note: the FPU still sends unaligned loads and stores to a trap handler! |
64 | | */ |
65 | | |
66 | | #define BROTLI_UNALIGNED_LOAD32(_p) (*(const uint32_t *)(_p)) |
67 | | #define BROTLI_UNALIGNED_LOAD64LE(_p) (*(const uint64_t *)(_p)) |
68 | | |
69 | | #define BROTLI_UNALIGNED_STORE64LE(_p, _val) \ |
70 | | (*(uint64_t *)(_p) = (_val)) |
71 | | |
72 | | #elif defined(BROTLI_LITTLE_ENDIAN) && defined(__arm__) && \ |
73 | | !defined(__ARM_ARCH_5__) && \ |
74 | | !defined(__ARM_ARCH_5T__) && \ |
75 | | !defined(__ARM_ARCH_5TE__) && \ |
76 | | !defined(__ARM_ARCH_5TEJ__) && \ |
77 | | !defined(__ARM_ARCH_6__) && \ |
78 | | !defined(__ARM_ARCH_6J__) && \ |
79 | | !defined(__ARM_ARCH_6K__) && \ |
80 | | !defined(__ARM_ARCH_6Z__) && \ |
81 | | !defined(__ARM_ARCH_6ZK__) && \ |
82 | | !defined(__ARM_ARCH_6T2__) |
83 | | |
84 | | /* ARMv7 and newer support native unaligned accesses, but only of 16-bit |
85 | | and 32-bit values (not 64-bit); older versions either raise a fatal signal, |
86 | | do an unaligned read and rotate the words around a bit, or do the reads very |
87 | | slowly (trip through kernel mode). */ |
88 | | |
89 | | #define BROTLI_UNALIGNED_LOAD32(_p) (*(const uint32_t *)(_p)) |
90 | | |
91 | | static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void *p) { |
92 | | uint64_t t; |
93 | | memcpy(&t, p, sizeof t); |
94 | | return t; |
95 | | } |
96 | | |
97 | | static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void *p, uint64_t v) { |
98 | | memcpy(p, &v, sizeof v); |
99 | | } |
100 | | |
101 | | #else |
102 | | |
103 | | /* These functions are provided for architectures that don't support */ |
104 | | /* unaligned loads and stores. */ |
105 | | |
106 | 0 | static BROTLI_INLINE uint32_t BROTLI_UNALIGNED_LOAD32(const void *p) { |
107 | 0 | uint32_t t; |
108 | 0 | memcpy(&t, p, sizeof t); |
109 | 0 | return t; |
110 | 0 | } Unexecuted instantiation: backward_references.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: backward_references_hq.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: bit_cost.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: block_splitter.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: brotli_bit_stream.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: cluster.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: compress_fragment.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: compress_fragment_two_pass.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: encode.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: entropy_encode.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: histogram.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: literal_cost.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: memory.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: metablock.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: static_dict.c:BROTLI_UNALIGNED_LOAD32 Unexecuted instantiation: utf8_util.c:BROTLI_UNALIGNED_LOAD32 |
111 | | |
112 | | #if defined(BROTLI_LITTLE_ENDIAN) |
113 | | |
114 | 0 | static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void *p) { |
115 | 0 | uint64_t t; |
116 | 0 | memcpy(&t, p, sizeof t); |
117 | 0 | return t; |
118 | 0 | } Unexecuted instantiation: backward_references.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: backward_references_hq.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: bit_cost.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: block_splitter.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: brotli_bit_stream.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: cluster.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: compress_fragment.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: compress_fragment_two_pass.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: encode.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: entropy_encode.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: histogram.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: literal_cost.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: memory.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: metablock.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: static_dict.c:BROTLI_UNALIGNED_LOAD64LE Unexecuted instantiation: utf8_util.c:BROTLI_UNALIGNED_LOAD64LE |
119 | | |
120 | 0 | static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void *p, uint64_t v) { |
121 | 0 | memcpy(p, &v, sizeof v); |
122 | 0 | } Unexecuted instantiation: backward_references.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: backward_references_hq.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: bit_cost.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: block_splitter.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: brotli_bit_stream.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: cluster.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: compress_fragment.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: compress_fragment_two_pass.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: encode.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: entropy_encode.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: histogram.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: literal_cost.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: memory.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: metablock.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: static_dict.c:BROTLI_UNALIGNED_STORE64LE Unexecuted instantiation: utf8_util.c:BROTLI_UNALIGNED_STORE64LE |
123 | | |
124 | | #else /* BROTLI_LITTLE_ENDIAN */ |
125 | | |
126 | | static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void *p) { |
127 | | const uint8_t* in = (const uint8_t*)p; |
128 | | uint64_t value = (uint64_t)(in[0]); |
129 | | value |= (uint64_t)(in[1]) << 8; |
130 | | value |= (uint64_t)(in[2]) << 16; |
131 | | value |= (uint64_t)(in[3]) << 24; |
132 | | value |= (uint64_t)(in[4]) << 32; |
133 | | value |= (uint64_t)(in[5]) << 40; |
134 | | value |= (uint64_t)(in[6]) << 48; |
135 | | value |= (uint64_t)(in[7]) << 56; |
136 | | return value; |
137 | | } |
138 | | |
139 | | static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void *p, uint64_t v) { |
140 | | uint8_t* out = (uint8_t*)p; |
141 | | out[0] = (uint8_t)v; |
142 | | out[1] = (uint8_t)(v >> 8); |
143 | | out[2] = (uint8_t)(v >> 16); |
144 | | out[3] = (uint8_t)(v >> 24); |
145 | | out[4] = (uint8_t)(v >> 32); |
146 | | out[5] = (uint8_t)(v >> 40); |
147 | | out[6] = (uint8_t)(v >> 48); |
148 | | out[7] = (uint8_t)(v >> 56); |
149 | | } |
150 | | |
151 | | #endif /* BROTLI_LITTLE_ENDIAN */ |
152 | | |
153 | | #endif |
154 | | |
155 | | #define TEMPLATE_(T) \ |
156 | 0 | static BROTLI_INLINE T brotli_min_ ## T (T a, T b) { return a < b ? a : b; } \ Unexecuted instantiation: backward_references.c:brotli_min_size_t Unexecuted instantiation: backward_references.c:brotli_min_double Unexecuted instantiation: backward_references.c:brotli_min_float Unexecuted instantiation: backward_references.c:brotli_min_int Unexecuted instantiation: backward_references.c:brotli_min_uint32_t Unexecuted instantiation: backward_references.c:brotli_min_uint8_t Unexecuted instantiation: backward_references_hq.c:brotli_min_size_t Unexecuted instantiation: backward_references_hq.c:brotli_min_float Unexecuted instantiation: backward_references_hq.c:brotli_min_double Unexecuted instantiation: backward_references_hq.c:brotli_min_int Unexecuted instantiation: backward_references_hq.c:brotli_min_uint32_t Unexecuted instantiation: backward_references_hq.c:brotli_min_uint8_t Unexecuted instantiation: bit_cost.c:brotli_min_double Unexecuted instantiation: bit_cost.c:brotli_min_float Unexecuted instantiation: bit_cost.c:brotli_min_int Unexecuted instantiation: bit_cost.c:brotli_min_size_t Unexecuted instantiation: bit_cost.c:brotli_min_uint32_t Unexecuted instantiation: bit_cost.c:brotli_min_uint8_t Unexecuted instantiation: block_splitter.c:brotli_min_size_t Unexecuted instantiation: block_splitter.c:brotli_min_double Unexecuted instantiation: block_splitter.c:brotli_min_float Unexecuted instantiation: block_splitter.c:brotli_min_int Unexecuted instantiation: block_splitter.c:brotli_min_uint32_t Unexecuted instantiation: block_splitter.c:brotli_min_uint8_t Unexecuted instantiation: brotli_bit_stream.c:brotli_min_uint32_t Unexecuted instantiation: brotli_bit_stream.c:brotli_min_double Unexecuted instantiation: brotli_bit_stream.c:brotli_min_float Unexecuted instantiation: brotli_bit_stream.c:brotli_min_int Unexecuted instantiation: brotli_bit_stream.c:brotli_min_size_t Unexecuted instantiation: brotli_bit_stream.c:brotli_min_uint8_t Unexecuted instantiation: cluster.c:brotli_min_size_t Unexecuted instantiation: cluster.c:brotli_min_double Unexecuted instantiation: cluster.c:brotli_min_float Unexecuted instantiation: cluster.c:brotli_min_int Unexecuted instantiation: cluster.c:brotli_min_uint32_t Unexecuted instantiation: cluster.c:brotli_min_uint8_t Unexecuted instantiation: compress_fragment.c:brotli_min_size_t Unexecuted instantiation: compress_fragment.c:brotli_min_uint32_t Unexecuted instantiation: compress_fragment.c:brotli_min_double Unexecuted instantiation: compress_fragment.c:brotli_min_float Unexecuted instantiation: compress_fragment.c:brotli_min_int Unexecuted instantiation: compress_fragment.c:brotli_min_uint8_t Unexecuted instantiation: compress_fragment_two_pass.c:brotli_min_size_t Unexecuted instantiation: compress_fragment_two_pass.c:brotli_min_double Unexecuted instantiation: compress_fragment_two_pass.c:brotli_min_float Unexecuted instantiation: compress_fragment_two_pass.c:brotli_min_int Unexecuted instantiation: compress_fragment_two_pass.c:brotli_min_uint32_t Unexecuted instantiation: compress_fragment_two_pass.c:brotli_min_uint8_t Unexecuted instantiation: encode.c:brotli_min_int Unexecuted instantiation: encode.c:brotli_min_uint32_t Unexecuted instantiation: encode.c:brotli_min_size_t Unexecuted instantiation: encode.c:brotli_min_double Unexecuted instantiation: encode.c:brotli_min_float Unexecuted instantiation: encode.c:brotli_min_uint8_t Unexecuted instantiation: entropy_encode.c:brotli_min_double Unexecuted instantiation: entropy_encode.c:brotli_min_float Unexecuted instantiation: entropy_encode.c:brotli_min_int Unexecuted instantiation: entropy_encode.c:brotli_min_size_t Unexecuted instantiation: entropy_encode.c:brotli_min_uint32_t Unexecuted instantiation: entropy_encode.c:brotli_min_uint8_t Unexecuted instantiation: histogram.c:brotli_min_double Unexecuted instantiation: histogram.c:brotli_min_float Unexecuted instantiation: histogram.c:brotli_min_int Unexecuted instantiation: histogram.c:brotli_min_size_t Unexecuted instantiation: histogram.c:brotli_min_uint32_t Unexecuted instantiation: histogram.c:brotli_min_uint8_t Unexecuted instantiation: literal_cost.c:brotli_min_size_t Unexecuted instantiation: literal_cost.c:brotli_min_double Unexecuted instantiation: literal_cost.c:brotli_min_float Unexecuted instantiation: literal_cost.c:brotli_min_int Unexecuted instantiation: literal_cost.c:brotli_min_uint32_t Unexecuted instantiation: literal_cost.c:brotli_min_uint8_t Unexecuted instantiation: memory.c:brotli_min_double Unexecuted instantiation: memory.c:brotli_min_float Unexecuted instantiation: memory.c:brotli_min_int Unexecuted instantiation: memory.c:brotli_min_size_t Unexecuted instantiation: memory.c:brotli_min_uint32_t Unexecuted instantiation: memory.c:brotli_min_uint8_t Unexecuted instantiation: metablock.c:brotli_min_size_t Unexecuted instantiation: metablock.c:brotli_min_double Unexecuted instantiation: metablock.c:brotli_min_float Unexecuted instantiation: metablock.c:brotli_min_int Unexecuted instantiation: metablock.c:brotli_min_uint32_t Unexecuted instantiation: metablock.c:brotli_min_uint8_t Unexecuted instantiation: static_dict.c:brotli_min_uint32_t Unexecuted instantiation: static_dict.c:brotli_min_size_t Unexecuted instantiation: static_dict.c:brotli_min_double Unexecuted instantiation: static_dict.c:brotli_min_float Unexecuted instantiation: static_dict.c:brotli_min_int Unexecuted instantiation: static_dict.c:brotli_min_uint8_t Unexecuted instantiation: utf8_util.c:brotli_min_double Unexecuted instantiation: utf8_util.c:brotli_min_float Unexecuted instantiation: utf8_util.c:brotli_min_int Unexecuted instantiation: utf8_util.c:brotli_min_size_t Unexecuted instantiation: utf8_util.c:brotli_min_uint32_t Unexecuted instantiation: utf8_util.c:brotli_min_uint8_t |
157 | 0 | static BROTLI_INLINE T brotli_max_ ## T (T a, T b) { return a > b ? a : b; } Unexecuted instantiation: backward_references.c:brotli_max_size_t Unexecuted instantiation: backward_references.c:brotli_max_double Unexecuted instantiation: backward_references.c:brotli_max_float Unexecuted instantiation: backward_references.c:brotli_max_int Unexecuted instantiation: backward_references.c:brotli_max_uint32_t Unexecuted instantiation: backward_references.c:brotli_max_uint8_t Unexecuted instantiation: backward_references_hq.c:brotli_max_size_t Unexecuted instantiation: backward_references_hq.c:brotli_max_double Unexecuted instantiation: backward_references_hq.c:brotli_max_float Unexecuted instantiation: backward_references_hq.c:brotli_max_int Unexecuted instantiation: backward_references_hq.c:brotli_max_uint32_t Unexecuted instantiation: backward_references_hq.c:brotli_max_uint8_t Unexecuted instantiation: bit_cost.c:brotli_max_uint32_t Unexecuted instantiation: bit_cost.c:brotli_max_double Unexecuted instantiation: bit_cost.c:brotli_max_float Unexecuted instantiation: bit_cost.c:brotli_max_int Unexecuted instantiation: bit_cost.c:brotli_max_size_t Unexecuted instantiation: bit_cost.c:brotli_max_uint8_t Unexecuted instantiation: block_splitter.c:brotli_max_uint8_t Unexecuted instantiation: block_splitter.c:brotli_max_double Unexecuted instantiation: block_splitter.c:brotli_max_float Unexecuted instantiation: block_splitter.c:brotli_max_int Unexecuted instantiation: block_splitter.c:brotli_max_size_t Unexecuted instantiation: block_splitter.c:brotli_max_uint32_t Unexecuted instantiation: brotli_bit_stream.c:brotli_max_uint32_t Unexecuted instantiation: brotli_bit_stream.c:brotli_max_double Unexecuted instantiation: brotli_bit_stream.c:brotli_max_float Unexecuted instantiation: brotli_bit_stream.c:brotli_max_int Unexecuted instantiation: brotli_bit_stream.c:brotli_max_size_t Unexecuted instantiation: brotli_bit_stream.c:brotli_max_uint8_t Unexecuted instantiation: cluster.c:brotli_max_double Unexecuted instantiation: cluster.c:brotli_max_float Unexecuted instantiation: cluster.c:brotli_max_int Unexecuted instantiation: cluster.c:brotli_max_size_t Unexecuted instantiation: cluster.c:brotli_max_uint32_t Unexecuted instantiation: cluster.c:brotli_max_uint8_t Unexecuted instantiation: compress_fragment.c:brotli_max_double Unexecuted instantiation: compress_fragment.c:brotli_max_float Unexecuted instantiation: compress_fragment.c:brotli_max_int Unexecuted instantiation: compress_fragment.c:brotli_max_size_t Unexecuted instantiation: compress_fragment.c:brotli_max_uint32_t Unexecuted instantiation: compress_fragment.c:brotli_max_uint8_t Unexecuted instantiation: compress_fragment_two_pass.c:brotli_max_double Unexecuted instantiation: compress_fragment_two_pass.c:brotli_max_float Unexecuted instantiation: compress_fragment_two_pass.c:brotli_max_int Unexecuted instantiation: compress_fragment_two_pass.c:brotli_max_size_t Unexecuted instantiation: compress_fragment_two_pass.c:brotli_max_uint32_t Unexecuted instantiation: compress_fragment_two_pass.c:brotli_max_uint8_t Unexecuted instantiation: encode.c:brotli_max_int Unexecuted instantiation: encode.c:brotli_max_size_t Unexecuted instantiation: encode.c:brotli_max_double Unexecuted instantiation: encode.c:brotli_max_float Unexecuted instantiation: encode.c:brotli_max_uint32_t Unexecuted instantiation: encode.c:brotli_max_uint8_t Unexecuted instantiation: entropy_encode.c:brotli_max_uint32_t Unexecuted instantiation: entropy_encode.c:brotli_max_double Unexecuted instantiation: entropy_encode.c:brotli_max_float Unexecuted instantiation: entropy_encode.c:brotli_max_int Unexecuted instantiation: entropy_encode.c:brotli_max_size_t Unexecuted instantiation: entropy_encode.c:brotli_max_uint8_t Unexecuted instantiation: histogram.c:brotli_max_double Unexecuted instantiation: histogram.c:brotli_max_float Unexecuted instantiation: histogram.c:brotli_max_int Unexecuted instantiation: histogram.c:brotli_max_size_t Unexecuted instantiation: histogram.c:brotli_max_uint32_t Unexecuted instantiation: histogram.c:brotli_max_uint8_t Unexecuted instantiation: literal_cost.c:brotli_max_double Unexecuted instantiation: literal_cost.c:brotli_max_float Unexecuted instantiation: literal_cost.c:brotli_max_int Unexecuted instantiation: literal_cost.c:brotli_max_size_t Unexecuted instantiation: literal_cost.c:brotli_max_uint32_t Unexecuted instantiation: literal_cost.c:brotli_max_uint8_t Unexecuted instantiation: memory.c:brotli_max_double Unexecuted instantiation: memory.c:brotli_max_float Unexecuted instantiation: memory.c:brotli_max_int Unexecuted instantiation: memory.c:brotli_max_size_t Unexecuted instantiation: memory.c:brotli_max_uint32_t Unexecuted instantiation: memory.c:brotli_max_uint8_t Unexecuted instantiation: metablock.c:brotli_max_size_t Unexecuted instantiation: metablock.c:brotli_max_double Unexecuted instantiation: metablock.c:brotli_max_float Unexecuted instantiation: metablock.c:brotli_max_int Unexecuted instantiation: metablock.c:brotli_max_uint32_t Unexecuted instantiation: metablock.c:brotli_max_uint8_t Unexecuted instantiation: static_dict.c:brotli_max_size_t Unexecuted instantiation: static_dict.c:brotli_max_double Unexecuted instantiation: static_dict.c:brotli_max_float Unexecuted instantiation: static_dict.c:brotli_max_int Unexecuted instantiation: static_dict.c:brotli_max_uint32_t Unexecuted instantiation: static_dict.c:brotli_max_uint8_t Unexecuted instantiation: utf8_util.c:brotli_max_double Unexecuted instantiation: utf8_util.c:brotli_max_float Unexecuted instantiation: utf8_util.c:brotli_max_int Unexecuted instantiation: utf8_util.c:brotli_max_size_t Unexecuted instantiation: utf8_util.c:brotli_max_uint32_t Unexecuted instantiation: utf8_util.c:brotli_max_uint8_t |
158 | | TEMPLATE_(double) TEMPLATE_(float) TEMPLATE_(int) |
159 | | TEMPLATE_(size_t) TEMPLATE_(uint32_t) TEMPLATE_(uint8_t) |
160 | | #undef TEMPLATE_ |
161 | 0 | #define BROTLI_MIN(T, A, B) (brotli_min_ ## T((A), (B))) |
162 | 0 | #define BROTLI_MAX(T, A, B) (brotli_max_ ## T((A), (B))) |
163 | | |
164 | 0 | #define BROTLI_SWAP(T, A, I, J) { \ |
165 | 0 | T __brotli_swap_tmp = (A)[(I)]; \ |
166 | 0 | (A)[(I)] = (A)[(J)]; \ |
167 | 0 | (A)[(J)] = __brotli_swap_tmp; \ |
168 | 0 | } |
169 | | |
170 | | /* |
171 | | Dynamically grows array capacity to at least the requested size |
172 | | M: MemoryManager |
173 | | T: data type |
174 | | A: array |
175 | | C: capacity |
176 | | R: requested size |
177 | | */ |
178 | 0 | #define BROTLI_ENSURE_CAPACITY(M, T, A, C, R) { \ |
179 | 0 | if (C < (R)) { \ |
180 | 0 | size_t _new_size = (C == 0) ? (R) : C; \ |
181 | 0 | T* new_array; \ |
182 | 0 | while (_new_size < (R)) _new_size *= 2; \ |
183 | 0 | new_array = BROTLI_ALLOC((M), T, _new_size); \ |
184 | 0 | if (!BROTLI_IS_OOM(M) && C != 0) \ |
185 | 0 | memcpy(new_array, A, C * sizeof(T)); \ |
186 | 0 | BROTLI_FREE((M), A); \ |
187 | 0 | A = new_array; \ |
188 | 0 | C = _new_size; \ |
189 | 0 | } \ |
190 | 0 | } |
191 | | |
192 | | #endif /* BROTLI_ENC_PORT_H_ */ |