Index: third_party/brotli/enc/fast_log.h |
diff --git a/third_party/brotli/enc/fast_log.h b/third_party/brotli/enc/fast_log.h |
index e750e56c44eeb92ecfeaa84f5eb5596ce4f8fe3f..b9801750567066428e0bd061d2509b4d29f7faef 100644 |
--- a/third_party/brotli/enc/fast_log.h |
+++ b/third_party/brotli/enc/fast_log.h |
@@ -4,21 +4,23 @@ |
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
*/ |
-// Utilities for fast computation of logarithms. |
+/* Utilities for fast computation of logarithms. */ |
#ifndef BROTLI_ENC_FAST_LOG_H_ |
#define BROTLI_ENC_FAST_LOG_H_ |
-#include <assert.h> |
#include <math.h> |
-#include "./types.h" |
+#include <brotli/types.h> |
+#include <brotli/port.h> |
-namespace brotli { |
+#if defined(__cplusplus) || defined(c_plusplus) |
+extern "C" { |
+#endif |
-static inline uint32_t Log2FloorNonZero(size_t n) { |
+static BROTLI_INLINE uint32_t Log2FloorNonZero(size_t n) { |
#ifdef __GNUC__ |
- return 31u ^ static_cast<uint32_t>(__builtin_clz(static_cast<uint32_t>(n))); |
+ return 31u ^ (uint32_t)__builtin_clz((uint32_t)n); |
#else |
uint32_t result = 0; |
while (n >>= 1) result++; |
@@ -26,10 +28,10 @@ static inline uint32_t Log2FloorNonZero(size_t n) { |
#endif |
} |
-// A lookup table for small values of log2(int) to be used in entropy |
-// computation. |
-// |
-// ", ".join(["%.16ff" % x for x in [0.0]+[log2(x) for x in range(1, 256)]]) |
+/* A lookup table for small values of log2(int) to be used in entropy |
+ computation. |
+ |
+ ", ".join(["%.16ff" % x for x in [0.0]+[log2(x) for x in range(1, 256)]]) */ |
static const float kLog2Table[] = { |
0.0000000000000000f, 0.0000000000000000f, 1.0000000000000000f, |
1.5849625007211563f, 2.0000000000000000f, 2.3219280948873622f, |
@@ -119,21 +121,25 @@ static const float kLog2Table[] = { |
7.9943534368588578f |
}; |
-// Faster logarithm for small integers, with the property of log2(0) == 0. |
-static inline double FastLog2(size_t v) { |
+#define LOG_2_INV 1.4426950408889634 |
+ |
+/* Faster logarithm for small integers, with the property of log2(0) == 0. */ |
+static BROTLI_INLINE double FastLog2(size_t v) { |
if (v < sizeof(kLog2Table) / sizeof(kLog2Table[0])) { |
return kLog2Table[v]; |
} |
-#if defined(_MSC_VER) && _MSC_VER <= 1700 |
- // Visual Studio 2012 does not have the log2() function defined, so we use |
- // log() and a multiplication instead. |
- static const double kLog2Inv = 1.4426950408889634f; |
- return log(static_cast<double>(v)) * kLog2Inv; |
+#if (defined(_MSC_VER) && _MSC_VER <= 1700) || \ |
+ (defined(__ANDROID_API__) && __ANDROID_API__ < 18) |
+ /* Visual Studio 2012 and Android API levels < 18 do not have the log2() |
+ * function defined, so we use log() and a multiplication instead. */ |
+ return log((double)v) * LOG_2_INV; |
#else |
- return log2(static_cast<double>(v)); |
+ return log2((double)v); |
#endif |
} |
-} // namespace brotli |
+#if defined(__cplusplus) || defined(c_plusplus) |
+} /* extern "C" */ |
+#endif |
-#endif // BROTLI_ENC_FAST_LOG_H_ |
+#endif /* BROTLI_ENC_FAST_LOG_H_ */ |