diff options
author | Cristi Vîjdea <cristi@cvjd.me> | 2020-03-19 11:46:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-19 10:46:52 +0100 |
commit | f503cb709ca181dbf5c73986ebac1b18ac5c9f63 (patch) | |
tree | a2b3fef9523640ce85930e90ec8eef51e244cd86 /c | |
parent | 36ac0feaf9654855ee090b1f042363ecfb256f31 (diff) | |
download | brotli-f503cb709ca181dbf5c73986ebac1b18ac5c9f63.zip brotli-f503cb709ca181dbf5c73986ebac1b18ac5c9f63.tar.gz brotli-f503cb709ca181dbf5c73986ebac1b18ac5c9f63.tar.bz2 |
Add HAVE_LOG2 build macro (#783)
* Add HAVE_LOG2 build macro
Fixes #781
* Rename macro to BROTLI_HAVE_LOG2 and move comment for visibility
Diffstat (limited to 'c')
-rw-r--r-- | c/enc/fast_log.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/c/enc/fast_log.h b/c/enc/fast_log.h index cade123..b1268e0 100644 --- a/c/enc/fast_log.h +++ b/c/enc/fast_log.h @@ -123,6 +123,16 @@ static const float kLog2Table[] = { 7.9943534368588578f }; +/* Visual Studio 2012 and Android API levels < 18 do not have the log2() + * function defined, so we use log() and a multiplication instead. */ +#ifndef BROTLI_HAVE_LOG2 +#if ((defined(_MSC_VER) && _MSC_VER <= 1700) || (defined(__ANDROID_API__) && __ANDROID_API__ < 18)) +#define BROTLI_HAVE_LOG2 0 +#else +#define BROTLI_HAVE_LOG2 1 +#endif +#endif + #define LOG_2_INV 1.4426950408889634 /* Faster logarithm for small integers, with the property of log2(0) == 0. */ @@ -130,10 +140,7 @@ 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) || \ - (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. */ +#if !(BROTLI_HAVE_LOG2) return log((double)v) * LOG_2_INV; #else return log2((double)v); |