Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/modules/brotli/common/platform.h
Line
Count
Source (jump to first uncovered line)
1
/* Copyright 2016 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 compiler / platform specific features and build options.
8
9
   Build options are:
10
    * BROTLI_BUILD_32_BIT disables 64-bit optimizations
11
    * BROTLI_BUILD_64_BIT forces to use 64-bit optimizations
12
    * BROTLI_BUILD_BIG_ENDIAN forces to use big-endian optimizations
13
    * BROTLI_BUILD_ENDIAN_NEUTRAL disables endian-aware optimizations
14
    * BROTLI_BUILD_LITTLE_ENDIAN forces to use little-endian optimizations
15
    * BROTLI_BUILD_PORTABLE disables dangerous optimizations, like unaligned
16
      read and overlapping memcpy; this reduces decompression speed by 5%
17
    * BROTLI_BUILD_NO_RBIT disables "rbit" optimization for ARM CPUs
18
    * BROTLI_DEBUG dumps file name and line number when decoder detects stream
19
      or memory error
20
    * BROTLI_ENABLE_LOG enables asserts and dumps various state information
21
*/
22
23
#ifndef BROTLI_COMMON_PLATFORM_H_
24
#define BROTLI_COMMON_PLATFORM_H_
25
26
#include <string.h>  /* memcpy */
27
#include <stdlib.h>  /* malloc, free */
28
29
#include <brotli/port.h>
30
#include <brotli/types.h>
31
32
#if defined(OS_LINUX) || defined(OS_CYGWIN)
33
#include <endian.h>
34
#elif defined(OS_FREEBSD)
35
#include <machine/endian.h>
36
#elif defined(OS_MACOSX)
37
#include <machine/endian.h>
38
/* Let's try and follow the Linux convention */
39
#define BROTLI_X_BYTE_ORDER BYTE_ORDER
40
#define BROTLI_X_LITTLE_ENDIAN LITTLE_ENDIAN
41
#define BROTLI_X_BIG_ENDIAN BIG_ENDIAN
42
#endif
43
44
#if defined(BROTLI_ENABLE_LOG) || defined(BROTLI_DEBUG)
45
#include <assert.h>
46
#include <stdio.h>
47
#endif
48
49
/* The following macros were borrowed from https://github.com/nemequ/hedley
50
 * with permission of original author - Evan Nemerson <evan@nemerson.com> */
51
52
/* >>> >>> >>> hedley macros */
53
54
/* Define "BROTLI_PREDICT_TRUE" and "BROTLI_PREDICT_FALSE" macros for capable
55
   compilers.
56
57
To apply compiler hint, enclose the branching condition into macros, like this:
58
59
  if (BROTLI_PREDICT_TRUE(zero == 0)) {
60
    // main execution path
61
  } else {
62
    // compiler should place this code outside of main execution path
63
  }
64
65
OR:
66
67
  if (BROTLI_PREDICT_FALSE(something_rare_or_unexpected_happens)) {
68
    // compiler should place this code outside of main execution path
69
  }
70
71
*/
72
#if BROTLI_GNUC_HAS_BUILTIN(__builtin_expect, 3, 0, 0) || \
73
    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||               \
74
    BROTLI_SUNPRO_VERSION_CHECK(5, 12, 0) ||              \
75
    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                  \
76
    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                 \
77
    BROTLI_TI_VERSION_CHECK(7, 3, 0) ||                   \
78
    BROTLI_TINYC_VERSION_CHECK(0, 9, 27)
79
0
#define BROTLI_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
80
0
#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
81
#else
82
#define BROTLI_PREDICT_FALSE(x) (x)
83
#define BROTLI_PREDICT_TRUE(x) (x)
84
#endif
85
86
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
87
    !defined(__cplusplus)
88
#define BROTLI_RESTRICT restrict
89
#elif BROTLI_GNUC_VERSION_CHECK(3, 1, 0) ||                         \
90
    BROTLI_MSVC_VERSION_CHECK(14, 0, 0) ||                          \
91
    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                         \
92
    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                            \
93
    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                           \
94
    BROTLI_PGI_VERSION_CHECK(17, 10, 0) ||                          \
95
    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                             \
96
    BROTLI_IAR_VERSION_CHECK(8, 0, 0) ||                            \
97
    (BROTLI_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus))
98
#define BROTLI_RESTRICT __restrict
99
#elif BROTLI_SUNPRO_VERSION_CHECK(5, 3, 0) && !defined(__cplusplus)
100
#define BROTLI_RESTRICT _Restrict
101
#else
102
#define BROTLI_RESTRICT
103
#endif
104
105
#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
106
    (defined(__cplusplus) && (__cplusplus >= 199711L))
107
#define BROTLI_MAYBE_INLINE inline
108
#elif defined(__GNUC_STDC_INLINE__) || defined(__GNUC_GNU_INLINE__) || \
109
    BROTLI_ARM_VERSION_CHECK(6, 2, 0)
110
#define BROTLI_MAYBE_INLINE __inline__
111
#elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0) || \
112
    BROTLI_ARM_VERSION_CHECK(4, 1, 0) || BROTLI_TI_VERSION_CHECK(8, 0, 0)
113
#define BROTLI_MAYBE_INLINE __inline
114
#else
115
#define BROTLI_MAYBE_INLINE
116
#endif
117
118
#if BROTLI_GNUC_HAS_ATTRIBUTE(always_inline, 4, 0, 0) ||                       \
119
    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                                    \
120
    BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) ||                                   \
121
    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                                       \
122
    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                                      \
123
    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                                        \
124
    (BROTLI_TI_VERSION_CHECK(7, 3, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))
125
#define BROTLI_INLINE BROTLI_MAYBE_INLINE __attribute__((__always_inline__))
126
#elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
127
#define BROTLI_INLINE BROTLI_MAYBE_INLINE __forceinline
128
#elif BROTLI_TI_VERSION_CHECK(7, 0, 0) && defined(__cplusplus)
129
#define BROTLI_INLINE BROTLI_MAYBE_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
130
#elif BROTLI_IAR_VERSION_CHECK(8, 0, 0)
131
#define BROTLI_INLINE BROTLI_MAYBE_INLINE _Pragma("inline=forced")
132
#else
133
#define BROTLI_INLINE BROTLI_MAYBE_INLINE
134
#endif
135
136
#if BROTLI_GNUC_HAS_ATTRIBUTE(noinline, 4, 0, 0) ||                            \
137
    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                                    \
138
    BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) ||                                   \
139
    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                                       \
140
    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                                      \
141
    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                                        \
142
    (BROTLI_TI_VERSION_CHECK(7, 3, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))
143
#define BROTLI_NOINLINE __attribute__((__noinline__))
144
#elif BROTLI_MSVC_VERSION_CHECK(13, 10, 0)
145
#define BROTLI_NOINLINE __declspec(noinline)
146
#elif BROTLI_PGI_VERSION_CHECK(10, 2, 0)
147
#define BROTLI_NOINLINE _Pragma("noinline")
148
#elif BROTLI_TI_VERSION_CHECK(6, 0, 0) && defined(__cplusplus)
149
#define BROTLI_NOINLINE _Pragma("FUNC_CANNOT_INLINE;")
150
#elif BROTLI_IAR_VERSION_CHECK(8, 0, 0)
151
#define BROTLI_NOINLINE _Pragma("inline=never")
152
#else
153
#define BROTLI_NOINLINE
154
#endif
155
156
/* BROTLI_INTERNAL could be defined to override visibility, e.g. for tests. */
157
#if !defined(BROTLI_INTERNAL)
158
#if defined(_WIN32) || defined(__CYGWIN__)
159
#define BROTLI_INTERNAL
160
#elif BROTLI_GNUC_VERSION_CHECK(3, 3, 0) ||                         \
161
    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                             \
162
    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                         \
163
    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                            \
164
    BROTLI_IBM_VERSION_CHECK(13, 1, 0) ||                           \
165
    BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) ||                        \
166
    (BROTLI_TI_VERSION_CHECK(7, 3, 0) &&                            \
167
     defined(__TI_GNU_ATTRIBUTE_SUPPORT__) && defined(__TI_EABI__))
168
#define BROTLI_INTERNAL __attribute__ ((visibility ("hidden")))
169
#else
170
#define BROTLI_INTERNAL
171
#endif
172
#endif
173
174
/* <<< <<< <<< end of hedley macros. */
175
176
#if BROTLI_GNUC_HAS_ATTRIBUTE(unused, 2, 7, 0) || \
177
    BROTLI_INTEL_VERSION_CHECK(16, 0, 0)
178
#define BROTLI_UNUSED_FUNCTION static BROTLI_INLINE __attribute__ ((unused))
179
#else
180
#define BROTLI_UNUSED_FUNCTION static BROTLI_INLINE
181
#endif
182
183
#if (defined(__ARM_ARCH) && (__ARM_ARCH == 7)) || \
184
    (defined(M_ARM) && (M_ARM == 7))
185
#define BROTLI_TARGET_ARMV7
186
#endif  /* ARMv7 */
187
188
#if (defined(__ARM_ARCH) && (__ARM_ARCH == 8)) || \
189
    defined(__aarch64__) || defined(__ARM64_ARCH_8__)
190
#define BROTLI_TARGET_ARMV8
191
#endif  /* ARMv8 */
192
193
#if defined(__i386) || defined(_M_IX86)
194
#define BROTLI_TARGET_X86
195
#endif
196
197
#if defined(__x86_64__) || defined(_M_X64)
198
#define BROTLI_TARGET_X64
199
#endif
200
201
#if defined(__PPC64__)
202
#define BROTLI_TARGET_POWERPC64
203
#endif
204
205
#if defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64
206
#define BROTLI_TARGET_RISCV64
207
#endif
208
209
#if defined(BROTLI_BUILD_64_BIT)
210
#define BROTLI_64_BITS 1
211
#elif defined(BROTLI_BUILD_32_BIT)
212
#define BROTLI_64_BITS 0
213
#elif defined(BROTLI_TARGET_X64) || defined(BROTLI_TARGET_ARMV8) || \
214
    defined(BROTLI_TARGET_POWERPC64) || defined(BROTLI_TARGET_RISCV64)
215
0
#define BROTLI_64_BITS 1
216
#else
217
#define BROTLI_64_BITS 0
218
#endif
219
220
#if (BROTLI_64_BITS)
221
0
#define brotli_reg_t uint64_t
222
#else
223
#define brotli_reg_t uint32_t
224
#endif
225
226
#if defined(BROTLI_BUILD_BIG_ENDIAN)
227
#define BROTLI_BIG_ENDIAN 1
228
#elif defined(BROTLI_BUILD_LITTLE_ENDIAN)
229
#define BROTLI_LITTLE_ENDIAN 1
230
#elif defined(BROTLI_BUILD_ENDIAN_NEUTRAL)
231
/* Just break elif chain. */
232
#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
233
#define BROTLI_LITTLE_ENDIAN 1
234
#elif defined(_WIN32) || defined(BROTLI_TARGET_X64)
235
/* Win32 & x64 can currently always be assumed to be little endian */
236
#define BROTLI_LITTLE_ENDIAN 1
237
#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
238
#define BROTLI_BIG_ENDIAN 1
239
#elif defined(BROTLI_X_BYTE_ORDER)
240
#if BROTLI_X_BYTE_ORDER == BROTLI_X_LITTLE_ENDIAN
241
#define BROTLI_LITTLE_ENDIAN 1
242
#elif BROTLI_X_BYTE_ORDER == BROTLI_X_BIG_ENDIAN
243
#define BROTLI_BIG_ENDIAN 1
244
#endif
245
#endif  /* BROTLI_X_BYTE_ORDER */
246
247
#if !defined(BROTLI_LITTLE_ENDIAN)
248
#define BROTLI_LITTLE_ENDIAN 0
249
#endif
250
251
#if !defined(BROTLI_BIG_ENDIAN)
252
#define BROTLI_BIG_ENDIAN 0
253
#endif
254
255
#if defined(BROTLI_X_BYTE_ORDER)
256
#undef BROTLI_X_BYTE_ORDER
257
#undef BROTLI_X_LITTLE_ENDIAN
258
#undef BROTLI_X_BIG_ENDIAN
259
#endif
260
261
#if defined(BROTLI_BUILD_PORTABLE)
262
0
#define BROTLI_ALIGNED_READ (!!1)
263
#elif defined(BROTLI_TARGET_X86) || defined(BROTLI_TARGET_X64) || \
264
    defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8) || \
265
    defined(BROTLI_TARGET_RISCV64)
266
/* Allow unaligned read only for white-listed CPUs. */
267
#define BROTLI_ALIGNED_READ (!!0)
268
#else
269
#define BROTLI_ALIGNED_READ (!!1)
270
#endif
271
272
#if BROTLI_ALIGNED_READ
273
/* Portable unaligned memory access: read / write values via memcpy. */
274
0
static BROTLI_INLINE uint16_t BrotliUnalignedRead16(const void* p) {
275
0
  uint16_t t;
276
0
  memcpy(&t, p, sizeof t);
277
0
  return t;
278
0
}
279
0
static BROTLI_INLINE uint32_t BrotliUnalignedRead32(const void* p) {
280
0
  uint32_t t;
281
0
  memcpy(&t, p, sizeof t);
282
0
  return t;
283
0
}
284
0
static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
285
0
  uint64_t t;
286
0
  memcpy(&t, p, sizeof t);
287
0
  return t;
288
0
}
289
0
static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
290
0
  memcpy(p, &v, sizeof v);
291
0
}
292
#else  /* BROTLI_ALIGNED_READ */
293
/* Unaligned memory access is allowed: just cast pointer to requested type. */
294
0
static BROTLI_INLINE uint16_t BrotliUnalignedRead16(const void* p) {
295
0
  return *(const uint16_t*)p;
296
0
}
Unexecuted instantiation: Unified_cpp_converters0.cpp:BrotliUnalignedRead16(void const*)
Unexecuted instantiation: nsNetModule.cpp:BrotliUnalignedRead16(void const*)
297
0
static BROTLI_INLINE uint32_t BrotliUnalignedRead32(const void* p) {
298
0
  return *(const uint32_t*)p;
299
0
}
Unexecuted instantiation: Unified_cpp_converters0.cpp:BrotliUnalignedRead32(void const*)
Unexecuted instantiation: nsNetModule.cpp:BrotliUnalignedRead32(void const*)
300
#if (BROTLI_64_BITS)
301
0
static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
302
0
  return *(const uint64_t*)p;
303
0
}
Unexecuted instantiation: Unified_cpp_converters0.cpp:BrotliUnalignedRead64(void const*)
Unexecuted instantiation: nsNetModule.cpp:BrotliUnalignedRead64(void const*)
304
0
static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
305
0
  *(uint64_t*)p = v;
306
0
}
Unexecuted instantiation: Unified_cpp_converters0.cpp:BrotliUnalignedWrite64(void*, unsigned long)
Unexecuted instantiation: nsNetModule.cpp:BrotliUnalignedWrite64(void*, unsigned long)
307
#else  /* BROTLI_64_BITS */
308
/* Avoid emitting LDRD / STRD, which require properly aligned address. */
309
static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
310
  const uint32_t* dwords = (const uint32_t*)p;
311
  return dwords[0] | ((uint64_t)dwords[1] << 32);
312
}
313
static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
314
  uint32_t* dwords = (uint32_t *)p;
315
  dwords[0] = (uint32_t)v;
316
  dwords[1] = (uint32_t)(v >> 32);
317
}
318
#endif  /* BROTLI_64_BITS */
319
#endif  /* BROTLI_ALIGNED_READ */
320
321
#if BROTLI_LITTLE_ENDIAN
322
/* Straight endianness. Just read / write values. */
323
#define BROTLI_UNALIGNED_LOAD16LE BrotliUnalignedRead16
324
0
#define BROTLI_UNALIGNED_LOAD32LE BrotliUnalignedRead32
325
0
#define BROTLI_UNALIGNED_LOAD64LE BrotliUnalignedRead64
326
#define BROTLI_UNALIGNED_STORE64LE BrotliUnalignedWrite64
327
#elif BROTLI_BIG_ENDIAN  /* BROTLI_LITTLE_ENDIAN */
328
/* Explain compiler to byte-swap values. */
329
#define BROTLI_BSWAP16_(V) ((uint16_t)( \
330
  (((V) & 0xFFU) << 8) | \
331
  (((V) >> 8) & 0xFFU)))
332
static BROTLI_INLINE uint16_t BROTLI_UNALIGNED_LOAD16LE(const void* p) {
333
  uint16_t value = BrotliUnalignedRead16(p);
334
  return BROTLI_BSWAP16_(value);
335
}
336
#define BROTLI_BSWAP32_(V) ( \
337
  (((V) & 0xFFU) << 24) | (((V) & 0xFF00U) << 8) | \
338
  (((V) >> 8) & 0xFF00U) | (((V) >> 24) & 0xFFU))
339
static BROTLI_INLINE uint32_t BROTLI_UNALIGNED_LOAD32LE(const void* p) {
340
  uint32_t value = BrotliUnalignedRead32(p);
341
  return BROTLI_BSWAP32_(value);
342
}
343
#define BROTLI_BSWAP64_(V) ( \
344
  (((V) & 0xFFU) << 56) | (((V) & 0xFF00U) << 40) | \
345
  (((V) & 0xFF0000U) << 24) | (((V) & 0xFF000000U) << 8) | \
346
  (((V) >> 8) & 0xFF000000U) | (((V) >> 24) & 0xFF0000U) | \
347
  (((V) >> 40) & 0xFF00U) | (((V) >> 56) & 0xFFU))
348
static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void* p) {
349
  uint64_t value = BrotliUnalignedRead64(p);
350
  return BROTLI_BSWAP64_(value);
351
}
352
static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void* p, uint64_t v) {
353
  uint64_t value = BROTLI_BSWAP64_(v);
354
  BrotliUnalignedWrite64(p, value);
355
}
356
#else  /* BROTLI_LITTLE_ENDIAN */
357
/* Read / store values byte-wise; hopefully compiler will understand. */
358
static BROTLI_INLINE uint16_t BROTLI_UNALIGNED_LOAD16LE(const void* p) {
359
  const uint8_t* in = (const uint8_t*)p;
360
  return (uint16_t)(in[0] | (in[1] << 8));
361
}
362
static BROTLI_INLINE uint32_t BROTLI_UNALIGNED_LOAD32LE(const void* p) {
363
  const uint8_t* in = (const uint8_t*)p;
364
  uint32_t value = (uint32_t)(in[0]);
365
  value |= (uint32_t)(in[1]) << 8;
366
  value |= (uint32_t)(in[2]) << 16;
367
  value |= (uint32_t)(in[3]) << 24;
368
  return value;
369
}
370
static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void* p) {
371
  const uint8_t* in = (const uint8_t*)p;
372
  uint64_t value = (uint64_t)(in[0]);
373
  value |= (uint64_t)(in[1]) << 8;
374
  value |= (uint64_t)(in[2]) << 16;
375
  value |= (uint64_t)(in[3]) << 24;
376
  value |= (uint64_t)(in[4]) << 32;
377
  value |= (uint64_t)(in[5]) << 40;
378
  value |= (uint64_t)(in[6]) << 48;
379
  value |= (uint64_t)(in[7]) << 56;
380
  return value;
381
}
382
static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void* p, uint64_t v) {
383
  uint8_t* out = (uint8_t*)p;
384
  out[0] = (uint8_t)v;
385
  out[1] = (uint8_t)(v >> 8);
386
  out[2] = (uint8_t)(v >> 16);
387
  out[3] = (uint8_t)(v >> 24);
388
  out[4] = (uint8_t)(v >> 32);
389
  out[5] = (uint8_t)(v >> 40);
390
  out[6] = (uint8_t)(v >> 48);
391
  out[7] = (uint8_t)(v >> 56);
392
}
393
#endif  /* BROTLI_LITTLE_ENDIAN */
394
395
/* BROTLI_IS_CONSTANT macros returns true for compile-time constants. */
396
#if BROTLI_GNUC_HAS_BUILTIN(__builtin_constant_p, 3, 0, 1) || \
397
    BROTLI_INTEL_VERSION_CHECK(16, 0, 0)
398
0
#define BROTLI_IS_CONSTANT(x) (!!__builtin_constant_p(x))
399
#else
400
#define BROTLI_IS_CONSTANT(x) (!!0)
401
#endif
402
403
#if defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8)
404
#define BROTLI_HAS_UBFX (!!1)
405
#else
406
0
#define BROTLI_HAS_UBFX (!!0)
407
#endif
408
409
#if defined(BROTLI_ENABLE_LOG)
410
#define BROTLI_DCHECK(x) assert(x)
411
#define BROTLI_LOG(x) printf x
412
#else
413
#define BROTLI_DCHECK(x)
414
#define BROTLI_LOG(x)
415
#endif
416
417
#if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG)
418
static BROTLI_INLINE void BrotliDump(const char* f, int l, const char* fn) {
419
  fprintf(stderr, "%s:%d (%s)\n", f, l, fn);
420
  fflush(stderr);
421
}
422
#define BROTLI_DUMP() BrotliDump(__FILE__, __LINE__, __FUNCTION__)
423
#else
424
0
#define BROTLI_DUMP() (void)(0)
425
#endif
426
427
/* TODO: add appropriate icc/sunpro/arm/ibm/ti checks. */
428
#if (BROTLI_GNUC_VERSION_CHECK(3, 0, 0) || defined(__llvm__)) && \
429
    !defined(BROTLI_BUILD_NO_RBIT)
430
#if defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8)
431
/* TODO: detect ARMv6T2 and enable this code for it. */
432
static BROTLI_INLINE brotli_reg_t BrotliRBit(brotli_reg_t input) {
433
  brotli_reg_t output;
434
  __asm__("rbit %0, %1\n" : "=r"(output) : "r"(input));
435
  return output;
436
}
437
#define BROTLI_RBIT(x) BrotliRBit(x)
438
#endif  /* armv7 / armv8 */
439
#endif  /* gcc || clang */
440
#if !defined(BROTLI_RBIT)
441
0
static BROTLI_INLINE void BrotliRBit(void) { /* Should break build if used. */ }
Unexecuted instantiation: Unified_cpp_converters0.cpp:BrotliRBit()
Unexecuted instantiation: nsNetModule.cpp:BrotliRBit()
Unexecuted instantiation: Unified_c_modules_brotli0.c:BrotliRBit
442
#endif  /* BROTLI_RBIT */
443
444
0
#define BROTLI_REPEAT(N, X) {     \
445
0
  if ((N & 1) != 0) {X;}          \
446
0
  if ((N & 2) != 0) {X; X;}       \
447
0
  if ((N & 4) != 0) {X; X; X; X;} \
448
0
}
449
450
0
#define BROTLI_UNUSED(X) (void)(X)
451
452
#define BROTLI_MIN_MAX(T)                                                      \
453
0
  static BROTLI_INLINE T brotli_min_ ## T (T a, T b) { return a < b ? a : b; } \
Unexecuted instantiation: Unified_cpp_converters0.cpp:brotli_min_double(double, double)
Unexecuted instantiation: Unified_cpp_converters0.cpp:brotli_min_float(float, float)
Unexecuted instantiation: Unified_cpp_converters0.cpp:brotli_min_int(int, int)
Unexecuted instantiation: Unified_cpp_converters0.cpp:brotli_min_size_t(unsigned long, unsigned long)
Unexecuted instantiation: Unified_cpp_converters0.cpp:brotli_min_uint32_t(unsigned int, unsigned int)
Unexecuted instantiation: Unified_cpp_converters0.cpp:brotli_min_uint8_t(unsigned char, unsigned char)
Unexecuted instantiation: nsNetModule.cpp:brotli_min_double(double, double)
Unexecuted instantiation: nsNetModule.cpp:brotli_min_float(float, float)
Unexecuted instantiation: nsNetModule.cpp:brotli_min_int(int, int)
Unexecuted instantiation: nsNetModule.cpp:brotli_min_size_t(unsigned long, unsigned long)
Unexecuted instantiation: nsNetModule.cpp:brotli_min_uint32_t(unsigned int, unsigned int)
Unexecuted instantiation: nsNetModule.cpp:brotli_min_uint8_t(unsigned char, unsigned char)
Unexecuted instantiation: Unified_c_modules_brotli0.c:brotli_min_double
Unexecuted instantiation: Unified_c_modules_brotli0.c:brotli_min_float
Unexecuted instantiation: Unified_c_modules_brotli0.c:brotli_min_int
Unexecuted instantiation: Unified_c_modules_brotli0.c:brotli_min_size_t
Unexecuted instantiation: Unified_c_modules_brotli0.c:brotli_min_uint32_t
Unexecuted instantiation: Unified_c_modules_brotli0.c:brotli_min_uint8_t
454
0
  static BROTLI_INLINE T brotli_max_ ## T (T a, T b) { return a > b ? a : b; }
Unexecuted instantiation: Unified_cpp_converters0.cpp:brotli_max_double(double, double)
Unexecuted instantiation: Unified_cpp_converters0.cpp:brotli_max_float(float, float)
Unexecuted instantiation: Unified_cpp_converters0.cpp:brotli_max_int(int, int)
Unexecuted instantiation: Unified_cpp_converters0.cpp:brotli_max_size_t(unsigned long, unsigned long)
Unexecuted instantiation: Unified_cpp_converters0.cpp:brotli_max_uint32_t(unsigned int, unsigned int)
Unexecuted instantiation: Unified_cpp_converters0.cpp:brotli_max_uint8_t(unsigned char, unsigned char)
Unexecuted instantiation: nsNetModule.cpp:brotli_max_double(double, double)
Unexecuted instantiation: nsNetModule.cpp:brotli_max_float(float, float)
Unexecuted instantiation: nsNetModule.cpp:brotli_max_int(int, int)
Unexecuted instantiation: nsNetModule.cpp:brotli_max_size_t(unsigned long, unsigned long)
Unexecuted instantiation: nsNetModule.cpp:brotli_max_uint32_t(unsigned int, unsigned int)
Unexecuted instantiation: nsNetModule.cpp:brotli_max_uint8_t(unsigned char, unsigned char)
Unexecuted instantiation: Unified_c_modules_brotli0.c:brotli_max_double
Unexecuted instantiation: Unified_c_modules_brotli0.c:brotli_max_float
Unexecuted instantiation: Unified_c_modules_brotli0.c:brotli_max_int
Unexecuted instantiation: Unified_c_modules_brotli0.c:brotli_max_size_t
Unexecuted instantiation: Unified_c_modules_brotli0.c:brotli_max_uint32_t
Unexecuted instantiation: Unified_c_modules_brotli0.c:brotli_max_uint8_t
455
BROTLI_MIN_MAX(double) BROTLI_MIN_MAX(float) BROTLI_MIN_MAX(int)
456
BROTLI_MIN_MAX(size_t) BROTLI_MIN_MAX(uint32_t) BROTLI_MIN_MAX(uint8_t)
457
#undef BROTLI_MIN_MAX
458
#define BROTLI_MIN(T, A, B) (brotli_min_ ## T((A), (B)))
459
#define BROTLI_MAX(T, A, B) (brotli_max_ ## T((A), (B)))
460
461
#define BROTLI_SWAP(T, A, I, J) { \
462
  T __brotli_swap_tmp = (A)[(I)]; \
463
  (A)[(I)] = (A)[(J)];            \
464
  (A)[(J)] = __brotli_swap_tmp;   \
465
}
466
467
/* Default brotli_alloc_func */
468
0
static void* BrotliDefaultAllocFunc(void* opaque, size_t size) {
469
0
  BROTLI_UNUSED(opaque);
470
0
  return malloc(size);
471
0
}
Unexecuted instantiation: Unified_cpp_converters0.cpp:BrotliDefaultAllocFunc(void*, unsigned long)
Unexecuted instantiation: nsNetModule.cpp:BrotliDefaultAllocFunc(void*, unsigned long)
Unexecuted instantiation: Unified_c_modules_brotli0.c:BrotliDefaultAllocFunc
472
473
/* Default brotli_free_func */
474
0
static void BrotliDefaultFreeFunc(void* opaque, void* address) {
475
0
  BROTLI_UNUSED(opaque);
476
0
  free(address);
477
0
}
Unexecuted instantiation: Unified_cpp_converters0.cpp:BrotliDefaultFreeFunc(void*, void*)
Unexecuted instantiation: nsNetModule.cpp:BrotliDefaultFreeFunc(void*, void*)
Unexecuted instantiation: Unified_c_modules_brotli0.c:BrotliDefaultFreeFunc
478
479
0
BROTLI_UNUSED_FUNCTION void BrotliSuppressUnusedFunctions(void) {
480
0
  BROTLI_UNUSED(&BrotliSuppressUnusedFunctions);
481
0
  BROTLI_UNUSED(&BrotliUnalignedRead16);
482
0
  BROTLI_UNUSED(&BrotliUnalignedRead32);
483
0
  BROTLI_UNUSED(&BrotliUnalignedRead64);
484
0
  BROTLI_UNUSED(&BrotliUnalignedWrite64);
485
0
  BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD16LE);
486
0
  BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD32LE);
487
0
  BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD64LE);
488
0
  BROTLI_UNUSED(&BROTLI_UNALIGNED_STORE64LE);
489
0
  BROTLI_UNUSED(&BrotliRBit);
490
0
  BROTLI_UNUSED(&brotli_min_double);
491
0
  BROTLI_UNUSED(&brotli_max_double);
492
0
  BROTLI_UNUSED(&brotli_min_float);
493
0
  BROTLI_UNUSED(&brotli_max_float);
494
0
  BROTLI_UNUSED(&brotli_min_int);
495
0
  BROTLI_UNUSED(&brotli_max_int);
496
0
  BROTLI_UNUSED(&brotli_min_size_t);
497
0
  BROTLI_UNUSED(&brotli_max_size_t);
498
0
  BROTLI_UNUSED(&brotli_min_uint32_t);
499
0
  BROTLI_UNUSED(&brotli_max_uint32_t);
500
0
  BROTLI_UNUSED(&brotli_min_uint8_t);
501
0
  BROTLI_UNUSED(&brotli_max_uint8_t);
502
0
  BROTLI_UNUSED(&BrotliDefaultAllocFunc);
503
0
  BROTLI_UNUSED(&BrotliDefaultFreeFunc);
504
0
#if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG)
505
0
  BROTLI_UNUSED(&BrotliDump);
506
0
#endif
507
0
}
Unexecuted instantiation: Unified_cpp_converters0.cpp:BrotliSuppressUnusedFunctions()
Unexecuted instantiation: nsNetModule.cpp:BrotliSuppressUnusedFunctions()
Unexecuted instantiation: Unified_c_modules_brotli0.c:BrotliSuppressUnusedFunctions
508
509
#endif  /* BROTLI_COMMON_PLATFORM_H_ */