| Index: third_party/brotli/include/brotli/port.h
|
| diff --git a/third_party/brotli/dec/port.h b/third_party/brotli/include/brotli/port.h
|
| similarity index 24%
|
| copy from third_party/brotli/dec/port.h
|
| copy to third_party/brotli/include/brotli/port.h
|
| index 30b5cac742d67b8bee6ac565290197f371206160..da4461c5f2db654643200cc4fd4e4fd3319967c0 100644
|
| --- a/third_party/brotli/dec/port.h
|
| +++ b/third_party/brotli/include/brotli/port.h
|
| @@ -1,33 +1,13 @@
|
| -/* Copyright 2015 Google Inc. All Rights Reserved.
|
| +/* Copyright 2016 Google Inc. All Rights Reserved.
|
|
|
| Distributed under MIT license.
|
| See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
| */
|
|
|
| -/* Macros for compiler / platform specific features and build options.
|
| -
|
| - Build options are:
|
| - * BROTLI_BUILD_32_BIT disables 64-bit optimizations
|
| - * BROTLI_BUILD_64_BIT forces to use 64-bit optimizations
|
| - * BROTLI_BUILD_BIG_ENDIAN forces to use big-endian optimizations
|
| - * BROTLI_BUILD_ENDIAN_NEUTRAL disables endian-aware optimizations
|
| - * BROTLI_BUILD_LITTLE_ENDIAN forces to use little-endian optimizations
|
| - * BROTLI_BUILD_MODERN_COMPILER forces to use modern compilers built-ins,
|
| - features and attributes
|
| - * BROTLI_BUILD_PORTABLE disables dangerous optimizations, like unaligned
|
| - read and overlapping memcpy; this reduces decompression speed by 5%
|
| - * 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
|
| - */
|
| -
|
| -#ifndef BROTLI_DEC_PORT_H_
|
| -#define BROTLI_DEC_PORT_H_
|
| -
|
| -#if defined(BROTLI_ENABLE_LOG) || defined(BROTLI_DEBUG)
|
| -#include <assert.h>
|
| -#include <stdio.h>
|
| -#endif
|
| +/* Macros for compiler / platform specific features and build options. */
|
| +
|
| +#ifndef BROTLI_COMMON_PORT_H_
|
| +#define BROTLI_COMMON_PORT_H_
|
|
|
| /* Compatibility with non-clang compilers. */
|
| #ifndef __has_builtin
|
| @@ -42,30 +22,6 @@
|
| #define __has_feature(x) 0
|
| #endif
|
|
|
| -#if defined(__arm__) || defined(__thumb__) || \
|
| - defined(_M_ARM) || defined(_M_ARMT)
|
| -#define BROTLI_TARGET_ARM
|
| -#if (defined(__ARM_ARCH) && (__ARM_ARCH >= 7)) || \
|
| - (defined(M_ARM) && (M_ARM >= 7))
|
| -#define BROTLI_TARGET_ARMV7
|
| -#endif /* ARMv7 */
|
| -#if defined(__aarch64__)
|
| -#define BROTLI_TARGET_ARMV8
|
| -#endif /* ARMv8 */
|
| -#endif /* ARM */
|
| -
|
| -#if defined(__i386) || defined(_M_IX86)
|
| -#define BROTLI_TARGET_X86
|
| -#endif
|
| -
|
| -#if defined(__x86_64__) || defined(_M_X64)
|
| -#define BROTLI_TARGET_X64
|
| -#endif
|
| -
|
| -#if defined(__PPC64__)
|
| -#define BROTLI_TARGET_POWERPC64
|
| -#endif
|
| -
|
| #if defined(__GNUC__) && defined(__GNUC_MINOR__)
|
| #define BROTLI_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
|
| #else
|
| @@ -80,27 +36,18 @@
|
|
|
| #if defined(BROTLI_BUILD_MODERN_COMPILER)
|
| #define BROTLI_MODERN_COMPILER 1
|
| -#elif (BROTLI_GCC_VERSION > 300) || (BROTLI_ICC_VERSION >= 1600)
|
| +#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. */
|
| -#define BROTLI_ALIGNED_READ (!!0)
|
| -#else
|
| -#define BROTLI_ALIGNED_READ (!!1)
|
| -#endif
|
| -
|
| -/* Define "PREDICT_TRUE" and "PREDICT_FALSE" macros for capable compilers.
|
| +/* Define "BROTLI_PREDICT_TRUE" and "BROTLI_PREDICT_FALSE" macros for capable
|
| + compilers.
|
|
|
| To apply compiler hint, enclose the branching condition into macros, like this:
|
|
|
| - if (PREDICT_TRUE(zero == 0)) {
|
| + if (BROTLI_PREDICT_TRUE(zero == 0)) {
|
| // main execution path
|
| } else {
|
| // compiler should place this code outside of main execution path
|
| @@ -108,46 +55,64 @@ To apply compiler hint, enclose the branching condition into macros, like this:
|
|
|
| OR:
|
|
|
| - if (PREDICT_FALSE(something_rare_or_unexpected_happens)) {
|
| + if (BROTLI_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))
|
| +#define BROTLI_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
|
| +#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
|
| #else
|
| -#define IS_CONSTANT(x) (!!0)
|
| +#define BROTLI_PREDICT_FALSE(x) (x)
|
| +#define BROTLI_PREDICT_TRUE(x) (x)
|
| #endif
|
|
|
| #if BROTLI_MODERN_COMPILER || __has_attribute(always_inline)
|
| -#define ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline))
|
| +#define BROTLI_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline))
|
| #else
|
| -#define ATTRIBUTE_ALWAYS_INLINE
|
| +#define BROTLI_ATTRIBUTE_ALWAYS_INLINE
|
| #endif
|
|
|
| -#if BROTLI_MODERN_COMPILER || __has_attribute(visibility)
|
| -#define ATTRIBUTE_VISIBILITY_HIDDEN __attribute__ ((visibility ("hidden")))
|
| +#if defined(_WIN32) || defined(__CYGWIN__)
|
| +#define BROTLI_ATTRIBUTE_VISIBILITY_HIDDEN
|
| +#elif BROTLI_MODERN_COMPILER || __has_attribute(visibility)
|
| +#define BROTLI_ATTRIBUTE_VISIBILITY_HIDDEN \
|
| + __attribute__ ((visibility ("hidden")))
|
| #else
|
| -#define ATTRIBUTE_VISIBILITY_HIDDEN
|
| +#define BROTLI_ATTRIBUTE_VISIBILITY_HIDDEN
|
| #endif
|
|
|
| #ifndef BROTLI_INTERNAL
|
| -#define BROTLI_INTERNAL ATTRIBUTE_VISIBILITY_HIDDEN
|
| +#define BROTLI_INTERNAL BROTLI_ATTRIBUTE_VISIBILITY_HIDDEN
|
| +#endif
|
| +
|
| +#if defined(BROTLI_SHARED_COMPILATION) && defined(_WIN32)
|
| +#if defined(BROTLICOMMON_SHARED_COMPILATION)
|
| +#define BROTLI_COMMON_API __declspec(dllexport)
|
| +#else
|
| +#define BROTLI_COMMON_API __declspec(dllimport)
|
| +#endif /* BROTLICOMMON_SHARED_COMPILATION */
|
| +#if defined(BROTLIDEC_SHARED_COMPILATION)
|
| +#define BROTLI_DEC_API __declspec(dllexport)
|
| +#else
|
| +#define BROTLI_DEC_API __declspec(dllimport)
|
| +#endif /* BROTLIDEC_SHARED_COMPILATION */
|
| +#if defined(BROTLIENC_SHARED_COMPILATION)
|
| +#define BROTLI_ENC_API __declspec(dllexport)
|
| +#else
|
| +#define BROTLI_ENC_API __declspec(dllimport)
|
| +#endif /* BROTLIENC_SHARED_COMPILATION */
|
| +#else /* BROTLI_SHARED_COMPILATION && _WIN32 */
|
| +#define BROTLI_COMMON_API
|
| +#define BROTLI_DEC_API
|
| +#define BROTLI_ENC_API
|
| #endif
|
|
|
| #ifndef _MSC_VER
|
| #if defined(__cplusplus) || !defined(__STRICT_ANSI__) || \
|
| - __STDC_VERSION__ >= 199901L
|
| -#define BROTLI_INLINE inline ATTRIBUTE_ALWAYS_INLINE
|
| + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
|
| +#define BROTLI_INLINE inline BROTLI_ATTRIBUTE_ALWAYS_INLINE
|
| #else
|
| #define BROTLI_INLINE
|
| #endif
|
| @@ -155,58 +120,13 @@ OR:
|
| #define BROTLI_INLINE __forceinline
|
| #endif /* _MSC_VER */
|
|
|
| -#ifdef BROTLI_ENABLE_LOG
|
| -#define BROTLI_DCHECK(x) assert(x)
|
| -#define BROTLI_LOG(x) printf x
|
| -#else
|
| -#define BROTLI_DCHECK(x)
|
| -#define BROTLI_LOG(x)
|
| -#endif
|
| -
|
| -#if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG)
|
| -static inline void BrotliDump(const char* f, int l, const char* fn) {
|
| - fprintf(stderr, "%s:%d (%s)\n", f, l, fn);
|
| - fflush(stderr);
|
| -}
|
| -#define BROTLI_DUMP() BrotliDump(__FILE__, __LINE__, __FUNCTION__)
|
| -#else
|
| -#define BROTLI_DUMP() (void)(0)
|
| -#endif
|
| -
|
| -#if defined(BROTLI_BUILD_64_BIT)
|
| -#define BROTLI_64_BITS 1
|
| -#elif defined(BROTLI_BUILD_32_BIT)
|
| -#define BROTLI_64_BITS 0
|
| -#elif defined(BROTLI_TARGET_X64) || defined(BROTLI_TARGET_ARMV8) || \
|
| - defined(BROTLI_TARGET_POWERPC64)
|
| -#define BROTLI_64_BITS 1
|
| +#if !defined(__cplusplus) && !defined(c_plusplus) && \
|
| + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
|
| +#define BROTLI_RESTRICT restrict
|
| +#elif BROTLI_GCC_VERSION > 295 || defined(__llvm__)
|
| +#define BROTLI_RESTRICT __restrict
|
| #else
|
| -#define BROTLI_64_BITS 0
|
| -#endif
|
| -
|
| -#if defined(BROTLI_BUILD_BIG_ENDIAN)
|
| -#define BROTLI_LITTLE_ENDIAN 0
|
| -#define BROTLI_BIG_ENDIAN 1
|
| -#elif defined(BROTLI_BUILD_LITTLE_ENDIAN)
|
| -#define BROTLI_LITTLE_ENDIAN 1
|
| -#define BROTLI_BIG_ENDIAN 0
|
| -#elif defined(BROTLI_BUILD_ENDIAN_NEUTRAL)
|
| -#define BROTLI_LITTLE_ENDIAN 0
|
| -#define BROTLI_BIG_ENDIAN 0
|
| -#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
|
| -#define BROTLI_LITTLE_ENDIAN 1
|
| -#define BROTLI_BIG_ENDIAN 0
|
| -#elif defined(_WIN32)
|
| -/* Win32 can currently always be assumed to be little endian */
|
| -#define BROTLI_LITTLE_ENDIAN 1
|
| -#define BROTLI_BIG_ENDIAN 0
|
| -#else
|
| -#if (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
|
| -#define BROTLI_BIG_ENDIAN 1
|
| -#else
|
| -#define BROTLI_BIG_ENDIAN 0
|
| -#endif
|
| -#define BROTLI_LITTLE_ENDIAN 0
|
| +#define BROTLI_RESTRICT
|
| #endif
|
|
|
| #if BROTLI_MODERN_COMPILER || __has_attribute(noinline)
|
| @@ -215,36 +135,13 @@ static inline void BrotliDump(const char* f, int l, const char* fn) {
|
| #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;
|
| - __asm__("rbit %0, %1\n" : "=r"(output) : "r"(input));
|
| - return output;
|
| -}
|
| -#define BROTLI_RBIT(x) BrotliRBit(x)
|
| -#endif /* armv7 */
|
| -#endif /* gcc || clang */
|
| -
|
| -#if defined(BROTLI_TARGET_ARM)
|
| -#define BROTLI_HAS_UBFX (!!1)
|
| +
|
| +#if BROTLI_MODERN_COMPILER || __has_attribute(deprecated)
|
| +#define BROTLI_DEPRECATED __attribute__((deprecated))
|
| #else
|
| -#define BROTLI_HAS_UBFX (!!0)
|
| +#define BROTLI_DEPRECATED
|
| #endif
|
|
|
| -#define BROTLI_ALLOC(S, L) S->alloc_func(S->memory_manager_opaque, L)
|
| -
|
| -#define BROTLI_FREE(S, X) { \
|
| - S->free_func(S->memory_manager_opaque, X); \
|
| - X = NULL; \
|
| -}
|
| -
|
| #define BROTLI_UNUSED(X) (void)(X)
|
|
|
| -#endif /* BROTLI_DEC_PORT_H_ */
|
| +#endif /* BROTLI_COMMON_PORT_H_ */
|
|
|