From 74d0df7324f23cfbbc2ae5b0cd0bf7f214fd05e5 Mon Sep 17 00:00:00 2001
From: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Date: Thu, 15 Oct 2015 00:10:26 +0300
Subject: [PATCH] unix: Allow to build against Android down to 1.5.

Bionic libc in Android 1.5 missed log2() and nan() functions.
---
 unix/mpconfigport.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h
index 21df22486..993baca62 100644
--- a/unix/mpconfigport.h
+++ b/unix/mpconfigport.h
@@ -198,6 +198,16 @@ void mp_unix_mark_exec(void);
 #define MICROPY_PLAT_DEV_MEM  (1)
 #endif
 
+#ifdef __ANDROID__
+#include <android/api-level.h>
+#if __ANDROID_API__ < 4
+// Bionic libc in Android 1.5 misses these 2 functions
+// 1.442695040888963407354163704 is 1/_M_LN2
+#define log2(x) (log(x) * 1.442695040888963407354163704)
+#define nan(x) NAN
+#endif
+#endif
+
 extern const struct _mp_obj_fun_builtin_t mp_builtin_input_obj;
 extern const struct _mp_obj_fun_builtin_t mp_builtin_open_obj;
 #define MICROPY_PORT_BUILTINS \
-- 
GitLab