aboutsummaryrefslogtreecommitdiff
path: root/stm/math.c
diff options
context:
space:
mode:
authorDamien George2014-03-08 15:24:39 +0000
committerDamien George2014-03-08 15:24:39 +0000
commit0c36da0b59bd3d5aeb6f7bd7f75913695a1dd366 (patch)
treeeb1d8e50037139646f935df99da56764fcafb4f1 /stm/math.c
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 'stm/math.c')
-rw-r--r--stm/math.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/stm/math.c b/stm/math.c
new file mode 100644
index 000000000..ac680f6b7
--- /dev/null
+++ b/stm/math.c
@@ -0,0 +1,48 @@
+#include <math.h>
+
+// these 2 functions seem to actually work... no idea why
+// replacing with libgcc does not work (probably due to wrong calling conventions)
+double __aeabi_f2d(float x) {
+ // TODO
+ return 0.0;
+}
+
+float __aeabi_d2f(double x) {
+ // TODO
+ return 0.0;
+}
+
+/*
+double sqrt(double x) {
+ // TODO
+ return 0.0;
+}
+*/
+
+float sqrtf(float x) {
+ asm volatile (
+ "vsqrt.f32 %[r], %[x]\n"
+ : [r] "=t" (x)
+ : [x] "t" (x));
+ return x;
+}
+
+// TODO we need import these functions from some library (eg musl or newlib)
+float powf(float x, float y) { return 0.0; }
+float expf(float x) { return 0.0; }
+float logf(float x) { return 0.0; }
+float log2f(float x) { return 0.0; }
+float log10f(float x) { return 0.0; }
+float coshf(float x) { return 0.0; }
+float sinhf(float x) { return 0.0; }
+float tanhf(float x) { return 0.0; }
+float acoshf(float x) { return 0.0; }
+float asinhf(float x) { return 0.0; }
+float atanhf(float x) { return 0.0; }
+float cosf(float x) { return 0.0; }
+float sinf(float x) { return 0.0; }
+float tanf(float x) { return 0.0; }
+float acosf(float x) { return 0.0; }
+float asinf(float x) { return 0.0; }
+float atanf(float x) { return 0.0; }
+float atan2f(float x, float y) { return 0.0; }