Commit 6d1eabfe authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

unix/mpconfigport: Move log2() definition to modmath.c.

It's safer to define it where it's used, defining it for all source files
may lead to hard to diagnose conflicts in corner cases.
parent 432e8275
...@@ -52,6 +52,11 @@ ...@@ -52,6 +52,11 @@
STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { mp_int_t x = MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj)); return mp_obj_new_int(x); } \ STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { mp_int_t x = MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj)); return mp_obj_new_int(x); } \
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name); STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name);
#if MP_NEED_LOG2
// 1.442695040888963407354163704 is 1/_M_LN2
#define log2(x) (log(x) * 1.442695040888963407354163704)
#endif
/// \function sqrt(x) /// \function sqrt(x)
/// Returns the square root of `x`. /// Returns the square root of `x`.
MATH_FUN_1(sqrt, sqrt) MATH_FUN_1(sqrt, sqrt)
......
...@@ -204,8 +204,7 @@ void mp_unix_mark_exec(void); ...@@ -204,8 +204,7 @@ void mp_unix_mark_exec(void);
#include <android/api-level.h> #include <android/api-level.h>
#if __ANDROID_API__ < 4 #if __ANDROID_API__ < 4
// Bionic libc in Android 1.5 misses these 2 functions // Bionic libc in Android 1.5 misses these 2 functions
// 1.442695040888963407354163704 is 1/_M_LN2 #define MP_NEED_LOG2 (1)
#define log2(x) (log(x) * 1.442695040888963407354163704)
#define nan(x) NAN #define nan(x) NAN
#endif #endif
#endif #endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment