diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/math/log2.hpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/mbgl/math/log2.hpp b/include/mbgl/math/log2.hpp index 3136ac22b4..4f5fde60d1 100644 --- a/include/mbgl/math/log2.hpp +++ b/include/mbgl/math/log2.hpp @@ -15,6 +15,17 @@ namespace util { // (== number of bits required to store x) uint32_t ceil_log2(uint64_t x); +template <typename T> +T log2(T x) { +// log2() is producing wrong results on ARMv5 binaries +// running on ARMv7+ CPUs. +#if defined(__ANDROID__) + return ::log(x) / M_LN2; +#else + return ::log2(x); +#endif +} + } // namespace util } // namespace mbgl |