| Index: third_party/brotli/dec/port.h
|
| diff --git a/third_party/brotli/dec/port.h b/third_party/brotli/dec/port.h
|
| index 30b5cac742d67b8bee6ac565290197f371206160..6b3d7352bdced90633e5a0fec278d4dc676f2304 100644
|
| --- a/third_party/brotli/dec/port.h
|
| +++ b/third_party/brotli/dec/port.h
|
| @@ -16,6 +16,7 @@
|
| features and attributes
|
| * BROTLI_BUILD_PORTABLE disables dangerous optimizations, like unaligned
|
| read and overlapping memcpy; this reduces decompression speed by 5%
|
| + * BROTLI_BUILD_NO_RBIT disables "rbit" optimization for ARM CPUs
|
| * BROTLI_DEBUG dumps file name and line number when decoder detects stream
|
| or memory error
|
| * BROTLI_ENABLE_LOG enables asserts and dumps various state information
|
| @@ -29,27 +30,16 @@
|
| #include <stdio.h>
|
| #endif
|
|
|
| -/* Compatibility with non-clang compilers. */
|
| -#ifndef __has_builtin
|
| -#define __has_builtin(x) 0
|
| -#endif
|
| -
|
| -#ifndef __has_attribute
|
| -#define __has_attribute(x) 0
|
| -#endif
|
| -
|
| -#ifndef __has_feature
|
| -#define __has_feature(x) 0
|
| -#endif
|
| +#include <brotli/port.h>
|
|
|
| #if defined(__arm__) || defined(__thumb__) || \
|
| - defined(_M_ARM) || defined(_M_ARMT)
|
| + defined(_M_ARM) || defined(_M_ARMT) || defined(__ARM64_ARCH_8__)
|
| #define BROTLI_TARGET_ARM
|
| -#if (defined(__ARM_ARCH) && (__ARM_ARCH >= 7)) || \
|
| - (defined(M_ARM) && (M_ARM >= 7))
|
| +#if (defined(__ARM_ARCH) && (__ARM_ARCH == 7)) || \
|
| + (defined(M_ARM) && (M_ARM == 7))
|
| #define BROTLI_TARGET_ARMV7
|
| #endif /* ARMv7 */
|
| -#if defined(__aarch64__)
|
| +#if defined(__aarch64__) || defined(__ARM64_ARCH_8__)
|
| #define BROTLI_TARGET_ARMV8
|
| #endif /* ARMv8 */
|
| #endif /* ARM */
|
| @@ -66,61 +56,16 @@
|
| #define BROTLI_TARGET_POWERPC64
|
| #endif
|
|
|
| -#if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
| -#define BROTLI_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
| -#else
|
| -#define BROTLI_GCC_VERSION 0
|
| -#endif
|
| -
|
| -#if defined(__ICC)
|
| -#define BROTLI_ICC_VERSION __ICC
|
| -#else
|
| -#define BROTLI_ICC_VERSION 0
|
| -#endif
|
| -
|
| -#if defined(BROTLI_BUILD_MODERN_COMPILER)
|
| -#define BROTLI_MODERN_COMPILER 1
|
| -#elif (BROTLI_GCC_VERSION > 300) || (BROTLI_ICC_VERSION >= 1600)
|
| -#define BROTLI_MODERN_COMPILER 1
|
| -#else
|
| -#define BROTLI_MODERN_COMPILER 0
|
| -#endif
|
| -
|
| #ifdef BROTLI_BUILD_PORTABLE
|
| #define BROTLI_ALIGNED_READ (!!1)
|
| #elif defined(BROTLI_TARGET_X86) || defined(BROTLI_TARGET_X64) || \
|
| defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8)
|
| -/* Allow unaligned read only for whitelisted CPUs. */
|
| +/* Allow unaligned read only for white-listed CPUs. */
|
| #define BROTLI_ALIGNED_READ (!!0)
|
| #else
|
| #define BROTLI_ALIGNED_READ (!!1)
|
| #endif
|
|
|
| -/* Define "PREDICT_TRUE" and "PREDICT_FALSE" macros for capable compilers.
|
| -
|
| -To apply compiler hint, enclose the branching condition into macros, like this:
|
| -
|
| - if (PREDICT_TRUE(zero == 0)) {
|
| - // main execution path
|
| - } else {
|
| - // compiler should place this code outside of main execution path
|
| - }
|
| -
|
| -OR:
|
| -
|
| - if (PREDICT_FALSE(something_rare_or_unexpected_happens)) {
|
| - // compiler should place this code outside of main execution path
|
| - }
|
| -
|
| -*/
|
| -#if BROTLI_MODERN_COMPILER || __has_builtin(__builtin_expect)
|
| -#define PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
|
| -#define PREDICT_FALSE(x) (__builtin_expect(x, 0))
|
| -#else
|
| -#define PREDICT_FALSE(x) (x)
|
| -#define PREDICT_TRUE(x) (x)
|
| -#endif
|
| -
|
| /* IS_CONSTANT macros returns true for compile-time constant expressions. */
|
| #if BROTLI_MODERN_COMPILER || __has_builtin(__builtin_constant_p)
|
| #define IS_CONSTANT(x) (!!__builtin_constant_p(x))
|
| @@ -128,33 +73,6 @@ OR:
|
| #define IS_CONSTANT(x) (!!0)
|
| #endif
|
|
|
| -#if BROTLI_MODERN_COMPILER || __has_attribute(always_inline)
|
| -#define ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline))
|
| -#else
|
| -#define ATTRIBUTE_ALWAYS_INLINE
|
| -#endif
|
| -
|
| -#if BROTLI_MODERN_COMPILER || __has_attribute(visibility)
|
| -#define ATTRIBUTE_VISIBILITY_HIDDEN __attribute__ ((visibility ("hidden")))
|
| -#else
|
| -#define ATTRIBUTE_VISIBILITY_HIDDEN
|
| -#endif
|
| -
|
| -#ifndef BROTLI_INTERNAL
|
| -#define BROTLI_INTERNAL ATTRIBUTE_VISIBILITY_HIDDEN
|
| -#endif
|
| -
|
| -#ifndef _MSC_VER
|
| -#if defined(__cplusplus) || !defined(__STRICT_ANSI__) || \
|
| - __STDC_VERSION__ >= 199901L
|
| -#define BROTLI_INLINE inline ATTRIBUTE_ALWAYS_INLINE
|
| -#else
|
| -#define BROTLI_INLINE
|
| -#endif
|
| -#else /* _MSC_VER */
|
| -#define BROTLI_INLINE __forceinline
|
| -#endif /* _MSC_VER */
|
| -
|
| #ifdef BROTLI_ENABLE_LOG
|
| #define BROTLI_DCHECK(x) assert(x)
|
| #define BROTLI_LOG(x) printf x
|
| @@ -164,7 +82,7 @@ OR:
|
| #endif
|
|
|
| #if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG)
|
| -static inline void BrotliDump(const char* f, int l, const char* fn) {
|
| +static BROTLI_INLINE void BrotliDump(const char* f, int l, const char* fn) {
|
| fprintf(stderr, "%s:%d (%s)\n", f, l, fn);
|
| fflush(stderr);
|
| }
|
| @@ -184,6 +102,12 @@ static inline void BrotliDump(const char* f, int l, const char* fn) {
|
| #define BROTLI_64_BITS 0
|
| #endif
|
|
|
| +#if (BROTLI_64_BITS)
|
| +#define reg_t uint64_t
|
| +#else
|
| +#define reg_t uint32_t
|
| +#endif
|
| +
|
| #if defined(BROTLI_BUILD_BIG_ENDIAN)
|
| #define BROTLI_LITTLE_ENDIAN 0
|
| #define BROTLI_BIG_ENDIAN 1
|
| @@ -209,22 +133,18 @@ static inline void BrotliDump(const char* f, int l, const char* fn) {
|
| #define BROTLI_LITTLE_ENDIAN 0
|
| #endif
|
|
|
| -#if BROTLI_MODERN_COMPILER || __has_attribute(noinline)
|
| -#define BROTLI_NOINLINE __attribute__((noinline))
|
| -#else
|
| -#define BROTLI_NOINLINE
|
| -#endif
|
| -
|
| #define BROTLI_REPEAT(N, X) { \
|
| if ((N & 1) != 0) {X;} \
|
| if ((N & 2) != 0) {X; X;} \
|
| if ((N & 4) != 0) {X; X; X; X;} \
|
| }
|
|
|
| -#if BROTLI_MODERN_COMPILER || defined(__llvm__)
|
| -#if defined(BROTLI_TARGET_ARMV7)
|
| -static BROTLI_INLINE unsigned BrotliRBit(unsigned input) {
|
| - unsigned output;
|
| +#if (BROTLI_MODERN_COMPILER || defined(__llvm__)) && \
|
| + !defined(BROTLI_BUILD_NO_RBIT)
|
| +#if defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8)
|
| +/* TODO: detect ARMv6T2 and enable this code for it. */
|
| +static BROTLI_INLINE reg_t BrotliRBit(reg_t input) {
|
| + reg_t output;
|
| __asm__("rbit %0, %1\n" : "=r"(output) : "r"(input));
|
| return output;
|
| }
|
| @@ -245,6 +165,4 @@ static BROTLI_INLINE unsigned BrotliRBit(unsigned input) {
|
| X = NULL; \
|
| }
|
|
|
| -#define BROTLI_UNUSED(X) (void)(X)
|
| -
|
| #endif /* BROTLI_DEC_PORT_H_ */
|
|
|