Skip to content

Commit 74d0df7

Browse files
committed
unix: Allow to build against Android down to 1.5.
Bionic libc in Android 1.5 missed log2() and nan() functions.
1 parent d7e3b36 commit 74d0df7

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

unix/mpconfigport.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,16 @@ void mp_unix_mark_exec(void);
198198
#define MICROPY_PLAT_DEV_MEM (1)
199199
#endif
200200

201+
#ifdef __ANDROID__
202+
#include <android/api-level.h>
203+
#if __ANDROID_API__ < 4
204+
// Bionic libc in Android 1.5 misses these 2 functions
205+
// 1.442695040888963407354163704 is 1/_M_LN2
206+
#define log2(x) (log(x) * 1.442695040888963407354163704)
207+
#define nan(x) NAN
208+
#endif
209+
#endif
210+
201211
extern const struct _mp_obj_fun_builtin_t mp_builtin_input_obj;
202212
extern const struct _mp_obj_fun_builtin_t mp_builtin_open_obj;
203213
#define MICROPY_PORT_BUILTINS \

0 commit comments

Comments
 (0)