summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSudarsana Babu Nagineni <sudarsana.babu@mapbox.com>2018-08-09 17:13:05 +0300
committerSudarsana Babu Nagineni <sudarsana.babu@mapbox.com>2018-08-10 13:43:05 +0300
commitd1f1ef922f329f3a5f729c34dde615d5afeb5ac6 (patch)
tree6723114e41ac03fc27ab02de508aaa6fcdd345b2 /include
parent0130c58fdd74edbbfe668f3125a9377554d7d605 (diff)
downloadqtlocation-mapboxgl-d1f1ef922f329f3a5f729c34dde615d5afeb5ac6.tar.gz
Fix Android build
Cherry picked from commit fc0745a699a0ef60c080e9c2ff5eaecde9cb5306
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/math/log2.hpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/mbgl/math/log2.hpp b/include/mbgl/math/log2.hpp
index 6a1ba23ed9..3136ac22b4 100644
--- a/include/mbgl/math/log2.hpp
+++ b/include/mbgl/math/log2.hpp
@@ -2,6 +2,11 @@
#include <cmath>
#include <cstdint>
+#include <type_traits>
+
+#if defined(__ANDROID__)
+#include <android/api-level.h>
+#endif
namespace mbgl {
namespace util {
@@ -12,3 +17,14 @@ uint32_t ceil_log2(uint64_t x);
} // namespace util
} // namespace mbgl
+
+// log2 is not available on Android before API 18.
+#if defined(__ANDROID__) && defined(__GNUC__) && \
+ defined(__ANDROID_API__) && __ANDROID_API__ < 18
+
+template <typename T>
+typename std::enable_if_t<std::is_floating_point<T>::value, T> log2(T x) {
+ return ::log(x) / M_LN2;
+}
+
+#endif