Implement ROMable modules. Add math module.
mp_module_obj_t can now be put in ROM.
Configuration of float type is now similar to longint: can now choose
none, float or double as the implementation.
math module has basic math functions. For STM port, these are not yet
implemented (they are just stub functions).
diff --git a/unix/main.c b/unix/main.c
index fb0a6ec..481b815 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -383,12 +383,6 @@
return 0;
}
-// for sqrt
-#include <math.h>
-machine_float_t machine_sqrt(machine_float_t x) {
- return sqrt(x);
-}
-
#include <sys/stat.h>
uint mp_import_stat(const char *path) {
diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h
index 99c13a7..8950337 100644
--- a/unix/mpconfigport.h
+++ b/unix/mpconfigport.h
@@ -8,7 +8,7 @@
#define MICROPY_ENABLE_REPL_HELPERS (1)
#define MICROPY_ENABLE_LEXER_UNIX (1)
#define MICROPY_ENABLE_SOURCE_LINE (1)
-#define MICROPY_ENABLE_FLOAT (1)
+#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
#define MICROPY_PATH_MAX (PATH_MAX)
@@ -28,9 +28,6 @@
typedef void *machine_ptr_t; // must be of pointer size
typedef const void *machine_const_ptr_t; // must be of pointer size
-typedef double machine_float_t;
-
-machine_float_t machine_sqrt(machine_float_t x);
struct _mp_obj_fun_native_t;
extern const struct _mp_obj_fun_native_t mp_builtin_open_obj;
diff --git a/unix/time.c b/unix/time.c
index 6dba9f0..1abd7cf 100644
--- a/unix/time.c
+++ b/unix/time.c
@@ -28,7 +28,7 @@
static mp_obj_t mod_time_sleep(mp_obj_t arg) {
#if MICROPY_ENABLE_FLOAT
struct timeval tv;
- machine_float_t val = mp_obj_get_float(arg);
+ mp_float_t val = mp_obj_get_float(arg);
double ipart;
tv.tv_usec = round(modf(val, &ipart) * 1000000);
tv.tv_sec = ipart;