summaryrefslogtreecommitdiffstatshomepage
path: root/lib/libm/math.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-12-18 21:05:44 +0000
committerDamien George <damien.p.george@gmail.com>2015-12-18 21:05:44 +0000
commita67651406d4154cd5093884dea6ca0ca395d56db (patch)
tree532b8c8ee6059620751ca4eddfbb0dc2915be1f1 /lib/libm/math.c
parent0e1b5faad5b29de39a42cc59ee4a6ac8355c8bcc (diff)
downloadmicropython-a67651406d4154cd5093884dea6ca0ca395d56db.tar.gz
micropython-a67651406d4154cd5093884dea6ca0ca395d56db.zip
lib/libm: Allow math funcs to be used by non-Thumb archs.
Requires addition of software implementation of sqrtf function.
Diffstat (limited to 'lib/libm/math.c')
-rw-r--r--lib/libm/math.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/libm/math.c b/lib/libm/math.c
index 5d4779b62d..7cbec5fb32 100644
--- a/lib/libm/math.c
+++ b/lib/libm/math.c
@@ -45,6 +45,8 @@ typedef union {
};
} double_s_t;
+#if defined(__thumb__)
+
double __attribute__((pcs("aapcs"))) __aeabi_i2d(int32_t x) {
return (float)x;
}
@@ -82,6 +84,11 @@ double __aeabi_dmul(double x , double y) {
}
+#endif // defined(__thumb__)
+
+// TODO this needs a better way of testing for Thumb2 FP hardware
+#if defined(__thumb2__)
+
float sqrtf(float x) {
asm volatile (
"vsqrt.f32 %[r], %[x]\n"
@@ -90,6 +97,8 @@ float sqrtf(float x) {
return x;
}
+#endif
+
#ifndef NDEBUG
float copysignf(float x, float y) {
float_s_t fx={.f = x};