aboutsummaryrefslogtreecommitdiff
path: root/unix
diff options
context:
space:
mode:
authorDamien George2014-03-08 15:24:39 +0000
committerDamien George2014-03-08 15:24:39 +0000
commit0c36da0b59bd3d5aeb6f7bd7f75913695a1dd366 (patch)
treeeb1d8e50037139646f935df99da56764fcafb4f1 /unix
parent8fd7d7e102372a3fe067030aa0f2049f744b1567 (diff)
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).
Diffstat (limited to 'unix')
-rw-r--r--unix/main.c6
-rw-r--r--unix/mpconfigport.h5
-rw-r--r--unix/time.c2
3 files changed, 2 insertions, 11 deletions
diff --git a/unix/main.c b/unix/main.c
index fb0a6ecf0..481b81581 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -383,12 +383,6 @@ int main(int argc, char **argv) {
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 99c13a7dc..8950337d4 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 unsigned int machine_uint_t; // must be pointer size
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 6dba9f0d0..1abd7cff3 100644
--- a/unix/time.c
+++ b/unix/time.c
@@ -28,7 +28,7 @@ static MP_DEFINE_CONST_FUN_OBJ_0(mod_time_clock_obj, mod_time_clock);
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;