]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/BrotliCompress/common/platform.h
BaseTools: Make brotli a submodule
[mirror_edk2.git] / BaseTools / Source / C / BrotliCompress / common / platform.h
diff --git a/BaseTools/Source/C/BrotliCompress/common/platform.h b/BaseTools/Source/C/BrotliCompress/common/platform.h
deleted file mode 100644 (file)
index b83ed6c..0000000
+++ /dev/null
@@ -1,558 +0,0 @@
-/* Copyright 2016 Google Inc. All Rights Reserved.\r
-\r
-   Distributed under MIT license.\r
-   See file LICENSE for detail or copy at https://opensource.org/licenses/MIT\r
-*/\r
-\r
-/* Macros for compiler / platform specific features and build options.\r
-\r
-   Build options are:\r
-    * BROTLI_BUILD_32_BIT disables 64-bit optimizations\r
-    * BROTLI_BUILD_64_BIT forces to use 64-bit optimizations\r
-    * BROTLI_BUILD_BIG_ENDIAN forces to use big-endian optimizations\r
-    * BROTLI_BUILD_ENDIAN_NEUTRAL disables endian-aware optimizations\r
-    * BROTLI_BUILD_LITTLE_ENDIAN forces to use little-endian optimizations\r
-    * BROTLI_BUILD_PORTABLE disables dangerous optimizations, like unaligned\r
-      read and overlapping memcpy; this reduces decompression speed by 5%\r
-    * BROTLI_BUILD_NO_RBIT disables "rbit" optimization for ARM CPUs\r
-    * BROTLI_DEBUG dumps file name and line number when decoder detects stream\r
-      or memory error\r
-    * BROTLI_ENABLE_LOG enables asserts and dumps various state information\r
-*/\r
-\r
-#ifndef BROTLI_COMMON_PLATFORM_H_\r
-#define BROTLI_COMMON_PLATFORM_H_\r
-\r
-#include <string.h>  /* memcpy */\r
-#include <stdlib.h>  /* malloc, free */\r
-\r
-#include <brotli/port.h>\r
-#include <brotli/types.h>\r
-\r
-#if defined(OS_LINUX) || defined(OS_CYGWIN)\r
-#include <endian.h>\r
-#elif defined(OS_FREEBSD)\r
-#include <machine/endian.h>\r
-#elif defined(OS_MACOSX)\r
-#include <machine/endian.h>\r
-/* Let's try and follow the Linux convention */\r
-#define BROTLI_X_BYTE_ORDER BYTE_ORDER\r
-#define BROTLI_X_LITTLE_ENDIAN LITTLE_ENDIAN\r
-#define BROTLI_X_BIG_ENDIAN BIG_ENDIAN\r
-#endif\r
-\r
-#if defined(BROTLI_ENABLE_LOG) || defined(BROTLI_DEBUG)\r
-#include <assert.h>\r
-#include <stdio.h>\r
-#endif\r
-\r
-/* The following macros were borrowed from https://github.com/nemequ/hedley\r
- * with permission of original author - Evan Nemerson <evan@nemerson.com> */\r
-\r
-/* >>> >>> >>> hedley macros */\r
-\r
-/* Define "BROTLI_PREDICT_TRUE" and "BROTLI_PREDICT_FALSE" macros for capable\r
-   compilers.\r
-\r
-To apply compiler hint, enclose the branching condition into macros, like this:\r
-\r
-  if (BROTLI_PREDICT_TRUE(zero == 0)) {\r
-    // main execution path\r
-  } else {\r
-    // compiler should place this code outside of main execution path\r
-  }\r
-\r
-OR:\r
-\r
-  if (BROTLI_PREDICT_FALSE(something_rare_or_unexpected_happens)) {\r
-    // compiler should place this code outside of main execution path\r
-  }\r
-\r
-*/\r
-#if BROTLI_GNUC_HAS_BUILTIN(__builtin_expect, 3, 0, 0) || \\r
-    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||               \\r
-    BROTLI_SUNPRO_VERSION_CHECK(5, 12, 0) ||              \\r
-    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                  \\r
-    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                 \\r
-    BROTLI_TI_VERSION_CHECK(7, 3, 0) ||                   \\r
-    BROTLI_TINYC_VERSION_CHECK(0, 9, 27)\r
-#define BROTLI_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))\r
-#define BROTLI_PREDICT_FALSE(x) (__builtin_expect(x, 0))\r
-#else\r
-#define BROTLI_PREDICT_FALSE(x) (x)\r
-#define BROTLI_PREDICT_TRUE(x) (x)\r
-#endif\r
-\r
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \\r
-    !defined(__cplusplus)\r
-#define BROTLI_RESTRICT restrict\r
-#elif BROTLI_GNUC_VERSION_CHECK(3, 1, 0) ||                         \\r
-    BROTLI_MSVC_VERSION_CHECK(14, 0, 0) ||                          \\r
-    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                         \\r
-    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                            \\r
-    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                           \\r
-    BROTLI_PGI_VERSION_CHECK(17, 10, 0) ||                          \\r
-    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                             \\r
-    BROTLI_IAR_VERSION_CHECK(8, 0, 0) ||                            \\r
-    (BROTLI_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus))\r
-#define BROTLI_RESTRICT __restrict\r
-#elif BROTLI_SUNPRO_VERSION_CHECK(5, 3, 0) && !defined(__cplusplus)\r
-#define BROTLI_RESTRICT _Restrict\r
-#else\r
-#define BROTLI_RESTRICT\r
-#endif\r
-\r
-#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \\r
-    (defined(__cplusplus) && (__cplusplus >= 199711L))\r
-#define BROTLI_MAYBE_INLINE inline\r
-#elif defined(__GNUC_STDC_INLINE__) || defined(__GNUC_GNU_INLINE__) || \\r
-    BROTLI_ARM_VERSION_CHECK(6, 2, 0)\r
-#define BROTLI_MAYBE_INLINE __inline__\r
-#elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0) || \\r
-    BROTLI_ARM_VERSION_CHECK(4, 1, 0) || BROTLI_TI_VERSION_CHECK(8, 0, 0)\r
-#define BROTLI_MAYBE_INLINE __inline\r
-#else\r
-#define BROTLI_MAYBE_INLINE\r
-#endif\r
-\r
-#if BROTLI_GNUC_HAS_ATTRIBUTE(always_inline, 4, 0, 0) ||                       \\r
-    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                                    \\r
-    BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) ||                                   \\r
-    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                                       \\r
-    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                                      \\r
-    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                                        \\r
-    (BROTLI_TI_VERSION_CHECK(7, 3, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))\r
-#define BROTLI_INLINE BROTLI_MAYBE_INLINE __attribute__((__always_inline__))\r
-#elif BROTLI_MSVC_VERSION_CHECK(12, 0, 0)\r
-#define BROTLI_INLINE BROTLI_MAYBE_INLINE __forceinline\r
-#elif BROTLI_TI_VERSION_CHECK(7, 0, 0) && defined(__cplusplus)\r
-#define BROTLI_INLINE BROTLI_MAYBE_INLINE _Pragma("FUNC_ALWAYS_INLINE;")\r
-#elif BROTLI_IAR_VERSION_CHECK(8, 0, 0)\r
-#define BROTLI_INLINE BROTLI_MAYBE_INLINE _Pragma("inline=forced")\r
-#else\r
-#define BROTLI_INLINE BROTLI_MAYBE_INLINE\r
-#endif\r
-\r
-#if BROTLI_GNUC_HAS_ATTRIBUTE(noinline, 4, 0, 0) ||                            \\r
-    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                                    \\r
-    BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) ||                                   \\r
-    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                                       \\r
-    BROTLI_IBM_VERSION_CHECK(10, 1, 0) ||                                      \\r
-    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                                        \\r
-    (BROTLI_TI_VERSION_CHECK(7, 3, 0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))\r
-#define BROTLI_NOINLINE __attribute__((__noinline__))\r
-#elif BROTLI_MSVC_VERSION_CHECK(13, 10, 0)\r
-#define BROTLI_NOINLINE __declspec(noinline)\r
-#elif BROTLI_PGI_VERSION_CHECK(10, 2, 0)\r
-#define BROTLI_NOINLINE _Pragma("noinline")\r
-#elif BROTLI_TI_VERSION_CHECK(6, 0, 0) && defined(__cplusplus)\r
-#define BROTLI_NOINLINE _Pragma("FUNC_CANNOT_INLINE;")\r
-#elif BROTLI_IAR_VERSION_CHECK(8, 0, 0)\r
-#define BROTLI_NOINLINE _Pragma("inline=never")\r
-#else\r
-#define BROTLI_NOINLINE\r
-#endif\r
-\r
-/* BROTLI_INTERNAL could be defined to override visibility, e.g. for tests. */\r
-#if !defined(BROTLI_INTERNAL)\r
-#if defined(_WIN32) || defined(__CYGWIN__)\r
-#define BROTLI_INTERNAL\r
-#elif BROTLI_GNUC_VERSION_CHECK(3, 3, 0) ||                         \\r
-    BROTLI_TI_VERSION_CHECK(8, 0, 0) ||                             \\r
-    BROTLI_INTEL_VERSION_CHECK(16, 0, 0) ||                         \\r
-    BROTLI_ARM_VERSION_CHECK(4, 1, 0) ||                            \\r
-    BROTLI_IBM_VERSION_CHECK(13, 1, 0) ||                           \\r
-    BROTLI_SUNPRO_VERSION_CHECK(5, 11, 0) ||                        \\r
-    (BROTLI_TI_VERSION_CHECK(7, 3, 0) &&                            \\r
-     defined(__TI_GNU_ATTRIBUTE_SUPPORT__) && defined(__TI_EABI__))\r
-#define BROTLI_INTERNAL __attribute__ ((visibility ("hidden")))\r
-#else\r
-#define BROTLI_INTERNAL\r
-#endif\r
-#endif\r
-\r
-/* <<< <<< <<< end of hedley macros. */\r
-\r
-#if BROTLI_GNUC_HAS_ATTRIBUTE(unused, 2, 7, 0) || \\r
-    BROTLI_INTEL_VERSION_CHECK(16, 0, 0)\r
-#define BROTLI_UNUSED_FUNCTION static BROTLI_INLINE __attribute__ ((unused))\r
-#else\r
-#define BROTLI_UNUSED_FUNCTION static BROTLI_INLINE\r
-#endif\r
-\r
-#if (defined(__ARM_ARCH) && (__ARM_ARCH == 7)) || \\r
-    (defined(M_ARM) && (M_ARM == 7))\r
-#define BROTLI_TARGET_ARMV7\r
-#endif  /* ARMv7 */\r
-\r
-#if (defined(__ARM_ARCH) && (__ARM_ARCH == 8)) || \\r
-    defined(__aarch64__) || defined(__ARM64_ARCH_8__)\r
-#define BROTLI_TARGET_ARMV8_ANY\r
-\r
-#if defined(__ARM_32BIT_STATE)\r
-#define BROTLI_TARGET_ARMV8_32\r
-#elif defined(__ARM_64BIT_STATE)\r
-#define BROTLI_TARGET_ARMV8_64\r
-#endif\r
-\r
-#endif  /* ARMv8 */\r
-\r
-#if defined(__i386) || defined(_M_IX86)\r
-#define BROTLI_TARGET_X86\r
-#endif\r
-\r
-#if defined(__x86_64__) || defined(_M_X64)\r
-#define BROTLI_TARGET_X64\r
-#endif\r
-\r
-#if defined(__PPC64__)\r
-#define BROTLI_TARGET_POWERPC64\r
-#endif\r
-\r
-#if defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64\r
-#define BROTLI_TARGET_RISCV64\r
-#endif\r
-\r
-#if defined(BROTLI_BUILD_64_BIT)\r
-#define BROTLI_64_BITS 1\r
-#elif defined(BROTLI_BUILD_32_BIT)\r
-#define BROTLI_64_BITS 0\r
-#elif defined(BROTLI_TARGET_X64) || defined(BROTLI_TARGET_ARMV8_64) || \\r
-    defined(BROTLI_TARGET_POWERPC64) || defined(BROTLI_TARGET_RISCV64)\r
-#define BROTLI_64_BITS 1\r
-#else\r
-#define BROTLI_64_BITS 0\r
-#endif\r
-\r
-#if (BROTLI_64_BITS)\r
-#define brotli_reg_t uint64_t\r
-#else\r
-#define brotli_reg_t uint32_t\r
-#endif\r
-\r
-#if defined(BROTLI_BUILD_BIG_ENDIAN)\r
-#define BROTLI_BIG_ENDIAN 1\r
-#elif defined(BROTLI_BUILD_LITTLE_ENDIAN)\r
-#define BROTLI_LITTLE_ENDIAN 1\r
-#elif defined(BROTLI_BUILD_ENDIAN_NEUTRAL)\r
-/* Just break elif chain. */\r
-#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)\r
-#define BROTLI_LITTLE_ENDIAN 1\r
-#elif defined(_WIN32) || defined(BROTLI_TARGET_X64)\r
-/* Win32 & x64 can currently always be assumed to be little endian */\r
-#define BROTLI_LITTLE_ENDIAN 1\r
-#elif defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)\r
-#define BROTLI_BIG_ENDIAN 1\r
-#elif defined(BROTLI_X_BYTE_ORDER)\r
-#if BROTLI_X_BYTE_ORDER == BROTLI_X_LITTLE_ENDIAN\r
-#define BROTLI_LITTLE_ENDIAN 1\r
-#elif BROTLI_X_BYTE_ORDER == BROTLI_X_BIG_ENDIAN\r
-#define BROTLI_BIG_ENDIAN 1\r
-#endif\r
-#endif  /* BROTLI_X_BYTE_ORDER */\r
-\r
-#if !defined(BROTLI_LITTLE_ENDIAN)\r
-#define BROTLI_LITTLE_ENDIAN 0\r
-#endif\r
-\r
-#if !defined(BROTLI_BIG_ENDIAN)\r
-#define BROTLI_BIG_ENDIAN 0\r
-#endif\r
-\r
-#if defined(BROTLI_X_BYTE_ORDER)\r
-#undef BROTLI_X_BYTE_ORDER\r
-#undef BROTLI_X_LITTLE_ENDIAN\r
-#undef BROTLI_X_BIG_ENDIAN\r
-#endif\r
-\r
-#if defined(BROTLI_BUILD_PORTABLE)\r
-#define BROTLI_ALIGNED_READ (!!1)\r
-#elif defined(BROTLI_TARGET_X86) || defined(BROTLI_TARGET_X64) || \\r
-    defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8_ANY) || \\r
-    defined(BROTLI_TARGET_RISCV64)\r
-/* Allow unaligned read only for white-listed CPUs. */\r
-#define BROTLI_ALIGNED_READ (!!0)\r
-#else\r
-#define BROTLI_ALIGNED_READ (!!1)\r
-#endif\r
-\r
-#if BROTLI_ALIGNED_READ\r
-/* Portable unaligned memory access: read / write values via memcpy. */\r
-static BROTLI_INLINE uint16_t BrotliUnalignedRead16(const void* p) {\r
-  uint16_t t;\r
-  memcpy(&t, p, sizeof t);\r
-  return t;\r
-}\r
-static BROTLI_INLINE uint32_t BrotliUnalignedRead32(const void* p) {\r
-  uint32_t t;\r
-  memcpy(&t, p, sizeof t);\r
-  return t;\r
-}\r
-static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {\r
-  uint64_t t;\r
-  memcpy(&t, p, sizeof t);\r
-  return t;\r
-}\r
-static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {\r
-  memcpy(p, &v, sizeof v);\r
-}\r
-#else  /* BROTLI_ALIGNED_READ */\r
-/* Unaligned memory access is allowed: just cast pointer to requested type. */\r
-#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || \\r
-    defined(MEMORY_SANITIZER)\r
-/* Consider we have an unaligned load/store of 4 bytes from address 0x...05.\r
-   AddressSanitizer will treat it as a 3-byte access to the range 05:07 and\r
-   will miss a bug if 08 is the first unaddressable byte.\r
-   ThreadSanitizer will also treat this as a 3-byte access to 05:07 and will\r
-   miss a race between this access and some other accesses to 08.\r
-   MemorySanitizer will correctly propagate the shadow on unaligned stores\r
-   and correctly report bugs on unaligned loads, but it may not properly\r
-   update and report the origin of the uninitialized memory.\r
-   For all three tools, replacing an unaligned access with a tool-specific\r
-   callback solves the problem. */\r
-#if defined(__cplusplus)\r
-extern "C" {\r
-#endif  /* __cplusplus */\r
-  uint16_t __sanitizer_unaligned_load16(const void* p);\r
-  uint32_t __sanitizer_unaligned_load32(const void* p);\r
-  uint64_t __sanitizer_unaligned_load64(const void* p);\r
-  void __sanitizer_unaligned_store64(void* p, uint64_t v);\r
-#if defined(__cplusplus)\r
-}  /* extern "C" */\r
-#endif  /* __cplusplus */\r
-#define BrotliUnalignedRead16 __sanitizer_unaligned_load16\r
-#define BrotliUnalignedRead32 __sanitizer_unaligned_load32\r
-#define BrotliUnalignedRead64 __sanitizer_unaligned_load64\r
-#define BrotliUnalignedWrite64 __sanitizer_unaligned_store64\r
-#else\r
-static BROTLI_INLINE uint16_t BrotliUnalignedRead16(const void* p) {\r
-  return *(const uint16_t*)p;\r
-}\r
-static BROTLI_INLINE uint32_t BrotliUnalignedRead32(const void* p) {\r
-  return *(const uint32_t*)p;\r
-}\r
-#if (BROTLI_64_BITS)\r
-static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {\r
-  return *(const uint64_t*)p;\r
-}\r
-static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {\r
-  *(uint64_t*)p = v;\r
-}\r
-#else  /* BROTLI_64_BITS */\r
-/* Avoid emitting LDRD / STRD, which require properly aligned address. */\r
-/* If __attribute__(aligned) is available, use that. Otherwise, memcpy. */\r
-\r
-#if BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0)\r
-typedef  __attribute__((aligned(1))) uint64_t brotli_unaligned_uint64_t;\r
-\r
-static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {\r
-  return (uint64_t) ((brotli_unaligned_uint64_t*) p)[0];\r
-}\r
-static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {\r
-  brotli_unaligned_uint64_t* dwords = (brotli_unaligned_uint64_t*) p;\r
-  dwords[0] = (brotli_unaligned_uint64_t) v;\r
-}\r
-#else /* BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) */\r
-static BROTLI_INLINE uint64_t BrotliUnalignedRead64(const void* p) {\r
-  uint64_t v;\r
-  memcpy(&v, p, sizeof(uint64_t));\r
-  return v;\r
-}\r
-\r
-static BROTLI_INLINE void BrotliUnalignedWrite64(void* p, uint64_t v) {\r
-  memcpy(p, &v, sizeof(uint64_t));\r
-}\r
-#endif  /* BROTLI_GNUC_HAS_ATTRIBUTE(aligned, 2, 7, 0) */\r
-#endif  /* BROTLI_64_BITS */\r
-#endif  /* ASAN / TSAN / MSAN */\r
-#endif  /* BROTLI_ALIGNED_READ */\r
-\r
-#if BROTLI_LITTLE_ENDIAN\r
-/* Straight endianness. Just read / write values. */\r
-#define BROTLI_UNALIGNED_LOAD16LE BrotliUnalignedRead16\r
-#define BROTLI_UNALIGNED_LOAD32LE BrotliUnalignedRead32\r
-#define BROTLI_UNALIGNED_LOAD64LE BrotliUnalignedRead64\r
-#define BROTLI_UNALIGNED_STORE64LE BrotliUnalignedWrite64\r
-#elif BROTLI_BIG_ENDIAN  /* BROTLI_LITTLE_ENDIAN */\r
-/* Explain compiler to byte-swap values. */\r
-#define BROTLI_BSWAP16_(V) ((uint16_t)( \\r
-  (((V) & 0xFFU) << 8) | \\r
-  (((V) >> 8) & 0xFFU)))\r
-static BROTLI_INLINE uint16_t BROTLI_UNALIGNED_LOAD16LE(const void* p) {\r
-  uint16_t value = BrotliUnalignedRead16(p);\r
-  return BROTLI_BSWAP16_(value);\r
-}\r
-#define BROTLI_BSWAP32_(V) ( \\r
-  (((V) & 0xFFU) << 24) | (((V) & 0xFF00U) << 8) | \\r
-  (((V) >> 8) & 0xFF00U) | (((V) >> 24) & 0xFFU))\r
-static BROTLI_INLINE uint32_t BROTLI_UNALIGNED_LOAD32LE(const void* p) {\r
-  uint32_t value = BrotliUnalignedRead32(p);\r
-  return BROTLI_BSWAP32_(value);\r
-}\r
-#define BROTLI_BSWAP64_(V) ( \\r
-  (((V) & 0xFFU) << 56) | (((V) & 0xFF00U) << 40) | \\r
-  (((V) & 0xFF0000U) << 24) | (((V) & 0xFF000000U) << 8) | \\r
-  (((V) >> 8) & 0xFF000000U) | (((V) >> 24) & 0xFF0000U) | \\r
-  (((V) >> 40) & 0xFF00U) | (((V) >> 56) & 0xFFU))\r
-static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void* p) {\r
-  uint64_t value = BrotliUnalignedRead64(p);\r
-  return BROTLI_BSWAP64_(value);\r
-}\r
-static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void* p, uint64_t v) {\r
-  uint64_t value = BROTLI_BSWAP64_(v);\r
-  BrotliUnalignedWrite64(p, value);\r
-}\r
-#else  /* BROTLI_LITTLE_ENDIAN */\r
-/* Read / store values byte-wise; hopefully compiler will understand. */\r
-static BROTLI_INLINE uint16_t BROTLI_UNALIGNED_LOAD16LE(const void* p) {\r
-  const uint8_t* in = (const uint8_t*)p;\r
-  return (uint16_t)(in[0] | (in[1] << 8));\r
-}\r
-static BROTLI_INLINE uint32_t BROTLI_UNALIGNED_LOAD32LE(const void* p) {\r
-  const uint8_t* in = (const uint8_t*)p;\r
-  uint32_t value = (uint32_t)(in[0]);\r
-  value |= (uint32_t)(in[1]) << 8;\r
-  value |= (uint32_t)(in[2]) << 16;\r
-  value |= (uint32_t)(in[3]) << 24;\r
-  return value;\r
-}\r
-static BROTLI_INLINE uint64_t BROTLI_UNALIGNED_LOAD64LE(const void* p) {\r
-  const uint8_t* in = (const uint8_t*)p;\r
-  uint64_t value = (uint64_t)(in[0]);\r
-  value |= (uint64_t)(in[1]) << 8;\r
-  value |= (uint64_t)(in[2]) << 16;\r
-  value |= (uint64_t)(in[3]) << 24;\r
-  value |= (uint64_t)(in[4]) << 32;\r
-  value |= (uint64_t)(in[5]) << 40;\r
-  value |= (uint64_t)(in[6]) << 48;\r
-  value |= (uint64_t)(in[7]) << 56;\r
-  return value;\r
-}\r
-static BROTLI_INLINE void BROTLI_UNALIGNED_STORE64LE(void* p, uint64_t v) {\r
-  uint8_t* out = (uint8_t*)p;\r
-  out[0] = (uint8_t)v;\r
-  out[1] = (uint8_t)(v >> 8);\r
-  out[2] = (uint8_t)(v >> 16);\r
-  out[3] = (uint8_t)(v >> 24);\r
-  out[4] = (uint8_t)(v >> 32);\r
-  out[5] = (uint8_t)(v >> 40);\r
-  out[6] = (uint8_t)(v >> 48);\r
-  out[7] = (uint8_t)(v >> 56);\r
-}\r
-#endif  /* BROTLI_LITTLE_ENDIAN */\r
-\r
-/* BROTLI_IS_CONSTANT macros returns true for compile-time constants. */\r
-#if BROTLI_GNUC_HAS_BUILTIN(__builtin_constant_p, 3, 0, 1) || \\r
-    BROTLI_INTEL_VERSION_CHECK(16, 0, 0)\r
-#define BROTLI_IS_CONSTANT(x) (!!__builtin_constant_p(x))\r
-#else\r
-#define BROTLI_IS_CONSTANT(x) (!!0)\r
-#endif\r
-\r
-#if defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8_ANY)\r
-#define BROTLI_HAS_UBFX (!!1)\r
-#else\r
-#define BROTLI_HAS_UBFX (!!0)\r
-#endif\r
-\r
-#if defined(BROTLI_ENABLE_LOG)\r
-#define BROTLI_DCHECK(x) assert(x)\r
-#define BROTLI_LOG(x) printf x\r
-#else\r
-#define BROTLI_DCHECK(x)\r
-#define BROTLI_LOG(x)\r
-#endif\r
-\r
-#if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG)\r
-static BROTLI_INLINE void BrotliDump(const char* f, int l, const char* fn) {\r
-  fprintf(stderr, "%s:%d (%s)\n", f, l, fn);\r
-  fflush(stderr);\r
-}\r
-#define BROTLI_DUMP() BrotliDump(__FILE__, __LINE__, __FUNCTION__)\r
-#else\r
-#define BROTLI_DUMP() (void)(0)\r
-#endif\r
-\r
-/* TODO: add appropriate icc/sunpro/arm/ibm/ti checks. */\r
-#if (BROTLI_GNUC_VERSION_CHECK(3, 0, 0) || defined(__llvm__)) && \\r
-    !defined(BROTLI_BUILD_NO_RBIT)\r
-#if defined(BROTLI_TARGET_ARMV7) || defined(BROTLI_TARGET_ARMV8_ANY)\r
-/* TODO: detect ARMv6T2 and enable this code for it. */\r
-static BROTLI_INLINE brotli_reg_t BrotliRBit(brotli_reg_t input) {\r
-  brotli_reg_t output;\r
-  __asm__("rbit %0, %1\n" : "=r"(output) : "r"(input));\r
-  return output;\r
-}\r
-#define BROTLI_RBIT(x) BrotliRBit(x)\r
-#endif  /* armv7 / armv8 */\r
-#endif  /* gcc || clang */\r
-#if !defined(BROTLI_RBIT)\r
-static BROTLI_INLINE void BrotliRBit(void) { /* Should break build if used. */ }\r
-#endif  /* BROTLI_RBIT */\r
-\r
-#define BROTLI_REPEAT(N, X) {     \\r
-  if ((N & 1) != 0) {X;}          \\r
-  if ((N & 2) != 0) {X; X;}       \\r
-  if ((N & 4) != 0) {X; X; X; X;} \\r
-}\r
-\r
-#define BROTLI_UNUSED(X) (void)(X)\r
-\r
-#define BROTLI_MIN_MAX(T)                                                      \\r
-  static BROTLI_INLINE T brotli_min_ ## T (T a, T b) { return a < b ? a : b; } \\r
-  static BROTLI_INLINE T brotli_max_ ## T (T a, T b) { return a > b ? a : b; }\r
-BROTLI_MIN_MAX(double) BROTLI_MIN_MAX(float) BROTLI_MIN_MAX(int)\r
-BROTLI_MIN_MAX(size_t) BROTLI_MIN_MAX(uint32_t) BROTLI_MIN_MAX(uint8_t)\r
-#undef BROTLI_MIN_MAX\r
-#define BROTLI_MIN(T, A, B) (brotli_min_ ## T((A), (B)))\r
-#define BROTLI_MAX(T, A, B) (brotli_max_ ## T((A), (B)))\r
-\r
-#define BROTLI_SWAP(T, A, I, J) { \\r
-  T __brotli_swap_tmp = (A)[(I)]; \\r
-  (A)[(I)] = (A)[(J)];            \\r
-  (A)[(J)] = __brotli_swap_tmp;   \\r
-}\r
-\r
-/* Default brotli_alloc_func */\r
-static void* BrotliDefaultAllocFunc(void* opaque, size_t size) {\r
-  BROTLI_UNUSED(opaque);\r
-  return malloc(size);\r
-}\r
-\r
-/* Default brotli_free_func */\r
-static void BrotliDefaultFreeFunc(void* opaque, void* address) {\r
-  BROTLI_UNUSED(opaque);\r
-  free(address);\r
-}\r
-\r
-BROTLI_UNUSED_FUNCTION void BrotliSuppressUnusedFunctions(void) {\r
-  BROTLI_UNUSED(&BrotliSuppressUnusedFunctions);\r
-  BROTLI_UNUSED(&BrotliUnalignedRead16);\r
-  BROTLI_UNUSED(&BrotliUnalignedRead32);\r
-  BROTLI_UNUSED(&BrotliUnalignedRead64);\r
-  BROTLI_UNUSED(&BrotliUnalignedWrite64);\r
-  BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD16LE);\r
-  BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD32LE);\r
-  BROTLI_UNUSED(&BROTLI_UNALIGNED_LOAD64LE);\r
-  BROTLI_UNUSED(&BROTLI_UNALIGNED_STORE64LE);\r
-  BROTLI_UNUSED(&BrotliRBit);\r
-  BROTLI_UNUSED(&brotli_min_double);\r
-  BROTLI_UNUSED(&brotli_max_double);\r
-  BROTLI_UNUSED(&brotli_min_float);\r
-  BROTLI_UNUSED(&brotli_max_float);\r
-  BROTLI_UNUSED(&brotli_min_int);\r
-  BROTLI_UNUSED(&brotli_max_int);\r
-  BROTLI_UNUSED(&brotli_min_size_t);\r
-  BROTLI_UNUSED(&brotli_max_size_t);\r
-  BROTLI_UNUSED(&brotli_min_uint32_t);\r
-  BROTLI_UNUSED(&brotli_max_uint32_t);\r
-  BROTLI_UNUSED(&brotli_min_uint8_t);\r
-  BROTLI_UNUSED(&brotli_max_uint8_t);\r
-  BROTLI_UNUSED(&BrotliDefaultAllocFunc);\r
-  BROTLI_UNUSED(&BrotliDefaultFreeFunc);\r
-#if defined(BROTLI_DEBUG) || defined(BROTLI_ENABLE_LOG)\r
-  BROTLI_UNUSED(&BrotliDump);\r
-#endif\r
-}\r
-\r
-#endif  /* BROTLI_COMMON_PLATFORM_H_ */\r