summaryrefslogtreecommitdiffstatshomepage
path: root/lib
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-11-03 12:26:32 +1100
committerDamien George <damien.p.george@gmail.com>2016-11-03 12:26:32 +1100
commitcd527bb324ade952d11a134859d38bf5272c165e (patch)
treef8b3d1b9a1c98f3d777d9be342c68481917d0d8a /lib
parent828df54bfeaa4a31040fa534dd2961cc9b4ac16e (diff)
downloadmicropython-cd527bb324ade952d11a134859d38bf5272c165e.tar.gz
micropython-cd527bb324ade952d11a134859d38bf5272c165e.zip
lib/libm: Move Thumb-specific sqrtf function to separate file.
This allows it to be used only when the hardware supports VFP instructions, preventing compile errors.
Diffstat (limited to 'lib')
-rw-r--r--lib/libm/math.c13
-rw-r--r--lib/libm/thumb_vfp_sqrtf.c11
2 files changed, 11 insertions, 13 deletions
diff --git a/lib/libm/math.c b/lib/libm/math.c
index 7cbec5fb32..732049236d 100644
--- a/lib/libm/math.c
+++ b/lib/libm/math.c
@@ -86,19 +86,6 @@ 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"
- : [r] "=t" (x)
- : [x] "t" (x));
- return x;
-}
-
-#endif
-
#ifndef NDEBUG
float copysignf(float x, float y) {
float_s_t fx={.f = x};
diff --git a/lib/libm/thumb_vfp_sqrtf.c b/lib/libm/thumb_vfp_sqrtf.c
new file mode 100644
index 0000000000..12ffebf827
--- /dev/null
+++ b/lib/libm/thumb_vfp_sqrtf.c
@@ -0,0 +1,11 @@
+// an implementation of sqrtf for Thumb using hardware VFP instructions
+
+#include <math.h>
+
+float sqrtf(float x) {
+ asm volatile (
+ "vsqrt.f32 %[r], %[x]\n"
+ : [r] "=t" (x)
+ : [x] "t" (x));
+ return x;
+}