Просмотр исходного кода

Restoring authorship annotation for <derrior@yandex-team.ru>. Commit 1 of 2.

derrior 3 лет назад
Родитель
Сommit
9365a6d843

+ 13 - 13
contrib/libs/brotli/common/constants.h

@@ -28,25 +28,25 @@
 /* "code length of 8 is repeated" */
 #define BROTLI_INITIAL_REPEATED_CODE_LENGTH 8
 
-/* "Large Window Brotli" */
-#define BROTLI_LARGE_MAX_DISTANCE_BITS 62U
-#define BROTLI_LARGE_MIN_WBITS 10
-#define BROTLI_LARGE_MAX_WBITS 30
-
+/* "Large Window Brotli" */ 
+#define BROTLI_LARGE_MAX_DISTANCE_BITS 62U 
+#define BROTLI_LARGE_MIN_WBITS 10 
+#define BROTLI_LARGE_MAX_WBITS 30 
+ 
 /* Specification: 4. Encoding of distances */
 #define BROTLI_NUM_DISTANCE_SHORT_CODES 16
 #define BROTLI_MAX_NPOSTFIX 3
 #define BROTLI_MAX_NDIRECT 120
 #define BROTLI_MAX_DISTANCE_BITS 24U
-#define BROTLI_DISTANCE_ALPHABET_SIZE(NPOSTFIX, NDIRECT, MAXNBITS) ( \
-    BROTLI_NUM_DISTANCE_SHORT_CODES + (NDIRECT) +                    \
-    ((MAXNBITS) << ((NPOSTFIX) + 1)))
-/* BROTLI_NUM_DISTANCE_SYMBOLS == 1128 */
-#define BROTLI_NUM_DISTANCE_SYMBOLS \
-    BROTLI_DISTANCE_ALPHABET_SIZE(  \
-        BROTLI_MAX_NDIRECT, BROTLI_MAX_NPOSTFIX, BROTLI_LARGE_MAX_DISTANCE_BITS)
+#define BROTLI_DISTANCE_ALPHABET_SIZE(NPOSTFIX, NDIRECT, MAXNBITS) ( \ 
+    BROTLI_NUM_DISTANCE_SHORT_CODES + (NDIRECT) +                    \ 
+    ((MAXNBITS) << ((NPOSTFIX) + 1))) 
+/* BROTLI_NUM_DISTANCE_SYMBOLS == 1128 */ 
+#define BROTLI_NUM_DISTANCE_SYMBOLS \ 
+    BROTLI_DISTANCE_ALPHABET_SIZE(  \ 
+        BROTLI_MAX_NDIRECT, BROTLI_MAX_NPOSTFIX, BROTLI_LARGE_MAX_DISTANCE_BITS) 
 #define BROTLI_MAX_DISTANCE 0x3FFFFFC
-#define BROTLI_MAX_ALLOWED_DISTANCE 0x7FFFFFFC
+#define BROTLI_MAX_ALLOWED_DISTANCE 0x7FFFFFFC 
 
 /* 7.1. Context modes and context ID lookup for literals */
 /* "context IDs for literals are in the range of 0..63" */

+ 1 - 1
contrib/libs/brotli/common/dictionary.c

@@ -5883,7 +5883,7 @@ static BrotliDictionary kBrotliDictionary = {
   122784,
 
   /* data */
-#if defined(BROTLI_EXTERNAL_DICTIONARY_DATA)
+#if defined(BROTLI_EXTERNAL_DICTIONARY_DATA) 
   NULL
 #else
   kBrotliDictionaryData

+ 4 - 4
contrib/libs/brotli/common/dictionary.h

@@ -27,13 +27,13 @@ typedef struct BrotliDictionary {
    * Dictionary consists of words with length of [4..24] bytes.
    * Values at [0..3] and [25..31] indices should not be addressed.
    */
-  uint8_t size_bits_by_length[32];
+  uint8_t size_bits_by_length[32]; 
 
   /* assert(offset[i + 1] == offset[i] + (bits[i] ? (i << bits[i]) : 0)) */
-  uint32_t offsets_by_length[32];
+  uint32_t offsets_by_length[32]; 
 
   /* assert(data_size == offsets_by_length[31]) */
-  size_t data_size;
+  size_t data_size; 
 
   /* Data array is not bound, and should obey to size_bits_by_length values.
      Specified size matches default (RFC 7932) dictionary. Its size is
@@ -41,7 +41,7 @@ typedef struct BrotliDictionary {
   const uint8_t* data;
 } BrotliDictionary;
 
-BROTLI_COMMON_API const BrotliDictionary* BrotliGetDictionary(void);
+BROTLI_COMMON_API const BrotliDictionary* BrotliGetDictionary(void); 
 
 /**
  * Sets dictionary data.

+ 568 - 568
contrib/libs/brotli/common/platform.h

@@ -1,568 +1,568 @@
-/* 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_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
-*/
-
-#ifndef BROTLI_COMMON_PLATFORM_H_
-#define BROTLI_COMMON_PLATFORM_H_
-
-#include <string.h>  /* memcpy */
-#include <stdlib.h>  /* malloc, free */
-
-#include <brotli/port.h>
-#include <brotli/types.h>
-
-#if defined(OS_LINUX) || defined(OS_CYGWIN)
-#include <endian.h>
-#elif defined(OS_FREEBSD)
-#include <machine/endian.h>
-#elif defined(OS_MACOSX)
-#include <machine/endian.h>
-/* Let's try and follow the Linux convention */
-#define BROTLI_X_BYTE_ORDER BYTE_ORDER
-#define BROTLI_X_LITTLE_ENDIAN LITTLE_ENDIAN
-#define BROTLI_X_BIG_ENDIAN BIG_ENDIAN
-#endif
-
-#if defined(BROTLI_ENABLE_LOG) || defined(BROTLI_DEBUG)
-#include <assert.h>
-#include <stdio.h>
-#endif
-
-/* The following macros were borrowed from https://github.com/nemequ/hedley
- * with permission of original author - Evan Nemerson <evan@nemerson.com> */
-
-/* >>> >>> >>> hedley macros */
-
-/* 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 (BROTLI_PREDICT_TRUE(zero == 0)) {
-    // main execution path
-  } else {
-    // compiler should place this code outside of main execution path
-  }
-
-OR:
-
-  if (BROTLI_PREDICT_FALSE(something_rare_or_unexpected_happens)) {
-    // compiler should place this code outside of main execution path
-  }
-
-*/
-#if BROTLI_GNUC_HAS_BUILTIN(__builtin_expect, 3, 0, 0) || \
-    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||               \
-    BROTLI_SUNPRO_VERSION_CHECK(5, 15, 0) ||              \
-    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                  \
-    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                 \
-    BROTLI_TI_VERSION_CHECK(7, 3, 0) ||                   \
-    BROTLI_TINYC_VERSION_CHECK(0, 9, 27)
-#define BROTLI_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
-#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))
-#else
-#define BROTLI_PREDICT_FALSE(x) (x)
-#define BROTLI_PREDICT_TRUE(x) (x)
-#endif
-
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
-    !defined(__cplusplus)
-#define BROTLI_RESTRICT restrict
-#elif BROTLI_GNUC_VERSION_CHECK(3, 1, 0) ||                         \
-    BROTLI_MSVC_VERSION_CHECK(14, 0, 0) ||                          \
-    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                         \
-    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                            \
-    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                           \
-    BROTLI_PGI_VERSION_CHECK(17, 10, 0) ||                          \
-    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                             \
-    BROTLI_IAR_VERSION_CHECK(8, 0, 0) ||                            \
-    (BROTLI_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus))
-#define BROTLI_RESTRICT __restrict
-#elif BROTLI_SUNPRO_VERSION_CHECK(5, 3, 0) && !defined(__cplusplus)
-#define BROTLI_RESTRICT _Restrict
-#else
-#define BROTLI_RESTRICT
-#endif
-
-#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
-    (defined(__cplusplus) && (__cplusplus >= 199711L))
-#define BROTLI_MAYBE_INLINE inline
-#elif defined(__GNUC_STDC_INLINE__) || defined(__GNUC_GNU_INLINE__) || \
-    BROTLI_ARM_VERSION_CHECK(6, 2, 0)
-#define BROTLI_MAYBE_INLINE __inline__
-#elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0) || \
-    BROTLI_ARM_VERSION_CHECK(4, 1, 0) || BROTLI_TI_VERSION_CHECK(8, 0, 0)
-#define BROTLI_MAYBE_INLINE __inline
-#else
-#define BROTLI_MAYBE_INLINE
-#endif
-
-#if BROTLI_GNUC_HAS_ATTRIBUTE(always_inline, 4, 0, 0) ||                       \
-    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                                    \
-    BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) ||                                   \
-    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                                       \
-    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                                      \
-    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                                        \
-    (BROTLI_TI_VERSION_CHECK(7, 3, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))
-#define BROTLI_INLINE BROTLI_MAYBE_INLINE __attribute__((__always_inline__))
-#elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0)
-#define BROTLI_INLINE BROTLI_MAYBE_INLINE __forceinline
-#elif BROTLI_TI_VERSION_CHECK(7, 0, 0) && defined(__cplusplus)
-#define BROTLI_INLINE BROTLI_MAYBE_INLINE _Pragma("FUNC_ALWAYS_INLINE;")
-#elif BROTLI_IAR_VERSION_CHECK(8, 0, 0)
-#define BROTLI_INLINE BROTLI_MAYBE_INLINE _Pragma("inline=forced")
-#else
-#define BROTLI_INLINE BROTLI_MAYBE_INLINE
-#endif
-
-#if BROTLI_GNUC_HAS_ATTRIBUTE(noinline, 4, 0, 0) ||                            \
-    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                                    \
-    BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) ||                                   \
-    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                                       \
-    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                                      \
-    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                                        \
-    (BROTLI_TI_VERSION_CHECK(7, 3, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))
-#define BROTLI_NOINLINE __attribute__((__noinline__))
-#elif BROTLI_MSVC_VERSION_CHECK(13, 10, 0)
-#define BROTLI_NOINLINE __declspec(noinline)
-#elif BROTLI_PGI_VERSION_CHECK(10, 2, 0)
-#define BROTLI_NOINLINE _Pragma("noinline")
-#elif BROTLI_TI_VERSION_CHECK(6, 0, 0) && defined(__cplusplus)
-#define BROTLI_NOINLINE _Pragma("FUNC_CANNOT_INLINE;")
-#elif BROTLI_IAR_VERSION_CHECK(8, 0, 0)
-#define BROTLI_NOINLINE _Pragma("inline=never")
-#else
-#define BROTLI_NOINLINE
-#endif
-
-/* BROTLI_INTERNAL could be defined to override visibility, e.g. for tests. */
-#if !defined(BROTLI_INTERNAL)
-#if defined(_WIN32) || defined(__CYGWIN__)
-#define BROTLI_INTERNAL
-#elif BROTLI_GNUC_VERSION_CHECK(3, 3, 0) ||                         \
-    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                             \
-    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                         \
-    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                            \
-    BROTLI_IBM_VERSION_CHECK(13, 1, 0) ||                           \
-    BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) ||                        \
-    (BROTLI_TI_VERSION_CHECK(7, 3, 0) &&                            \
-     defined(__TI_GNU_ATTRIBUTE_SUPPORT__) && defined(__TI_EABI__))
-#define BROTLI_INTERNAL __attribute__ ((visibility ("hidden")))
-#else
-#define BROTLI_INTERNAL
-#endif
-#endif
-
-/* <<< <<< <<< end of hedley macros. */
-
-#if BROTLI_GNUC_HAS_ATTRIBUTE(unused, 2, 7, 0) || \
-    BROTLI_INTEL_VERSION_CHECK(16, 0, 0)
-#define BROTLI_UNUSED_FUNCTION static BROTLI_INLINE __attribute__ ((unused))
-#else
-#define BROTLI_UNUSED_FUNCTION static BROTLI_INLINE
-#endif
-
-#if BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0)
-#define BROTLI_ALIGNED(N) __attribute__((aligned(N)))
-#else
-#define BROTLI_ALIGNED(N)
-#endif
-
-#if (defined(__ARM_ARCH) && (__ARM_ARCH == 7)) || \
-    (defined(M_ARM) && (M_ARM == 7))
-#define BROTLI_TARGET_ARMV7
-#endif  /* ARMv7 */
-
-#if (defined(__ARM_ARCH) && (__ARM_ARCH == 8)) || \
-    defined(__aarch64__) || defined(__ARM64_ARCH_8__)
-#define BROTLI_TARGET_ARMV8_ANY
-
-#if defined(__ARM_32BIT_STATE)
-#define BROTLI_TARGET_ARMV8_32
-#elif defined(__ARM_64BIT_STATE)
-#define BROTLI_TARGET_ARMV8_64
-#endif
-
-#endif  /* ARMv8 */
-
-#if defined(__ARM_NEON__) || defined(__ARM_NEON)
-#define BROTLI_TARGET_NEON
-#endif
-
-#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(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64
-#define BROTLI_TARGET_RISCV64
-#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_64) || \
-    defined(BROTLI_TARGET_POWERPC64) || defined(BROTLI_TARGET_RISCV64)
-#define BROTLI_64_BITS 1
-#else
-#define BROTLI_64_BITS 0
-#endif
-
-#if (BROTLI_64_BITS)
-#define brotli_reg_t uint64_t
-#else
-#define brotli_reg_t uint32_t
-#endif
-
-#if defined(BROTLI_BUILD_BIG_ENDIAN)
-#define BROTLI_BIG_ENDIAN 1
-#elif defined(BROTLI_BUILD_LITTLE_ENDIAN)
-#define BROTLI_LITTLE_ENDIAN 1
-#elif defined(BROTLI_BUILD_ENDIAN_NEUTRAL)
-/* Just break elif chain. */
-#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
-#define BROTLI_LITTLE_ENDIAN 1
-#elif defined(_WIN32) || defined(BROTLI_TARGET_X64)
-/* Win32 & x64 can currently always be assumed to be little endian */
-#define BROTLI_LITTLE_ENDIAN 1
-#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
-#define BROTLI_BIG_ENDIAN 1
-#elif defined(BROTLI_X_BYTE_ORDER)
-#if BROTLI_X_BYTE_ORDER == BROTLI_X_LITTLE_ENDIAN
-#define BROTLI_LITTLE_ENDIAN 1
-#elif BROTLI_X_BYTE_ORDER == BROTLI_X_BIG_ENDIAN
-#define BROTLI_BIG_ENDIAN 1
-#endif
-#endif  /* BROTLI_X_BYTE_ORDER */
-
-#if !defined(BROTLI_LITTLE_ENDIAN)
-#define BROTLI_LITTLE_ENDIAN 0
-#endif
-
-#if !defined(BROTLI_BIG_ENDIAN)
-#define BROTLI_BIG_ENDIAN 0
-#endif
-
-#if defined(BROTLI_X_BYTE_ORDER)
-#undef BROTLI_X_BYTE_ORDER
-#undef BROTLI_X_LITTLE_ENDIAN
-#undef BROTLI_X_BIG_ENDIAN
-#endif
-
-#if defined(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_ANY) || \
-    defined(BROTLI_TARGET_RISCV64)
-/* Allow unaligned read only for white-listed CPUs. */
-#define BROTLI_ALIGNED_READ (!!0)
-#else
-#define BROTLI_ALIGNED_READ (!!1)
-#endif
-
-#if BROTLI_ALIGNED_READ
-/* Portable unaligned memory access: read / write values via memcpy. */
-static BROTLI_INLINE uint16_t BrotliUnalignedRead16(const void* p) {
-  uint16_t t;
-  memcpy(&t, p, sizeof t);
-  return t;
-}
-static BROTLI_INLINE uint32_t BrotliUnalignedRead32(const void* p) {
-  uint32_t t;
-  memcpy(&t, p, sizeof t);
-  return t;
-}
-static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
-  uint64_t t;
-  memcpy(&t, p, sizeof t);
-  return t;
-}
-static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
-  memcpy(p, &v, sizeof v);
-}
-#else  /* BROTLI_ALIGNED_READ */
-/* Unaligned memory access is allowed: just cast pointer to requested type. */
-#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || \
-    defined(MEMORY_SANITIZER)
-/* Consider we have an unaligned load/store of 4 bytes from address 0x...05.
-   AddressSanitizer will treat it as a 3-byte access to the range 05:07 and
-   will miss a bug if 08 is the first unaddressable byte.
-   ThreadSanitizer will also treat this as a 3-byte access to 05:07 and will
-   miss a race between this access and some other accesses to 08.
-   MemorySanitizer will correctly propagate the shadow on unaligned stores
-   and correctly report bugs on unaligned loads, but it may not properly
-   update and report the origin of the uninitialized memory.
-   For all three tools, replacing an unaligned access with a tool-specific
-   callback solves the problem. */
-#if defined(__cplusplus)
-extern "C" {
-#endif  /* __cplusplus */
-  uint16_t __sanitizer_unaligned_load16(const void* p);
-  uint32_t __sanitizer_unaligned_load32(const void* p);
-  uint64_t __sanitizer_unaligned_load64(const void* p);
-  void __sanitizer_unaligned_store64(void* p, uint64_t v);
-#if defined(__cplusplus)
-}  /* extern "C" */
-#endif  /* __cplusplus */
-#define BrotliUnalignedRead16 __sanitizer_unaligned_load16
-#define BrotliUnalignedRead32 __sanitizer_unaligned_load32
-#define BrotliUnalignedRead64 __sanitizer_unaligned_load64
-#define BrotliUnalignedWrite64 __sanitizer_unaligned_store64
-#else
-static BROTLI_INLINE uint16_t BrotliUnalignedRead16(const void* p) {
-  return *(const uint16_t*)p;
-}
-static BROTLI_INLINE uint32_t BrotliUnalignedRead32(const void* p) {
-  return *(const uint32_t*)p;
-}
-#if (BROTLI_64_BITS)
-static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
-  return *(const uint64_t*)p;
-}
-static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
-  *(uint64_t*)p = v;
-}
-#else  /* BROTLI_64_BITS */
-/* Avoid emitting LDRD / STRD, which require properly aligned address. */
-/* If __attribute__(aligned) is available, use that. Otherwise, memcpy. */
-
-#if BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0)
-typedef BROTLI_ALIGNED(1) uint64_t brotli_unaligned_uint64_t;
-
-static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
-  return (uint64_t) ((brotli_unaligned_uint64_t*) p)[0];
-}
-static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
-  brotli_unaligned_uint64_t* dwords = (brotli_unaligned_uint64_t*) p;
-  dwords[0] = (brotli_unaligned_uint64_t) v;
-}
-#else /* BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) */
-static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {
-  uint64_t v;
-  memcpy(&v, p, sizeof(uint64_t));
-  return v;
-}
-
-static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {
-  memcpy(p, &v, sizeof(uint64_t));
-}
-#endif  /* BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) */
-#endif  /* BROTLI_64_BITS */
-#endif  /* ASAN / TSAN / MSAN */
-#endif  /* BROTLI_ALIGNED_READ */
-
-#if BROTLI_LITTLE_ENDIAN
-/* Straight endianness. Just read / write values. */
-#define BROTLI_UNALIGNED_LOAD16LE BrotliUnalignedRead16
-#define BROTLI_UNALIGNED_LOAD32LE BrotliUnalignedRead32
-#define BROTLI_UNALIGNED_LOAD64LE BrotliUnalignedRead64
-#define BROTLI_UNALIGNED_STORE64LE BrotliUnalignedWrite64
-#elif BROTLI_BIG_ENDIAN  /* BROTLI_LITTLE_ENDIAN */
-/* Explain compiler to byte-swap values. */
-#define BROTLI_BSWAP16_(V) ((uint16_t)( \
-  (((V) & 0xFFU) << 8) | \
-  (((V) >> 8) & 0xFFU)))
-static BROTLI_INLINE uint16_t BROTLI_UNALIGNED_LOAD16LE(const void* p) {
-  uint16_t value = BrotliUnalignedRead16(p);
-  return BROTLI_BSWAP16_(value);
-}
-#define BROTLI_BSWAP32_(V) ( \
-  (((V) & 0xFFU) << 24) | (((V) & 0xFF00U) << 8) | \
-  (((V) >> 8) & 0xFF00U) | (((V) >> 24) & 0xFFU))
-static BROTLI_INLINE uint32_t BROTLI_UNALIGNED_LOAD32LE(const void* p) {
-  uint32_t value = BrotliUnalignedRead32(p);
-  return BROTLI_BSWAP32_(value);
-}
-#define BROTLI_BSWAP64_(V) ( \
-  (((V) & 0xFFU) << 56) | (((V) & 0xFF00U) << 40) | \
-  (((V) & 0xFF0000U) << 24) | (((V) & 0xFF000000U) << 8) | \
-  (((V) >> 8) & 0xFF000000U) | (((V) >> 24) & 0xFF0000U) | \
-  (((V) >> 40) & 0xFF00U) | (((V) >> 56) & 0xFFU))
-static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void* p) {
-  uint64_t value = BrotliUnalignedRead64(p);
-  return BROTLI_BSWAP64_(value);
-}
-static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void* p, uint64_t v) {
-  uint64_t value = BROTLI_BSWAP64_(v);
-  BrotliUnalignedWrite64(p, value);
-}
-#else  /* BROTLI_LITTLE_ENDIAN */
-/* Read / store values byte-wise; hopefully compiler will understand. */
-static BROTLI_INLINE uint16_t BROTLI_UNALIGNED_LOAD16LE(const void* p) {
-  const uint8_t* in = (const uint8_t*)p;
-  return (uint16_t)(in[0] | (in[1] << 8));
-}
-static BROTLI_INLINE uint32_t BROTLI_UNALIGNED_LOAD32LE(const void* p) {
-  const uint8_t* in = (const uint8_t*)p;
-  uint32_t value = (uint32_t)(in[0]);
-  value |= (uint32_t)(in[1]) << 8;
-  value |= (uint32_t)(in[2]) << 16;
-  value |= (uint32_t)(in[3]) << 24;
-  return value;
-}
-static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void* p) {
-  const uint8_t* in = (const uint8_t*)p;
-  uint64_t value = (uint64_t)(in[0]);
-  value |= (uint64_t)(in[1]) << 8;
-  value |= (uint64_t)(in[2]) << 16;
-  value |= (uint64_t)(in[3]) << 24;
-  value |= (uint64_t)(in[4]) << 32;
-  value |= (uint64_t)(in[5]) << 40;
-  value |= (uint64_t)(in[6]) << 48;
-  value |= (uint64_t)(in[7]) << 56;
-  return value;
-}
-static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void* p, uint64_t v) {
-  uint8_t* out = (uint8_t*)p;
-  out[0] = (uint8_t)v;
-  out[1] = (uint8_t)(v >> 8);
-  out[2] = (uint8_t)(v >> 16);
-  out[3] = (uint8_t)(v >> 24);
-  out[4] = (uint8_t)(v >> 32);
-  out[5] = (uint8_t)(v >> 40);
-  out[6] = (uint8_t)(v >> 48);
-  out[7] = (uint8_t)(v >> 56);
-}
-#endif  /* BROTLI_LITTLE_ENDIAN */
-
-/* BROTLI_IS_CONSTANT macros returns true for compile-time constants. */
-#if BROTLI_GNUC_HAS_BUILTIN(__builtin_constant_p, 3, 0, 1) || \
-    BROTLI_INTEL_VERSION_CHECK(16, 0, 0)
-#define BROTLI_IS_CONSTANT(x) (!!__builtin_constant_p(x))
-#else
-#define BROTLI_IS_CONSTANT(x) (!!0)
-#endif
-
-#if defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8_ANY)
-#define BROTLI_HAS_UBFX (!!1)
-#else
-#define BROTLI_HAS_UBFX (!!0)
-#endif
-
-#if defined(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 BROTLI_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
-
-/* TODO: add appropriate icc/sunpro/arm/ibm/ti checks. */
-#if (BROTLI_GNUC_VERSION_CHECK(3, 0, 0) || defined(__llvm__)) && \
-    !defined(BROTLI_BUILD_NO_RBIT)
-#if defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8_ANY)
-/* TODO: detect ARMv6T2 and enable this code for it. */
-static BROTLI_INLINE brotli_reg_t BrotliRBit(brotli_reg_t input) {
-  brotli_reg_t output;
-  __asm__("rbit %0, %1\n" : "=r"(output) : "r"(input));
-  return output;
-}
-#define BROTLI_RBIT(x) BrotliRBit(x)
-#endif  /* armv7 / armv8 */
-#endif  /* gcc || clang */
-#if !defined(BROTLI_RBIT)
-static BROTLI_INLINE void BrotliRBit(void) { /* Should break build if used. */ }
-#endif  /* BROTLI_RBIT */
-
-#define BROTLI_REPEAT(N, X) {     \
-  if ((N & 1) != 0) {X;}          \
-  if ((N & 2) != 0) {X; X;}       \
-  if ((N & 4) != 0) {X; X; X; X;} \
-}
-
-#define BROTLI_UNUSED(X) (void)(X)
-
-#define BROTLI_MIN_MAX(T)                                                      \
-  static BROTLI_INLINE T brotli_min_ ## T (T a, T b) { return a < b ? a : b; } \
-  static BROTLI_INLINE T brotli_max_ ## T (T a, T b) { return a > b ? a : b; }
-BROTLI_MIN_MAX(double) BROTLI_MIN_MAX(float) BROTLI_MIN_MAX(int)
-BROTLI_MIN_MAX(size_t) BROTLI_MIN_MAX(uint32_t) BROTLI_MIN_MAX(uint8_t)
-#undef BROTLI_MIN_MAX
-#define BROTLI_MIN(T, A, B) (brotli_min_ ## T((A), (B)))
-#define BROTLI_MAX(T, A, B) (brotli_max_ ## T((A), (B)))
-
-#define BROTLI_SWAP(T, A, I, J) { \
-  T __brotli_swap_tmp = (A)[(I)]; \
-  (A)[(I)] = (A)[(J)];            \
-  (A)[(J)] = __brotli_swap_tmp;   \
-}
-
-/* Default brotli_alloc_func */
-static void* BrotliDefaultAllocFunc(void* opaque, size_t size) {
-  BROTLI_UNUSED(opaque);
-  return malloc(size);
-}
-
-/* Default brotli_free_func */
-static void BrotliDefaultFreeFunc(void* opaque, void* address) {
-  BROTLI_UNUSED(opaque);
-  free(address);
-}
-
-BROTLI_UNUSED_FUNCTION void BrotliSuppressUnusedFunctions(void) {
-  BROTLI_UNUSED(&BrotliSuppressUnusedFunctions);
-  BROTLI_UNUSED(&BrotliUnalignedRead16);
-  BROTLI_UNUSED(&BrotliUnalignedRead32);
-  BROTLI_UNUSED(&BrotliUnalignedRead64);
-  BROTLI_UNUSED(&BrotliUnalignedWrite64);
-  BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD16LE);
-  BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD32LE);
-  BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD64LE);
-  BROTLI_UNUSED(&BROTLI_UNALIGNED_STORE64LE);
-  BROTLI_UNUSED(&BrotliRBit);
-  BROTLI_UNUSED(&brotli_min_double);
-  BROTLI_UNUSED(&brotli_max_double);
-  BROTLI_UNUSED(&brotli_min_float);
-  BROTLI_UNUSED(&brotli_max_float);
-  BROTLI_UNUSED(&brotli_min_int);
-  BROTLI_UNUSED(&brotli_max_int);
-  BROTLI_UNUSED(&brotli_min_size_t);
-  BROTLI_UNUSED(&brotli_max_size_t);
-  BROTLI_UNUSED(&brotli_min_uint32_t);
-  BROTLI_UNUSED(&brotli_max_uint32_t);
-  BROTLI_UNUSED(&brotli_min_uint8_t);
-  BROTLI_UNUSED(&brotli_max_uint8_t);
-  BROTLI_UNUSED(&BrotliDefaultAllocFunc);
-  BROTLI_UNUSED(&BrotliDefaultFreeFunc);
-#if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG)
-  BROTLI_UNUSED(&BrotliDump);
-#endif
-}
-
-#endif  /* BROTLI_COMMON_PLATFORM_H_ */
+/* 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_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 
+*/ 
+ 
+#ifndef BROTLI_COMMON_PLATFORM_H_ 
+#define BROTLI_COMMON_PLATFORM_H_ 
+ 
+#include <string.h>  /* memcpy */ 
+#include <stdlib.h>  /* malloc, free */ 
+ 
+#include <brotli/port.h> 
+#include <brotli/types.h> 
+ 
+#if defined(OS_LINUX) || defined(OS_CYGWIN) 
+#include <endian.h> 
+#elif defined(OS_FREEBSD) 
+#include <machine/endian.h> 
+#elif defined(OS_MACOSX) 
+#include <machine/endian.h> 
+/* Let's try and follow the Linux convention */ 
+#define BROTLI_X_BYTE_ORDER BYTE_ORDER 
+#define BROTLI_X_LITTLE_ENDIAN LITTLE_ENDIAN 
+#define BROTLI_X_BIG_ENDIAN BIG_ENDIAN 
+#endif 
+ 
+#if defined(BROTLI_ENABLE_LOG) || defined(BROTLI_DEBUG) 
+#include <assert.h> 
+#include <stdio.h> 
+#endif 
+ 
+/* The following macros were borrowed from https://github.com/nemequ/hedley 
+ * with permission of original author - Evan Nemerson <evan@nemerson.com> */ 
+ 
+/* >>> >>> >>> hedley macros */ 
+ 
+/* 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 (BROTLI_PREDICT_TRUE(zero == 0)) { 
+    // main execution path 
+  } else { 
+    // compiler should place this code outside of main execution path 
+  } 
+ 
+OR: 
+ 
+  if (BROTLI_PREDICT_FALSE(something_rare_or_unexpected_happens)) { 
+    // compiler should place this code outside of main execution path 
+  } 
+ 
+*/ 
+#if BROTLI_GNUC_HAS_BUILTIN(__builtin_expect, 3, 0, 0) || \ 
+    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||               \ 
+    BROTLI_SUNPRO_VERSION_CHECK(5, 15, 0) ||              \ 
+    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                  \ 
+    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                 \ 
+    BROTLI_TI_VERSION_CHECK(7, 3, 0) ||                   \ 
+    BROTLI_TINYC_VERSION_CHECK(0, 9, 27) 
+#define BROTLI_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1)) 
+#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0)) 
+#else 
+#define BROTLI_PREDICT_FALSE(x) (x) 
+#define BROTLI_PREDICT_TRUE(x) (x) 
+#endif 
+ 
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ 
+    !defined(__cplusplus) 
+#define BROTLI_RESTRICT restrict 
+#elif BROTLI_GNUC_VERSION_CHECK(3, 1, 0) ||                         \ 
+    BROTLI_MSVC_VERSION_CHECK(14, 0, 0) ||                          \ 
+    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                         \ 
+    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                            \ 
+    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                           \ 
+    BROTLI_PGI_VERSION_CHECK(17, 10, 0) ||                          \ 
+    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                             \ 
+    BROTLI_IAR_VERSION_CHECK(8, 0, 0) ||                            \ 
+    (BROTLI_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus)) 
+#define BROTLI_RESTRICT __restrict 
+#elif BROTLI_SUNPRO_VERSION_CHECK(5, 3, 0) && !defined(__cplusplus) 
+#define BROTLI_RESTRICT _Restrict 
+#else 
+#define BROTLI_RESTRICT 
+#endif 
+ 
+#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ 
+    (defined(__cplusplus) && (__cplusplus >= 199711L)) 
+#define BROTLI_MAYBE_INLINE inline 
+#elif defined(__GNUC_STDC_INLINE__) || defined(__GNUC_GNU_INLINE__) || \ 
+    BROTLI_ARM_VERSION_CHECK(6, 2, 0) 
+#define BROTLI_MAYBE_INLINE __inline__ 
+#elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0) || \ 
+    BROTLI_ARM_VERSION_CHECK(4, 1, 0) || BROTLI_TI_VERSION_CHECK(8, 0, 0) 
+#define BROTLI_MAYBE_INLINE __inline 
+#else 
+#define BROTLI_MAYBE_INLINE 
+#endif 
+ 
+#if BROTLI_GNUC_HAS_ATTRIBUTE(always_inline, 4, 0, 0) ||                       \ 
+    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                                    \ 
+    BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) ||                                   \ 
+    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                                       \ 
+    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                                      \ 
+    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                                        \ 
+    (BROTLI_TI_VERSION_CHECK(7, 3, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) 
+#define BROTLI_INLINE BROTLI_MAYBE_INLINE __attribute__((__always_inline__)) 
+#elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0) 
+#define BROTLI_INLINE BROTLI_MAYBE_INLINE __forceinline 
+#elif BROTLI_TI_VERSION_CHECK(7, 0, 0) && defined(__cplusplus) 
+#define BROTLI_INLINE BROTLI_MAYBE_INLINE _Pragma("FUNC_ALWAYS_INLINE;") 
+#elif BROTLI_IAR_VERSION_CHECK(8, 0, 0) 
+#define BROTLI_INLINE BROTLI_MAYBE_INLINE _Pragma("inline=forced") 
+#else 
+#define BROTLI_INLINE BROTLI_MAYBE_INLINE 
+#endif 
+ 
+#if BROTLI_GNUC_HAS_ATTRIBUTE(noinline, 4, 0, 0) ||                            \ 
+    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                                    \ 
+    BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) ||                                   \ 
+    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                                       \ 
+    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                                      \ 
+    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                                        \ 
+    (BROTLI_TI_VERSION_CHECK(7, 3, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) 
+#define BROTLI_NOINLINE __attribute__((__noinline__)) 
+#elif BROTLI_MSVC_VERSION_CHECK(13, 10, 0) 
+#define BROTLI_NOINLINE __declspec(noinline) 
+#elif BROTLI_PGI_VERSION_CHECK(10, 2, 0) 
+#define BROTLI_NOINLINE _Pragma("noinline") 
+#elif BROTLI_TI_VERSION_CHECK(6, 0, 0) && defined(__cplusplus) 
+#define BROTLI_NOINLINE _Pragma("FUNC_CANNOT_INLINE;") 
+#elif BROTLI_IAR_VERSION_CHECK(8, 0, 0) 
+#define BROTLI_NOINLINE _Pragma("inline=never") 
+#else 
+#define BROTLI_NOINLINE 
+#endif 
+ 
+/* BROTLI_INTERNAL could be defined to override visibility, e.g. for tests. */ 
+#if !defined(BROTLI_INTERNAL) 
+#if defined(_WIN32) || defined(__CYGWIN__) 
+#define BROTLI_INTERNAL 
+#elif BROTLI_GNUC_VERSION_CHECK(3, 3, 0) ||                         \ 
+    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                             \ 
+    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                         \ 
+    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                            \ 
+    BROTLI_IBM_VERSION_CHECK(13, 1, 0) ||                           \ 
+    BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) ||                        \ 
+    (BROTLI_TI_VERSION_CHECK(7, 3, 0) &&                            \ 
+     defined(__TI_GNU_ATTRIBUTE_SUPPORT__) && defined(__TI_EABI__)) 
+#define BROTLI_INTERNAL __attribute__ ((visibility ("hidden"))) 
+#else 
+#define BROTLI_INTERNAL 
+#endif 
+#endif 
+ 
+/* <<< <<< <<< end of hedley macros. */ 
+ 
+#if BROTLI_GNUC_HAS_ATTRIBUTE(unused, 2, 7, 0) || \ 
+    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) 
+#define BROTLI_UNUSED_FUNCTION static BROTLI_INLINE __attribute__ ((unused)) 
+#else 
+#define BROTLI_UNUSED_FUNCTION static BROTLI_INLINE 
+#endif 
+ 
+#if BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) 
+#define BROTLI_ALIGNED(N) __attribute__((aligned(N))) 
+#else 
+#define BROTLI_ALIGNED(N) 
+#endif 
+ 
+#if (defined(__ARM_ARCH) && (__ARM_ARCH == 7)) || \ 
+    (defined(M_ARM) && (M_ARM == 7)) 
+#define BROTLI_TARGET_ARMV7 
+#endif  /* ARMv7 */ 
+ 
+#if (defined(__ARM_ARCH) && (__ARM_ARCH == 8)) || \ 
+    defined(__aarch64__) || defined(__ARM64_ARCH_8__) 
+#define BROTLI_TARGET_ARMV8_ANY 
+ 
+#if defined(__ARM_32BIT_STATE) 
+#define BROTLI_TARGET_ARMV8_32 
+#elif defined(__ARM_64BIT_STATE) 
+#define BROTLI_TARGET_ARMV8_64 
+#endif 
+ 
+#endif  /* ARMv8 */ 
+ 
+#if defined(__ARM_NEON__) || defined(__ARM_NEON) 
+#define BROTLI_TARGET_NEON 
+#endif 
+ 
+#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(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64 
+#define BROTLI_TARGET_RISCV64 
+#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_64) || \ 
+    defined(BROTLI_TARGET_POWERPC64) || defined(BROTLI_TARGET_RISCV64) 
+#define BROTLI_64_BITS 1 
+#else 
+#define BROTLI_64_BITS 0 
+#endif 
+ 
+#if (BROTLI_64_BITS) 
+#define brotli_reg_t uint64_t 
+#else 
+#define brotli_reg_t uint32_t 
+#endif 
+ 
+#if defined(BROTLI_BUILD_BIG_ENDIAN) 
+#define BROTLI_BIG_ENDIAN 1 
+#elif defined(BROTLI_BUILD_LITTLE_ENDIAN) 
+#define BROTLI_LITTLE_ENDIAN 1 
+#elif defined(BROTLI_BUILD_ENDIAN_NEUTRAL) 
+/* Just break elif chain. */ 
+#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) 
+#define BROTLI_LITTLE_ENDIAN 1 
+#elif defined(_WIN32) || defined(BROTLI_TARGET_X64) 
+/* Win32 & x64 can currently always be assumed to be little endian */ 
+#define BROTLI_LITTLE_ENDIAN 1 
+#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) 
+#define BROTLI_BIG_ENDIAN 1 
+#elif defined(BROTLI_X_BYTE_ORDER) 
+#if BROTLI_X_BYTE_ORDER == BROTLI_X_LITTLE_ENDIAN 
+#define BROTLI_LITTLE_ENDIAN 1 
+#elif BROTLI_X_BYTE_ORDER == BROTLI_X_BIG_ENDIAN 
+#define BROTLI_BIG_ENDIAN 1 
+#endif 
+#endif  /* BROTLI_X_BYTE_ORDER */ 
+ 
+#if !defined(BROTLI_LITTLE_ENDIAN) 
+#define BROTLI_LITTLE_ENDIAN 0 
+#endif 
+ 
+#if !defined(BROTLI_BIG_ENDIAN) 
+#define BROTLI_BIG_ENDIAN 0 
+#endif 
+ 
+#if defined(BROTLI_X_BYTE_ORDER) 
+#undef BROTLI_X_BYTE_ORDER 
+#undef BROTLI_X_LITTLE_ENDIAN 
+#undef BROTLI_X_BIG_ENDIAN 
+#endif 
+ 
+#if defined(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_ANY) || \ 
+    defined(BROTLI_TARGET_RISCV64) 
+/* Allow unaligned read only for white-listed CPUs. */ 
+#define BROTLI_ALIGNED_READ (!!0) 
+#else 
+#define BROTLI_ALIGNED_READ (!!1) 
+#endif 
+ 
+#if BROTLI_ALIGNED_READ 
+/* Portable unaligned memory access: read / write values via memcpy. */ 
+static BROTLI_INLINE uint16_t BrotliUnalignedRead16(const void* p) { 
+  uint16_t t; 
+  memcpy(&t, p, sizeof t); 
+  return t; 
+} 
+static BROTLI_INLINE uint32_t BrotliUnalignedRead32(const void* p) { 
+  uint32_t t; 
+  memcpy(&t, p, sizeof t); 
+  return t; 
+} 
+static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) { 
+  uint64_t t; 
+  memcpy(&t, p, sizeof t); 
+  return t; 
+} 
+static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) { 
+  memcpy(p, &v, sizeof v); 
+} 
+#else  /* BROTLI_ALIGNED_READ */ 
+/* Unaligned memory access is allowed: just cast pointer to requested type. */ 
+#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || \ 
+    defined(MEMORY_SANITIZER) 
+/* Consider we have an unaligned load/store of 4 bytes from address 0x...05. 
+   AddressSanitizer will treat it as a 3-byte access to the range 05:07 and 
+   will miss a bug if 08 is the first unaddressable byte. 
+   ThreadSanitizer will also treat this as a 3-byte access to 05:07 and will 
+   miss a race between this access and some other accesses to 08. 
+   MemorySanitizer will correctly propagate the shadow on unaligned stores 
+   and correctly report bugs on unaligned loads, but it may not properly 
+   update and report the origin of the uninitialized memory. 
+   For all three tools, replacing an unaligned access with a tool-specific 
+   callback solves the problem. */ 
+#if defined(__cplusplus) 
+extern "C" { 
+#endif  /* __cplusplus */ 
+  uint16_t __sanitizer_unaligned_load16(const void* p); 
+  uint32_t __sanitizer_unaligned_load32(const void* p); 
+  uint64_t __sanitizer_unaligned_load64(const void* p); 
+  void __sanitizer_unaligned_store64(void* p, uint64_t v); 
+#if defined(__cplusplus) 
+}  /* extern "C" */ 
+#endif  /* __cplusplus */ 
+#define BrotliUnalignedRead16 __sanitizer_unaligned_load16 
+#define BrotliUnalignedRead32 __sanitizer_unaligned_load32 
+#define BrotliUnalignedRead64 __sanitizer_unaligned_load64 
+#define BrotliUnalignedWrite64 __sanitizer_unaligned_store64 
+#else 
+static BROTLI_INLINE uint16_t BrotliUnalignedRead16(const void* p) { 
+  return *(const uint16_t*)p; 
+} 
+static BROTLI_INLINE uint32_t BrotliUnalignedRead32(const void* p) { 
+  return *(const uint32_t*)p; 
+} 
+#if (BROTLI_64_BITS) 
+static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) { 
+  return *(const uint64_t*)p; 
+} 
+static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) { 
+  *(uint64_t*)p = v; 
+} 
+#else  /* BROTLI_64_BITS */ 
+/* Avoid emitting LDRD / STRD, which require properly aligned address. */ 
+/* If __attribute__(aligned) is available, use that. Otherwise, memcpy. */ 
+ 
+#if BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) 
+typedef BROTLI_ALIGNED(1) uint64_t brotli_unaligned_uint64_t; 
+ 
+static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) { 
+  return (uint64_t) ((brotli_unaligned_uint64_t*) p)[0]; 
+} 
+static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) { 
+  brotli_unaligned_uint64_t* dwords = (brotli_unaligned_uint64_t*) p; 
+  dwords[0] = (brotli_unaligned_uint64_t) v; 
+} 
+#else /* BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) */ 
+static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) { 
+  uint64_t v; 
+  memcpy(&v, p, sizeof(uint64_t)); 
+  return v; 
+} 
+ 
+static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) { 
+  memcpy(p, &v, sizeof(uint64_t)); 
+} 
+#endif  /* BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) */ 
+#endif  /* BROTLI_64_BITS */ 
+#endif  /* ASAN / TSAN / MSAN */ 
+#endif  /* BROTLI_ALIGNED_READ */ 
+ 
+#if BROTLI_LITTLE_ENDIAN 
+/* Straight endianness. Just read / write values. */ 
+#define BROTLI_UNALIGNED_LOAD16LE BrotliUnalignedRead16 
+#define BROTLI_UNALIGNED_LOAD32LE BrotliUnalignedRead32 
+#define BROTLI_UNALIGNED_LOAD64LE BrotliUnalignedRead64 
+#define BROTLI_UNALIGNED_STORE64LE BrotliUnalignedWrite64 
+#elif BROTLI_BIG_ENDIAN  /* BROTLI_LITTLE_ENDIAN */ 
+/* Explain compiler to byte-swap values. */ 
+#define BROTLI_BSWAP16_(V) ((uint16_t)( \ 
+  (((V) & 0xFFU) << 8) | \ 
+  (((V) >> 8) & 0xFFU))) 
+static BROTLI_INLINE uint16_t BROTLI_UNALIGNED_LOAD16LE(const void* p) { 
+  uint16_t value = BrotliUnalignedRead16(p); 
+  return BROTLI_BSWAP16_(value); 
+} 
+#define BROTLI_BSWAP32_(V) ( \ 
+  (((V) & 0xFFU) << 24) | (((V) & 0xFF00U) << 8) | \ 
+  (((V) >> 8) & 0xFF00U) | (((V) >> 24) & 0xFFU)) 
+static BROTLI_INLINE uint32_t BROTLI_UNALIGNED_LOAD32LE(const void* p) { 
+  uint32_t value = BrotliUnalignedRead32(p); 
+  return BROTLI_BSWAP32_(value); 
+} 
+#define BROTLI_BSWAP64_(V) ( \ 
+  (((V) & 0xFFU) << 56) | (((V) & 0xFF00U) << 40) | \ 
+  (((V) & 0xFF0000U) << 24) | (((V) & 0xFF000000U) << 8) | \ 
+  (((V) >> 8) & 0xFF000000U) | (((V) >> 24) & 0xFF0000U) | \ 
+  (((V) >> 40) & 0xFF00U) | (((V) >> 56) & 0xFFU)) 
+static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void* p) { 
+  uint64_t value = BrotliUnalignedRead64(p); 
+  return BROTLI_BSWAP64_(value); 
+} 
+static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void* p, uint64_t v) { 
+  uint64_t value = BROTLI_BSWAP64_(v); 
+  BrotliUnalignedWrite64(p, value); 
+} 
+#else  /* BROTLI_LITTLE_ENDIAN */ 
+/* Read / store values byte-wise; hopefully compiler will understand. */ 
+static BROTLI_INLINE uint16_t BROTLI_UNALIGNED_LOAD16LE(const void* p) { 
+  const uint8_t* in = (const uint8_t*)p; 
+  return (uint16_t)(in[0] | (in[1] << 8)); 
+} 
+static BROTLI_INLINE uint32_t BROTLI_UNALIGNED_LOAD32LE(const void* p) { 
+  const uint8_t* in = (const uint8_t*)p; 
+  uint32_t value = (uint32_t)(in[0]); 
+  value |= (uint32_t)(in[1]) << 8; 
+  value |= (uint32_t)(in[2]) << 16; 
+  value |= (uint32_t)(in[3]) << 24; 
+  return value; 
+} 
+static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void* p) { 
+  const uint8_t* in = (const uint8_t*)p; 
+  uint64_t value = (uint64_t)(in[0]); 
+  value |= (uint64_t)(in[1]) << 8; 
+  value |= (uint64_t)(in[2]) << 16; 
+  value |= (uint64_t)(in[3]) << 24; 
+  value |= (uint64_t)(in[4]) << 32; 
+  value |= (uint64_t)(in[5]) << 40; 
+  value |= (uint64_t)(in[6]) << 48; 
+  value |= (uint64_t)(in[7]) << 56; 
+  return value; 
+} 
+static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void* p, uint64_t v) { 
+  uint8_t* out = (uint8_t*)p; 
+  out[0] = (uint8_t)v; 
+  out[1] = (uint8_t)(v >> 8); 
+  out[2] = (uint8_t)(v >> 16); 
+  out[3] = (uint8_t)(v >> 24); 
+  out[4] = (uint8_t)(v >> 32); 
+  out[5] = (uint8_t)(v >> 40); 
+  out[6] = (uint8_t)(v >> 48); 
+  out[7] = (uint8_t)(v >> 56); 
+} 
+#endif  /* BROTLI_LITTLE_ENDIAN */ 
+ 
+/* BROTLI_IS_CONSTANT macros returns true for compile-time constants. */ 
+#if BROTLI_GNUC_HAS_BUILTIN(__builtin_constant_p, 3, 0, 1) || \ 
+    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) 
+#define BROTLI_IS_CONSTANT(x) (!!__builtin_constant_p(x)) 
+#else 
+#define BROTLI_IS_CONSTANT(x) (!!0) 
+#endif 
+ 
+#if defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8_ANY) 
+#define BROTLI_HAS_UBFX (!!1) 
+#else 
+#define BROTLI_HAS_UBFX (!!0) 
+#endif 
+ 
+#if defined(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 BROTLI_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 
+ 
+/* TODO: add appropriate icc/sunpro/arm/ibm/ti checks. */ 
+#if (BROTLI_GNUC_VERSION_CHECK(3, 0, 0) || defined(__llvm__)) && \ 
+    !defined(BROTLI_BUILD_NO_RBIT) 
+#if defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8_ANY) 
+/* TODO: detect ARMv6T2 and enable this code for it. */ 
+static BROTLI_INLINE brotli_reg_t BrotliRBit(brotli_reg_t input) { 
+  brotli_reg_t output; 
+  __asm__("rbit %0, %1\n" : "=r"(output) : "r"(input)); 
+  return output; 
+} 
+#define BROTLI_RBIT(x) BrotliRBit(x) 
+#endif  /* armv7 / armv8 */ 
+#endif  /* gcc || clang */ 
+#if !defined(BROTLI_RBIT) 
+static BROTLI_INLINE void BrotliRBit(void) { /* Should break build if used. */ } 
+#endif  /* BROTLI_RBIT */ 
+ 
+#define BROTLI_REPEAT(N, X) {     \ 
+  if ((N & 1) != 0) {X;}          \ 
+  if ((N & 2) != 0) {X; X;}       \ 
+  if ((N & 4) != 0) {X; X; X; X;} \ 
+} 
+ 
+#define BROTLI_UNUSED(X) (void)(X) 
+ 
+#define BROTLI_MIN_MAX(T)                                                      \ 
+  static BROTLI_INLINE T brotli_min_ ## T (T a, T b) { return a < b ? a : b; } \ 
+  static BROTLI_INLINE T brotli_max_ ## T (T a, T b) { return a > b ? a : b; } 
+BROTLI_MIN_MAX(double) BROTLI_MIN_MAX(float) BROTLI_MIN_MAX(int) 
+BROTLI_MIN_MAX(size_t) BROTLI_MIN_MAX(uint32_t) BROTLI_MIN_MAX(uint8_t) 
+#undef BROTLI_MIN_MAX 
+#define BROTLI_MIN(T, A, B) (brotli_min_ ## T((A), (B))) 
+#define BROTLI_MAX(T, A, B) (brotli_max_ ## T((A), (B))) 
+ 
+#define BROTLI_SWAP(T, A, I, J) { \ 
+  T __brotli_swap_tmp = (A)[(I)]; \ 
+  (A)[(I)] = (A)[(J)];            \ 
+  (A)[(J)] = __brotli_swap_tmp;   \ 
+} 
+ 
+/* Default brotli_alloc_func */ 
+static void* BrotliDefaultAllocFunc(void* opaque, size_t size) { 
+  BROTLI_UNUSED(opaque); 
+  return malloc(size); 
+} 
+ 
+/* Default brotli_free_func */ 
+static void BrotliDefaultFreeFunc(void* opaque, void* address) { 
+  BROTLI_UNUSED(opaque); 
+  free(address); 
+} 
+ 
+BROTLI_UNUSED_FUNCTION void BrotliSuppressUnusedFunctions(void) { 
+  BROTLI_UNUSED(&BrotliSuppressUnusedFunctions); 
+  BROTLI_UNUSED(&BrotliUnalignedRead16); 
+  BROTLI_UNUSED(&BrotliUnalignedRead32); 
+  BROTLI_UNUSED(&BrotliUnalignedRead64); 
+  BROTLI_UNUSED(&BrotliUnalignedWrite64); 
+  BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD16LE); 
+  BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD32LE); 
+  BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD64LE); 
+  BROTLI_UNUSED(&BROTLI_UNALIGNED_STORE64LE); 
+  BROTLI_UNUSED(&BrotliRBit); 
+  BROTLI_UNUSED(&brotli_min_double); 
+  BROTLI_UNUSED(&brotli_max_double); 
+  BROTLI_UNUSED(&brotli_min_float); 
+  BROTLI_UNUSED(&brotli_max_float); 
+  BROTLI_UNUSED(&brotli_min_int); 
+  BROTLI_UNUSED(&brotli_max_int); 
+  BROTLI_UNUSED(&brotli_min_size_t); 
+  BROTLI_UNUSED(&brotli_max_size_t); 
+  BROTLI_UNUSED(&brotli_min_uint32_t); 
+  BROTLI_UNUSED(&brotli_max_uint32_t); 
+  BROTLI_UNUSED(&brotli_min_uint8_t); 
+  BROTLI_UNUSED(&brotli_max_uint8_t); 
+  BROTLI_UNUSED(&BrotliDefaultAllocFunc); 
+  BROTLI_UNUSED(&BrotliDefaultFreeFunc); 
+#if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG) 
+  BROTLI_UNUSED(&BrotliDump); 
+#endif 
+} 
+ 
+#endif  /* BROTLI_COMMON_PLATFORM_H_ */ 

+ 235 - 235
contrib/libs/brotli/common/transform.c

@@ -1,235 +1,235 @@
-/* Copyright 2013 Google Inc. All Rights Reserved.
-
-   Distributed under MIT license.
-   See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
-*/
-
-#include "./transform.h"
-
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
-/* RFC 7932 transforms string data */
-static const char kPrefixSuffix[217] =
-      "\1 \2, \10 of the \4 of \2s \1.\5 and \4 "
-/* 0x  _0 _2  __5        _E    _3  _6 _8     _E */
-      "in \1\"\4 to \2\">\1\n\2. \1]\5 for \3 a \6 "
-/* 2x     _3_ _5    _A_  _D_ _F  _2 _4     _A   _E */
-      "that \1\'\6 with \6 from \4 by \1(\6. T"
-/* 4x       _5_ _7      _E      _5    _A _C */
-      "he \4 on \4 as \4 is \4ing \2\n\t\1:\3ed "
-/* 6x     _3    _8    _D    _2    _7_ _ _A _C */
-      "\2=\"\4 at \3ly \1,\2=\'\5.com/\7. This \5"
-/* 8x  _0 _ _3    _8   _C _E _ _1     _7       _F */
-      " not \3er \3al \4ful \4ive \5less \4es"
-/* Ax       _5   _9   _D    _2    _7     _D */
-      "t \4ize \2\xc2\xa0\4ous \5 the \2e \0";
-/* Cx    _2    _7___ ___ _A    _F     _5  _8 */
-
-static const uint16_t kPrefixSuffixMap[50] = {
-  0x00, 0x02, 0x05, 0x0E, 0x13, 0x16, 0x18, 0x1E, 0x23, 0x25,
-  0x2A, 0x2D, 0x2F, 0x32, 0x34, 0x3A, 0x3E, 0x45, 0x47, 0x4E,
-  0x55, 0x5A, 0x5C, 0x63, 0x68, 0x6D, 0x72, 0x77, 0x7A, 0x7C,
-  0x80, 0x83, 0x88, 0x8C, 0x8E, 0x91, 0x97, 0x9F, 0xA5, 0xA9,
-  0xAD, 0xB2, 0xB7, 0xBD, 0xC2, 0xC7, 0xCA, 0xCF, 0xD5, 0xD8
-};
-
-/* RFC 7932 transforms */
-static const uint8_t kTransformsData[] = {
-  49, BROTLI_TRANSFORM_IDENTITY, 49,
-  49, BROTLI_TRANSFORM_IDENTITY, 0,
-   0, BROTLI_TRANSFORM_IDENTITY, 0,
-  49, BROTLI_TRANSFORM_OMIT_FIRST_1, 49,
-  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 0,
-  49, BROTLI_TRANSFORM_IDENTITY, 47,
-   0, BROTLI_TRANSFORM_IDENTITY, 49,
-   4, BROTLI_TRANSFORM_IDENTITY, 0,
-  49, BROTLI_TRANSFORM_IDENTITY, 3,
-  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 49,
-  49, BROTLI_TRANSFORM_IDENTITY, 6,
-  49, BROTLI_TRANSFORM_OMIT_FIRST_2, 49,
-  49, BROTLI_TRANSFORM_OMIT_LAST_1, 49,
-   1, BROTLI_TRANSFORM_IDENTITY, 0,
-  49, BROTLI_TRANSFORM_IDENTITY, 1,
-   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 0,
-  49, BROTLI_TRANSFORM_IDENTITY, 7,
-  49, BROTLI_TRANSFORM_IDENTITY, 9,
-  48, BROTLI_TRANSFORM_IDENTITY, 0,
-  49, BROTLI_TRANSFORM_IDENTITY, 8,
-  49, BROTLI_TRANSFORM_IDENTITY, 5,
-  49, BROTLI_TRANSFORM_IDENTITY, 10,
-  49, BROTLI_TRANSFORM_IDENTITY, 11,
-  49, BROTLI_TRANSFORM_OMIT_LAST_3, 49,
-  49, BROTLI_TRANSFORM_IDENTITY, 13,
-  49, BROTLI_TRANSFORM_IDENTITY, 14,
-  49, BROTLI_TRANSFORM_OMIT_FIRST_3, 49,
-  49, BROTLI_TRANSFORM_OMIT_LAST_2, 49,
-  49, BROTLI_TRANSFORM_IDENTITY, 15,
-  49, BROTLI_TRANSFORM_IDENTITY, 16,
-   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 49,
-  49, BROTLI_TRANSFORM_IDENTITY, 12,
-   5, BROTLI_TRANSFORM_IDENTITY, 49,
-   0, BROTLI_TRANSFORM_IDENTITY, 1,
-  49, BROTLI_TRANSFORM_OMIT_FIRST_4, 49,
-  49, BROTLI_TRANSFORM_IDENTITY, 18,
-  49, BROTLI_TRANSFORM_IDENTITY, 17,
-  49, BROTLI_TRANSFORM_IDENTITY, 19,
-  49, BROTLI_TRANSFORM_IDENTITY, 20,
-  49, BROTLI_TRANSFORM_OMIT_FIRST_5, 49,
-  49, BROTLI_TRANSFORM_OMIT_FIRST_6, 49,
-  47, BROTLI_TRANSFORM_IDENTITY, 49,
-  49, BROTLI_TRANSFORM_OMIT_LAST_4, 49,
-  49, BROTLI_TRANSFORM_IDENTITY, 22,
-  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 49,
-  49, BROTLI_TRANSFORM_IDENTITY, 23,
-  49, BROTLI_TRANSFORM_IDENTITY, 24,
-  49, BROTLI_TRANSFORM_IDENTITY, 25,
-  49, BROTLI_TRANSFORM_OMIT_LAST_7, 49,
-  49, BROTLI_TRANSFORM_OMIT_LAST_1, 26,
-  49, BROTLI_TRANSFORM_IDENTITY, 27,
-  49, BROTLI_TRANSFORM_IDENTITY, 28,
-   0, BROTLI_TRANSFORM_IDENTITY, 12,
-  49, BROTLI_TRANSFORM_IDENTITY, 29,
-  49, BROTLI_TRANSFORM_OMIT_FIRST_9, 49,
-  49, BROTLI_TRANSFORM_OMIT_FIRST_7, 49,
-  49, BROTLI_TRANSFORM_OMIT_LAST_6, 49,
-  49, BROTLI_TRANSFORM_IDENTITY, 21,
-  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 1,
-  49, BROTLI_TRANSFORM_OMIT_LAST_8, 49,
-  49, BROTLI_TRANSFORM_IDENTITY, 31,
-  49, BROTLI_TRANSFORM_IDENTITY, 32,
-  47, BROTLI_TRANSFORM_IDENTITY, 3,
-  49, BROTLI_TRANSFORM_OMIT_LAST_5, 49,
-  49, BROTLI_TRANSFORM_OMIT_LAST_9, 49,
-   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 1,
-  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 8,
-   5, BROTLI_TRANSFORM_IDENTITY, 21,
-  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 0,
-  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 10,
-  49, BROTLI_TRANSFORM_IDENTITY, 30,
-   0, BROTLI_TRANSFORM_IDENTITY, 5,
-  35, BROTLI_TRANSFORM_IDENTITY, 49,
-  47, BROTLI_TRANSFORM_IDENTITY, 2,
-  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 17,
-  49, BROTLI_TRANSFORM_IDENTITY, 36,
-  49, BROTLI_TRANSFORM_IDENTITY, 33,
-   5, BROTLI_TRANSFORM_IDENTITY, 0,
-  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 21,
-  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 5,
-  49, BROTLI_TRANSFORM_IDENTITY, 37,
-   0, BROTLI_TRANSFORM_IDENTITY, 30,
-  49, BROTLI_TRANSFORM_IDENTITY, 38,
-   0, BROTLI_TRANSFORM_UPPERCASE_ALL, 0,
-  49, BROTLI_TRANSFORM_IDENTITY, 39,
-   0, BROTLI_TRANSFORM_UPPERCASE_ALL, 49,
-  49, BROTLI_TRANSFORM_IDENTITY, 34,
-  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 8,
-  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 12,
-   0, BROTLI_TRANSFORM_IDENTITY, 21,
-  49, BROTLI_TRANSFORM_IDENTITY, 40,
-   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 12,
-  49, BROTLI_TRANSFORM_IDENTITY, 41,
-  49, BROTLI_TRANSFORM_IDENTITY, 42,
-  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 17,
-  49, BROTLI_TRANSFORM_IDENTITY, 43,
-   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 5,
-  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 10,
-   0, BROTLI_TRANSFORM_IDENTITY, 34,
-  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 33,
-  49, BROTLI_TRANSFORM_IDENTITY, 44,
-  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 5,
-  45, BROTLI_TRANSFORM_IDENTITY, 49,
-   0, BROTLI_TRANSFORM_IDENTITY, 33,
-  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 30,
-  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 30,
-  49, BROTLI_TRANSFORM_IDENTITY, 46,
-  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 1,
-  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 34,
-   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 33,
-   0, BROTLI_TRANSFORM_UPPERCASE_ALL, 30,
-   0, BROTLI_TRANSFORM_UPPERCASE_ALL, 1,
-  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 33,
-  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 21,
-  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 12,
-   0, BROTLI_TRANSFORM_UPPERCASE_ALL, 5,
-  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 34,
-   0, BROTLI_TRANSFORM_UPPERCASE_ALL, 12,
-   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 30,
-   0, BROTLI_TRANSFORM_UPPERCASE_ALL, 34,
-   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 34,
-};
-
-static BrotliTransforms kBrotliTransforms = {
-  sizeof(kPrefixSuffix),
-  (const uint8_t*)kPrefixSuffix,
-  kPrefixSuffixMap,
-  sizeof(kTransformsData) / (3 * sizeof(kTransformsData[0])),
-  kTransformsData,
-  {0, 12, 27, 23, 42, 63, 56, 48, 59, 64}
-};
-
-const BrotliTransforms* BrotliGetTransforms(void) {
-  return &kBrotliTransforms;
-}
-
-static int ToUpperCase(uint8_t* p) {
-  if (p[0] < 0xC0) {
-    if (p[0] >= 'a' && p[0] <= 'z') {
-      p[0] ^= 32;
-    }
-    return 1;
-  }
-  /* An overly simplified uppercasing model for UTF-8. */
-  if (p[0] < 0xE0) {
-    p[1] ^= 32;
-    return 2;
-  }
-  /* An arbitrary transform for three byte characters. */
-  p[2] ^= 5;
-  return 3;
-}
-
-int BrotliTransformDictionaryWord(uint8_t* dst, const uint8_t* word, int len,
-    const BrotliTransforms* transforms, int transform_idx) {
-  int idx = 0;
-  const uint8_t* prefix = BROTLI_TRANSFORM_PREFIX(transforms, transform_idx);
-  uint8_t type = BROTLI_TRANSFORM_TYPE(transforms, transform_idx);
-  const uint8_t* suffix = BROTLI_TRANSFORM_SUFFIX(transforms, transform_idx);
-  {
-    int prefix_len = *prefix++;
-    while (prefix_len--) { dst[idx++] = *prefix++; }
-  }
-  {
-    const int t = type;
-    int i = 0;
-    if (t <= BROTLI_TRANSFORM_OMIT_LAST_9) {
-      len -= t;
-    } else if (t >= BROTLI_TRANSFORM_OMIT_FIRST_1
-        && t <= BROTLI_TRANSFORM_OMIT_FIRST_9) {
-      int skip = t - (BROTLI_TRANSFORM_OMIT_FIRST_1 - 1);
-      word += skip;
-      len -= skip;
-    }
-    while (i < len) { dst[idx++] = word[i++]; }
-    if (t == BROTLI_TRANSFORM_UPPERCASE_FIRST) {
-      ToUpperCase(&dst[idx - len]);
-    } else if (t == BROTLI_TRANSFORM_UPPERCASE_ALL) {
-      uint8_t* uppercase = &dst[idx - len];
-      while (len > 0) {
-        int step = ToUpperCase(uppercase);
-        uppercase += step;
-        len -= step;
-      }
-    }
-  }
-  {
-    int suffix_len = *suffix++;
-    while (suffix_len--) { dst[idx++] = *suffix++; }
-    return idx;
-  }
-}
-
-#if defined(__cplusplus) || defined(c_plusplus)
-}  /* extern "C" */
-#endif
+/* Copyright 2013 Google Inc. All Rights Reserved. 
+ 
+   Distributed under MIT license. 
+   See file LICENSE for detail or copy at https://opensource.org/licenses/MIT 
+*/ 
+ 
+#include "./transform.h" 
+ 
+#if defined(__cplusplus) || defined(c_plusplus) 
+extern "C" { 
+#endif 
+ 
+/* RFC 7932 transforms string data */ 
+static const char kPrefixSuffix[217] = 
+      "\1 \2, \10 of the \4 of \2s \1.\5 and \4 " 
+/* 0x  _0 _2  __5        _E    _3  _6 _8     _E */ 
+      "in \1\"\4 to \2\">\1\n\2. \1]\5 for \3 a \6 " 
+/* 2x     _3_ _5    _A_  _D_ _F  _2 _4     _A   _E */ 
+      "that \1\'\6 with \6 from \4 by \1(\6. T" 
+/* 4x       _5_ _7      _E      _5    _A _C */ 
+      "he \4 on \4 as \4 is \4ing \2\n\t\1:\3ed " 
+/* 6x     _3    _8    _D    _2    _7_ _ _A _C */ 
+      "\2=\"\4 at \3ly \1,\2=\'\5.com/\7. This \5" 
+/* 8x  _0 _ _3    _8   _C _E _ _1     _7       _F */ 
+      " not \3er \3al \4ful \4ive \5less \4es" 
+/* Ax       _5   _9   _D    _2    _7     _D */ 
+      "t \4ize \2\xc2\xa0\4ous \5 the \2e \0"; 
+/* Cx    _2    _7___ ___ _A    _F     _5  _8 */ 
+ 
+static const uint16_t kPrefixSuffixMap[50] = { 
+  0x00, 0x02, 0x05, 0x0E, 0x13, 0x16, 0x18, 0x1E, 0x23, 0x25, 
+  0x2A, 0x2D, 0x2F, 0x32, 0x34, 0x3A, 0x3E, 0x45, 0x47, 0x4E, 
+  0x55, 0x5A, 0x5C, 0x63, 0x68, 0x6D, 0x72, 0x77, 0x7A, 0x7C, 
+  0x80, 0x83, 0x88, 0x8C, 0x8E, 0x91, 0x97, 0x9F, 0xA5, 0xA9, 
+  0xAD, 0xB2, 0xB7, 0xBD, 0xC2, 0xC7, 0xCA, 0xCF, 0xD5, 0xD8 
+}; 
+ 
+/* RFC 7932 transforms */ 
+static const uint8_t kTransformsData[] = { 
+  49, BROTLI_TRANSFORM_IDENTITY, 49, 
+  49, BROTLI_TRANSFORM_IDENTITY, 0, 
+   0, BROTLI_TRANSFORM_IDENTITY, 0, 
+  49, BROTLI_TRANSFORM_OMIT_FIRST_1, 49, 
+  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 0, 
+  49, BROTLI_TRANSFORM_IDENTITY, 47, 
+   0, BROTLI_TRANSFORM_IDENTITY, 49, 
+   4, BROTLI_TRANSFORM_IDENTITY, 0, 
+  49, BROTLI_TRANSFORM_IDENTITY, 3, 
+  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 49, 
+  49, BROTLI_TRANSFORM_IDENTITY, 6, 
+  49, BROTLI_TRANSFORM_OMIT_FIRST_2, 49, 
+  49, BROTLI_TRANSFORM_OMIT_LAST_1, 49, 
+   1, BROTLI_TRANSFORM_IDENTITY, 0, 
+  49, BROTLI_TRANSFORM_IDENTITY, 1, 
+   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 0, 
+  49, BROTLI_TRANSFORM_IDENTITY, 7, 
+  49, BROTLI_TRANSFORM_IDENTITY, 9, 
+  48, BROTLI_TRANSFORM_IDENTITY, 0, 
+  49, BROTLI_TRANSFORM_IDENTITY, 8, 
+  49, BROTLI_TRANSFORM_IDENTITY, 5, 
+  49, BROTLI_TRANSFORM_IDENTITY, 10, 
+  49, BROTLI_TRANSFORM_IDENTITY, 11, 
+  49, BROTLI_TRANSFORM_OMIT_LAST_3, 49, 
+  49, BROTLI_TRANSFORM_IDENTITY, 13, 
+  49, BROTLI_TRANSFORM_IDENTITY, 14, 
+  49, BROTLI_TRANSFORM_OMIT_FIRST_3, 49, 
+  49, BROTLI_TRANSFORM_OMIT_LAST_2, 49, 
+  49, BROTLI_TRANSFORM_IDENTITY, 15, 
+  49, BROTLI_TRANSFORM_IDENTITY, 16, 
+   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 49, 
+  49, BROTLI_TRANSFORM_IDENTITY, 12, 
+   5, BROTLI_TRANSFORM_IDENTITY, 49, 
+   0, BROTLI_TRANSFORM_IDENTITY, 1, 
+  49, BROTLI_TRANSFORM_OMIT_FIRST_4, 49, 
+  49, BROTLI_TRANSFORM_IDENTITY, 18, 
+  49, BROTLI_TRANSFORM_IDENTITY, 17, 
+  49, BROTLI_TRANSFORM_IDENTITY, 19, 
+  49, BROTLI_TRANSFORM_IDENTITY, 20, 
+  49, BROTLI_TRANSFORM_OMIT_FIRST_5, 49, 
+  49, BROTLI_TRANSFORM_OMIT_FIRST_6, 49, 
+  47, BROTLI_TRANSFORM_IDENTITY, 49, 
+  49, BROTLI_TRANSFORM_OMIT_LAST_4, 49, 
+  49, BROTLI_TRANSFORM_IDENTITY, 22, 
+  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 49, 
+  49, BROTLI_TRANSFORM_IDENTITY, 23, 
+  49, BROTLI_TRANSFORM_IDENTITY, 24, 
+  49, BROTLI_TRANSFORM_IDENTITY, 25, 
+  49, BROTLI_TRANSFORM_OMIT_LAST_7, 49, 
+  49, BROTLI_TRANSFORM_OMIT_LAST_1, 26, 
+  49, BROTLI_TRANSFORM_IDENTITY, 27, 
+  49, BROTLI_TRANSFORM_IDENTITY, 28, 
+   0, BROTLI_TRANSFORM_IDENTITY, 12, 
+  49, BROTLI_TRANSFORM_IDENTITY, 29, 
+  49, BROTLI_TRANSFORM_OMIT_FIRST_9, 49, 
+  49, BROTLI_TRANSFORM_OMIT_FIRST_7, 49, 
+  49, BROTLI_TRANSFORM_OMIT_LAST_6, 49, 
+  49, BROTLI_TRANSFORM_IDENTITY, 21, 
+  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 1, 
+  49, BROTLI_TRANSFORM_OMIT_LAST_8, 49, 
+  49, BROTLI_TRANSFORM_IDENTITY, 31, 
+  49, BROTLI_TRANSFORM_IDENTITY, 32, 
+  47, BROTLI_TRANSFORM_IDENTITY, 3, 
+  49, BROTLI_TRANSFORM_OMIT_LAST_5, 49, 
+  49, BROTLI_TRANSFORM_OMIT_LAST_9, 49, 
+   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 1, 
+  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 8, 
+   5, BROTLI_TRANSFORM_IDENTITY, 21, 
+  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 0, 
+  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 10, 
+  49, BROTLI_TRANSFORM_IDENTITY, 30, 
+   0, BROTLI_TRANSFORM_IDENTITY, 5, 
+  35, BROTLI_TRANSFORM_IDENTITY, 49, 
+  47, BROTLI_TRANSFORM_IDENTITY, 2, 
+  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 17, 
+  49, BROTLI_TRANSFORM_IDENTITY, 36, 
+  49, BROTLI_TRANSFORM_IDENTITY, 33, 
+   5, BROTLI_TRANSFORM_IDENTITY, 0, 
+  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 21, 
+  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 5, 
+  49, BROTLI_TRANSFORM_IDENTITY, 37, 
+   0, BROTLI_TRANSFORM_IDENTITY, 30, 
+  49, BROTLI_TRANSFORM_IDENTITY, 38, 
+   0, BROTLI_TRANSFORM_UPPERCASE_ALL, 0, 
+  49, BROTLI_TRANSFORM_IDENTITY, 39, 
+   0, BROTLI_TRANSFORM_UPPERCASE_ALL, 49, 
+  49, BROTLI_TRANSFORM_IDENTITY, 34, 
+  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 8, 
+  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 12, 
+   0, BROTLI_TRANSFORM_IDENTITY, 21, 
+  49, BROTLI_TRANSFORM_IDENTITY, 40, 
+   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 12, 
+  49, BROTLI_TRANSFORM_IDENTITY, 41, 
+  49, BROTLI_TRANSFORM_IDENTITY, 42, 
+  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 17, 
+  49, BROTLI_TRANSFORM_IDENTITY, 43, 
+   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 5, 
+  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 10, 
+   0, BROTLI_TRANSFORM_IDENTITY, 34, 
+  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 33, 
+  49, BROTLI_TRANSFORM_IDENTITY, 44, 
+  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 5, 
+  45, BROTLI_TRANSFORM_IDENTITY, 49, 
+   0, BROTLI_TRANSFORM_IDENTITY, 33, 
+  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 30, 
+  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 30, 
+  49, BROTLI_TRANSFORM_IDENTITY, 46, 
+  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 1, 
+  49, BROTLI_TRANSFORM_UPPERCASE_FIRST, 34, 
+   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 33, 
+   0, BROTLI_TRANSFORM_UPPERCASE_ALL, 30, 
+   0, BROTLI_TRANSFORM_UPPERCASE_ALL, 1, 
+  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 33, 
+  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 21, 
+  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 12, 
+   0, BROTLI_TRANSFORM_UPPERCASE_ALL, 5, 
+  49, BROTLI_TRANSFORM_UPPERCASE_ALL, 34, 
+   0, BROTLI_TRANSFORM_UPPERCASE_ALL, 12, 
+   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 30, 
+   0, BROTLI_TRANSFORM_UPPERCASE_ALL, 34, 
+   0, BROTLI_TRANSFORM_UPPERCASE_FIRST, 34, 
+}; 
+ 
+static BrotliTransforms kBrotliTransforms = { 
+  sizeof(kPrefixSuffix), 
+  (const uint8_t*)kPrefixSuffix, 
+  kPrefixSuffixMap, 
+  sizeof(kTransformsData) / (3 * sizeof(kTransformsData[0])), 
+  kTransformsData, 
+  {0, 12, 27, 23, 42, 63, 56, 48, 59, 64} 
+}; 
+ 
+const BrotliTransforms* BrotliGetTransforms(void) { 
+  return &kBrotliTransforms; 
+} 
+ 
+static int ToUpperCase(uint8_t* p) { 
+  if (p[0] < 0xC0) { 
+    if (p[0] >= 'a' && p[0] <= 'z') { 
+      p[0] ^= 32; 
+    } 
+    return 1; 
+  } 
+  /* An overly simplified uppercasing model for UTF-8. */ 
+  if (p[0] < 0xE0) { 
+    p[1] ^= 32; 
+    return 2; 
+  } 
+  /* An arbitrary transform for three byte characters. */ 
+  p[2] ^= 5; 
+  return 3; 
+} 
+ 
+int BrotliTransformDictionaryWord(uint8_t* dst, const uint8_t* word, int len, 
+    const BrotliTransforms* transforms, int transform_idx) { 
+  int idx = 0; 
+  const uint8_t* prefix = BROTLI_TRANSFORM_PREFIX(transforms, transform_idx); 
+  uint8_t type = BROTLI_TRANSFORM_TYPE(transforms, transform_idx); 
+  const uint8_t* suffix = BROTLI_TRANSFORM_SUFFIX(transforms, transform_idx); 
+  { 
+    int prefix_len = *prefix++; 
+    while (prefix_len--) { dst[idx++] = *prefix++; } 
+  } 
+  { 
+    const int t = type; 
+    int i = 0; 
+    if (t <= BROTLI_TRANSFORM_OMIT_LAST_9) { 
+      len -= t; 
+    } else if (t >= BROTLI_TRANSFORM_OMIT_FIRST_1 
+        && t <= BROTLI_TRANSFORM_OMIT_FIRST_9) { 
+      int skip = t - (BROTLI_TRANSFORM_OMIT_FIRST_1 - 1); 
+      word += skip; 
+      len -= skip; 
+    } 
+    while (i < len) { dst[idx++] = word[i++]; } 
+    if (t == BROTLI_TRANSFORM_UPPERCASE_FIRST) { 
+      ToUpperCase(&dst[idx - len]); 
+    } else if (t == BROTLI_TRANSFORM_UPPERCASE_ALL) { 
+      uint8_t* uppercase = &dst[idx - len]; 
+      while (len > 0) { 
+        int step = ToUpperCase(uppercase); 
+        uppercase += step; 
+        len -= step; 
+      } 
+    } 
+  } 
+  { 
+    int suffix_len = *suffix++; 
+    while (suffix_len--) { dst[idx++] = *suffix++; } 
+    return idx; 
+  } 
+} 
+ 
+#if defined(__cplusplus) || defined(c_plusplus) 
+}  /* extern "C" */ 
+#endif 

+ 80 - 80
contrib/libs/brotli/common/transform.h

@@ -1,80 +1,80 @@
-/* transforms is a part of ABI, but not API.
-
-   It means that there are some functions that are supposed to be in "common"
-   library, but header itself is not placed into include/brotli. This way,
-   aforementioned functions will be available only to brotli internals.
- */
-
-#ifndef BROTLI_COMMON_TRANSFORM_H_
-#define BROTLI_COMMON_TRANSFORM_H_
-
-#include <brotli/port.h>
-#include <brotli/types.h>
-
-#if defined(__cplusplus) || defined(c_plusplus)
-extern "C" {
-#endif
-
-enum BrotliWordTransformType {
-  BROTLI_TRANSFORM_IDENTITY = 0,
-  BROTLI_TRANSFORM_OMIT_LAST_1 = 1,
-  BROTLI_TRANSFORM_OMIT_LAST_2 = 2,
-  BROTLI_TRANSFORM_OMIT_LAST_3 = 3,
-  BROTLI_TRANSFORM_OMIT_LAST_4 = 4,
-  BROTLI_TRANSFORM_OMIT_LAST_5 = 5,
-  BROTLI_TRANSFORM_OMIT_LAST_6 = 6,
-  BROTLI_TRANSFORM_OMIT_LAST_7 = 7,
-  BROTLI_TRANSFORM_OMIT_LAST_8 = 8,
-  BROTLI_TRANSFORM_OMIT_LAST_9 = 9,
-  BROTLI_TRANSFORM_UPPERCASE_FIRST = 10,
-  BROTLI_TRANSFORM_UPPERCASE_ALL = 11,
-  BROTLI_TRANSFORM_OMIT_FIRST_1 = 12,
-  BROTLI_TRANSFORM_OMIT_FIRST_2 = 13,
-  BROTLI_TRANSFORM_OMIT_FIRST_3 = 14,
-  BROTLI_TRANSFORM_OMIT_FIRST_4 = 15,
-  BROTLI_TRANSFORM_OMIT_FIRST_5 = 16,
-  BROTLI_TRANSFORM_OMIT_FIRST_6 = 17,
-  BROTLI_TRANSFORM_OMIT_FIRST_7 = 18,
-  BROTLI_TRANSFORM_OMIT_FIRST_8 = 19,
-  BROTLI_TRANSFORM_OMIT_FIRST_9 = 20,
-  BROTLI_NUM_TRANSFORM_TYPES  /* Counts transforms, not a transform itself. */
-};
-
-#define BROTLI_TRANSFORMS_MAX_CUT_OFF BROTLI_TRANSFORM_OMIT_LAST_9
-
-typedef struct BrotliTransforms {
-  uint16_t prefix_suffix_size;
-  /* Last character must be null, so prefix_suffix_size must be at least 1. */
-  const uint8_t* prefix_suffix;
-  const uint16_t* prefix_suffix_map;
-  uint32_t num_transforms;
-  /* Each entry is a [prefix_id, transform, suffix_id] triplet. */
-  const uint8_t* transforms;
-  /* Indices of transforms like ["", BROTLI_TRANSFORM_OMIT_LAST_#, ""].
-     0-th element corresponds to ["", BROTLI_TRANSFORM_IDENTITY, ""].
-     -1, if cut-off transform does not exist. */
-  int16_t cutOffTransforms[BROTLI_TRANSFORMS_MAX_CUT_OFF + 1];
-} BrotliTransforms;
-
-/* T is BrotliTransforms*; result is uint8_t. */
-#define BROTLI_TRANSFORM_PREFIX_ID(T, I) ((T)->transforms[((I) * 3) + 0])
-#define BROTLI_TRANSFORM_TYPE(T, I)      ((T)->transforms[((I) * 3) + 1])
-#define BROTLI_TRANSFORM_SUFFIX_ID(T, I) ((T)->transforms[((I) * 3) + 2])
-
-/* T is BrotliTransforms*; result is const uint8_t*. */
-#define BROTLI_TRANSFORM_PREFIX(T, I) (&(T)->prefix_suffix[ \
-    (T)->prefix_suffix_map[BROTLI_TRANSFORM_PREFIX_ID(T, I)]])
-#define BROTLI_TRANSFORM_SUFFIX(T, I) (&(T)->prefix_suffix[ \
-    (T)->prefix_suffix_map[BROTLI_TRANSFORM_SUFFIX_ID(T, I)]])
-
-BROTLI_COMMON_API const BrotliTransforms* BrotliGetTransforms(void);
-
-BROTLI_COMMON_API int BrotliTransformDictionaryWord(
-    uint8_t* dst, const uint8_t* word, int len,
-    const BrotliTransforms* transforms, int transform_idx);
-
-#if defined(__cplusplus) || defined(c_plusplus)
-}  /* extern "C" */
-#endif
-
-#endif  /* BROTLI_COMMON_TRANSFORM_H_ */
+/* transforms is a part of ABI, but not API. 
+ 
+   It means that there are some functions that are supposed to be in "common" 
+   library, but header itself is not placed into include/brotli. This way, 
+   aforementioned functions will be available only to brotli internals. 
+ */ 
+ 
+#ifndef BROTLI_COMMON_TRANSFORM_H_ 
+#define BROTLI_COMMON_TRANSFORM_H_ 
+ 
+#include <brotli/port.h> 
+#include <brotli/types.h> 
+ 
+#if defined(__cplusplus) || defined(c_plusplus) 
+extern "C" { 
+#endif 
+ 
+enum BrotliWordTransformType { 
+  BROTLI_TRANSFORM_IDENTITY = 0, 
+  BROTLI_TRANSFORM_OMIT_LAST_1 = 1, 
+  BROTLI_TRANSFORM_OMIT_LAST_2 = 2, 
+  BROTLI_TRANSFORM_OMIT_LAST_3 = 3, 
+  BROTLI_TRANSFORM_OMIT_LAST_4 = 4, 
+  BROTLI_TRANSFORM_OMIT_LAST_5 = 5, 
+  BROTLI_TRANSFORM_OMIT_LAST_6 = 6, 
+  BROTLI_TRANSFORM_OMIT_LAST_7 = 7, 
+  BROTLI_TRANSFORM_OMIT_LAST_8 = 8, 
+  BROTLI_TRANSFORM_OMIT_LAST_9 = 9, 
+  BROTLI_TRANSFORM_UPPERCASE_FIRST = 10, 
+  BROTLI_TRANSFORM_UPPERCASE_ALL = 11, 
+  BROTLI_TRANSFORM_OMIT_FIRST_1 = 12, 
+  BROTLI_TRANSFORM_OMIT_FIRST_2 = 13, 
+  BROTLI_TRANSFORM_OMIT_FIRST_3 = 14, 
+  BROTLI_TRANSFORM_OMIT_FIRST_4 = 15, 
+  BROTLI_TRANSFORM_OMIT_FIRST_5 = 16, 
+  BROTLI_TRANSFORM_OMIT_FIRST_6 = 17, 
+  BROTLI_TRANSFORM_OMIT_FIRST_7 = 18, 
+  BROTLI_TRANSFORM_OMIT_FIRST_8 = 19, 
+  BROTLI_TRANSFORM_OMIT_FIRST_9 = 20, 
+  BROTLI_NUM_TRANSFORM_TYPES  /* Counts transforms, not a transform itself. */ 
+}; 
+ 
+#define BROTLI_TRANSFORMS_MAX_CUT_OFF BROTLI_TRANSFORM_OMIT_LAST_9 
+ 
+typedef struct BrotliTransforms { 
+  uint16_t prefix_suffix_size; 
+  /* Last character must be null, so prefix_suffix_size must be at least 1. */ 
+  const uint8_t* prefix_suffix; 
+  const uint16_t* prefix_suffix_map; 
+  uint32_t num_transforms; 
+  /* Each entry is a [prefix_id, transform, suffix_id] triplet. */ 
+  const uint8_t* transforms; 
+  /* Indices of transforms like ["", BROTLI_TRANSFORM_OMIT_LAST_#, ""]. 
+     0-th element corresponds to ["", BROTLI_TRANSFORM_IDENTITY, ""]. 
+     -1, if cut-off transform does not exist. */ 
+  int16_t cutOffTransforms[BROTLI_TRANSFORMS_MAX_CUT_OFF + 1]; 
+} BrotliTransforms; 
+ 
+/* T is BrotliTransforms*; result is uint8_t. */ 
+#define BROTLI_TRANSFORM_PREFIX_ID(T, I) ((T)->transforms[((I) * 3) + 0]) 
+#define BROTLI_TRANSFORM_TYPE(T, I)      ((T)->transforms[((I) * 3) + 1]) 
+#define BROTLI_TRANSFORM_SUFFIX_ID(T, I) ((T)->transforms[((I) * 3) + 2]) 
+ 
+/* T is BrotliTransforms*; result is const uint8_t*. */ 
+#define BROTLI_TRANSFORM_PREFIX(T, I) (&(T)->prefix_suffix[ \ 
+    (T)->prefix_suffix_map[BROTLI_TRANSFORM_PREFIX_ID(T, I)]]) 
+#define BROTLI_TRANSFORM_SUFFIX(T, I) (&(T)->prefix_suffix[ \ 
+    (T)->prefix_suffix_map[BROTLI_TRANSFORM_SUFFIX_ID(T, I)]]) 
+ 
+BROTLI_COMMON_API const BrotliTransforms* BrotliGetTransforms(void); 
+ 
+BROTLI_COMMON_API int BrotliTransformDictionaryWord( 
+    uint8_t* dst, const uint8_t* word, int len, 
+    const BrotliTransforms* transforms, int transform_idx); 
+ 
+#if defined(__cplusplus) || defined(c_plusplus) 
+}  /* extern "C" */ 
+#endif 
+ 
+#endif  /* BROTLI_COMMON_TRANSFORM_H_ */ 

+ 9 - 9
contrib/libs/brotli/common/version.h

@@ -14,13 +14,13 @@
    BrotliEncoderVersion methods. */
 
 /* Semantic version, calculated as (MAJOR << 24) | (MINOR << 12) | PATCH */
-#define BROTLI_VERSION 0x1000007
-
-/* This macro is used by build system to produce Libtool-friendly soname. See
-   https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html
- */
-
-/* ABI version, calculated as (CURRENT << 24) | (REVISION << 12) | AGE */
-#define BROTLI_ABI_VERSION 0x1007000
-
+#define BROTLI_VERSION 0x1000007 
+
+/* This macro is used by build system to produce Libtool-friendly soname. See 
+   https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html 
+ */ 
+ 
+/* ABI version, calculated as (CURRENT << 24) | (REVISION << 12) | AGE */ 
+#define BROTLI_ABI_VERSION 0x1007000 
+ 
 #endif  /* BROTLI_COMMON_VERSION_H_ */

+ 1 - 1
contrib/libs/brotli/common/ya.make

@@ -18,7 +18,7 @@ ADDINCL(contrib/libs/brotli/include)
 
 SRCS(
     dictionary.c
-    transform.c
+    transform.c 
 )
 
 CFLAGS(-DBROTLI_BUILD_PORTABLE)

+ 1 - 1
contrib/libs/brotli/dec/bit_reader.c

@@ -8,7 +8,7 @@
 
 #include "./bit_reader.h"
 
-#include "../common/platform.h"
+#include "../common/platform.h" 
 #include <brotli/types.h>
 
 #if defined(__cplusplus) || defined(c_plusplus)

+ 35 - 35
contrib/libs/brotli/dec/bit_reader.h

@@ -11,16 +11,16 @@
 
 #include <string.h>  /* memcpy */
 
-#include "../common/platform.h"
+#include "../common/platform.h" 
 #include <brotli/types.h>
 
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
 
-#define BROTLI_SHORT_FILL_BIT_WINDOW_READ (sizeof(brotli_reg_t) >> 1)
+#define BROTLI_SHORT_FILL_BIT_WINDOW_READ (sizeof(brotli_reg_t) >> 1) 
 
-static const uint32_t kBitMask[33] = {  0x00000000,
+static const uint32_t kBitMask[33] = {  0x00000000, 
     0x00000001, 0x00000003, 0x00000007, 0x0000000F,
     0x0000001F, 0x0000003F, 0x0000007F, 0x000000FF,
     0x000001FF, 0x000003FF, 0x000007FF, 0x00000FFF,
@@ -32,24 +32,24 @@ static const uint32_t kBitMask[33] = {  0x00000000,
 };
 
 static BROTLI_INLINE uint32_t BitMask(uint32_t n) {
-  if (BROTLI_IS_CONSTANT(n) || BROTLI_HAS_UBFX) {
+  if (BROTLI_IS_CONSTANT(n) || BROTLI_HAS_UBFX) { 
     /* Masking with this expression turns to a single
        "Unsigned Bit Field Extract" UBFX instruction on ARM. */
-    return ~((0xFFFFFFFFu) << n);
+    return ~((0xFFFFFFFFu) << n); 
   } else {
     return kBitMask[n];
   }
 }
 
 typedef struct {
-  brotli_reg_t val_;       /* pre-fetched bits */
+  brotli_reg_t val_;       /* pre-fetched bits */ 
   uint32_t bit_pos_;       /* current bit-reading position in val_ */
   const uint8_t* next_in;  /* the byte we're reading from */
   size_t avail_in;
 } BrotliBitReader;
 
 typedef struct {
-  brotli_reg_t val_;
+  brotli_reg_t val_; 
   uint32_t bit_pos_;
   const uint8_t* next_in;
   size_t avail_in;
@@ -58,9 +58,9 @@ typedef struct {
 /* Initializes the BrotliBitReader fields. */
 BROTLI_INTERNAL void BrotliInitBitReader(BrotliBitReader* const br);
 
-/* Ensures that accumulator is not empty.
-   May consume up to sizeof(brotli_reg_t) - 1 bytes of input.
-   Returns BROTLI_FALSE if data is required but there is no input available.
+/* Ensures that accumulator is not empty. 
+   May consume up to sizeof(brotli_reg_t) - 1 bytes of input. 
+   Returns BROTLI_FALSE if data is required but there is no input available. 
    For BROTLI_ALIGNED_READ this function also prepares bit reader for aligned
    reading. */
 BROTLI_INTERNAL BROTLI_BOOL BrotliWarmupBitReader(BrotliBitReader* const br);
@@ -99,27 +99,27 @@ static BROTLI_INLINE BROTLI_BOOL BrotliCheckInputAmount(
   return TO_BROTLI_BOOL(br->avail_in >= num);
 }
 
-/* Guarantees that there are at least |n_bits| + 1 bits in accumulator.
+/* Guarantees that there are at least |n_bits| + 1 bits in accumulator. 
    Precondition: accumulator contains at least 1 bit.
-   |n_bits| should be in the range [1..24] for regular build. For portable
+   |n_bits| should be in the range [1..24] for regular build. For portable 
    non-64-bit little-endian build only 16 bits are safe to request. */
 static BROTLI_INLINE void BrotliFillBitWindow(
     BrotliBitReader* const br, uint32_t n_bits) {
 #if (BROTLI_64_BITS)
-  if (!BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 8)) {
+  if (!BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 8)) { 
     if (br->bit_pos_ >= 56) {
       br->val_ >>= 56;
       br->bit_pos_ ^= 56;  /* here same as -= 56 because of the if condition */
-      br->val_ |= BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 8;
+      br->val_ |= BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 8; 
       br->avail_in -= 7;
       br->next_in += 7;
     }
-  } else if (
-      !BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 16)) {
+  } else if ( 
+      !BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 16)) { 
     if (br->bit_pos_ >= 48) {
       br->val_ >>= 48;
       br->bit_pos_ ^= 48;  /* here same as -= 48 because of the if condition */
-      br->val_ |= BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 16;
+      br->val_ |= BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 16; 
       br->avail_in -= 6;
       br->next_in += 6;
     }
@@ -127,17 +127,17 @@ static BROTLI_INLINE void BrotliFillBitWindow(
     if (br->bit_pos_ >= 32) {
       br->val_ >>= 32;
       br->bit_pos_ ^= 32;  /* here same as -= 32 because of the if condition */
-      br->val_ |= ((uint64_t)BROTLI_UNALIGNED_LOAD32LE(br->next_in)) << 32;
+      br->val_ |= ((uint64_t)BROTLI_UNALIGNED_LOAD32LE(br->next_in)) << 32; 
       br->avail_in -= BROTLI_SHORT_FILL_BIT_WINDOW_READ;
       br->next_in += BROTLI_SHORT_FILL_BIT_WINDOW_READ;
     }
   }
 #else
-  if (!BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 8)) {
+  if (!BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 8)) { 
     if (br->bit_pos_ >= 24) {
       br->val_ >>= 24;
       br->bit_pos_ ^= 24;  /* here same as -= 24 because of the if condition */
-      br->val_ |= BROTLI_UNALIGNED_LOAD32LE(br->next_in) << 8;
+      br->val_ |= BROTLI_UNALIGNED_LOAD32LE(br->next_in) << 8; 
       br->avail_in -= 3;
       br->next_in += 3;
     }
@@ -145,7 +145,7 @@ static BROTLI_INLINE void BrotliFillBitWindow(
     if (br->bit_pos_ >= 16) {
       br->val_ >>= 16;
       br->bit_pos_ ^= 16;  /* here same as -= 16 because of the if condition */
-      br->val_ |= ((uint32_t)BROTLI_UNALIGNED_LOAD16LE(br->next_in)) << 16;
+      br->val_ |= ((uint32_t)BROTLI_UNALIGNED_LOAD16LE(br->next_in)) << 16; 
       br->avail_in -= BROTLI_SHORT_FILL_BIT_WINDOW_READ;
       br->next_in += BROTLI_SHORT_FILL_BIT_WINDOW_READ;
     }
@@ -159,8 +159,8 @@ static BROTLI_INLINE void BrotliFillBitWindow16(BrotliBitReader* const br) {
   BrotliFillBitWindow(br, 17);
 }
 
-/* Tries to pull one byte of input to accumulator.
-   Returns BROTLI_FALSE if there is no input available. */
+/* Tries to pull one byte of input to accumulator. 
+   Returns BROTLI_FALSE if there is no input available. */ 
 static BROTLI_INLINE BROTLI_BOOL BrotliPullByte(BrotliBitReader* const br) {
   if (br->avail_in == 0) {
     return BROTLI_FALSE;
@@ -179,8 +179,8 @@ static BROTLI_INLINE BROTLI_BOOL BrotliPullByte(BrotliBitReader* const br) {
 
 /* Returns currently available bits.
    The number of valid bits could be calculated by BrotliGetAvailableBits. */
-static BROTLI_INLINE brotli_reg_t BrotliGetBitsUnmasked(
-    BrotliBitReader* const br) {
+static BROTLI_INLINE brotli_reg_t BrotliGetBitsUnmasked( 
+    BrotliBitReader* const br) { 
   return br->val_ >> br->bit_pos_;
 }
 
@@ -192,16 +192,16 @@ static BROTLI_INLINE uint32_t BrotliGet16BitsUnmasked(
   return (uint32_t)BrotliGetBitsUnmasked(br);
 }
 
-/* Returns the specified number of bits from |br| without advancing bit
-   position. */
+/* Returns the specified number of bits from |br| without advancing bit 
+   position. */ 
 static BROTLI_INLINE uint32_t BrotliGetBits(
     BrotliBitReader* const br, uint32_t n_bits) {
   BrotliFillBitWindow(br, n_bits);
   return (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits);
 }
 
-/* Tries to peek the specified amount of bits. Returns BROTLI_FALSE, if there
-   is not enough input. */
+/* Tries to peek the specified amount of bits. Returns BROTLI_FALSE, if there 
+   is not enough input. */ 
 static BROTLI_INLINE BROTLI_BOOL BrotliSafeGetBits(
     BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) {
   while (BrotliGetAvailableBits(br) < n_bits) {
@@ -213,7 +213,7 @@ static BROTLI_INLINE BROTLI_BOOL BrotliSafeGetBits(
   return BROTLI_TRUE;
 }
 
-/* Advances the bit pos by |n_bits|. */
+/* Advances the bit pos by |n_bits|. */ 
 static BROTLI_INLINE void BrotliDropBits(
     BrotliBitReader* const br, uint32_t n_bits) {
   br->bit_pos_ += n_bits;
@@ -233,12 +233,12 @@ static BROTLI_INLINE void BrotliBitReaderUnload(BrotliBitReader* br) {
 }
 
 /* Reads the specified number of bits from |br| and advances the bit pos.
-   Precondition: accumulator MUST contain at least |n_bits|. */
+   Precondition: accumulator MUST contain at least |n_bits|. */ 
 static BROTLI_INLINE void BrotliTakeBits(
   BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) {
   *val = (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits);
   BROTLI_LOG(("[BrotliReadBits]  %d %d %d val: %6x\n",
-      (int)br->avail_in, (int)br->bit_pos_, (int)n_bits, (int)*val));
+      (int)br->avail_in, (int)br->bit_pos_, (int)n_bits, (int)*val)); 
   BrotliDropBits(br, n_bits);
 }
 
@@ -262,8 +262,8 @@ static BROTLI_INLINE uint32_t BrotliReadBits(
   }
 }
 
-/* Tries to read the specified amount of bits. Returns BROTLI_FALSE, if there
-   is not enough input. |n_bits| MUST be positive. */
+/* Tries to read the specified amount of bits. Returns BROTLI_FALSE, if there 
+   is not enough input. |n_bits| MUST be positive. */ 
 static BROTLI_INLINE BROTLI_BOOL BrotliSafeReadBits(
     BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) {
   while (BrotliGetAvailableBits(br) < n_bits) {
@@ -287,7 +287,7 @@ static BROTLI_INLINE BROTLI_BOOL BrotliJumpToByteBoundary(BrotliBitReader* br) {
 }
 
 /* Copies remaining input bytes stored in the bit reader to the output. Value
-   |num| may not be larger than BrotliGetRemainingBytes. The bit reader must be
+   |num| may not be larger than BrotliGetRemainingBytes. The bit reader must be 
    warmed up again after this. */
 static BROTLI_INLINE void BrotliCopyBytes(uint8_t* dest,
                                           BrotliBitReader* br, size_t num) {

Некоторые файлы не были показаны из-за большого количества измененных файлов