summaryrefslogtreecommitdiff
path: root/src/math/powerpc64/lround.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2017-06-23 16:01:00 -0400
committerRich Felker <dalias@aerifal.cx>2017-06-23 16:01:00 -0400
commit94f744195e17cf787a36c259254d56386b31fe20 (patch)
tree6702e9ebf15bd4db3049d769fd06bd51abe124d8 /src/math/powerpc64/lround.c
parent9d12a6a21fd146f543e8a6b8ec4cce7fd61be606 (diff)
downloadmusl-94f744195e17cf787a36c259254d56386b31fe20.tar.gz
powerpc64: add single-instruction math functions
while the official elfv2 abi for "powerpc64le" sets power8 as the baseline isa, we use it for both little and big endian powerpc64 targets and need to maintain compatibility with pre-power8 models. the instructions for sqrt, fabs, and fma are in the baseline isa; support for the rest is conditional via predefined isa-level macros. patch by David Edelsohn.
Diffstat (limited to 'src/math/powerpc64/lround.c')
-rw-r--r--src/math/powerpc64/lround.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/math/powerpc64/lround.c b/src/math/powerpc64/lround.c
new file mode 100644
index 00000000..ee4d1143
--- /dev/null
+++ b/src/math/powerpc64/lround.c
@@ -0,0 +1,18 @@
+#include <math.h>
+
+#ifdef __VSX__
+
+long lround(double x)
+{
+ long n;
+ __asm__ (
+ "xsrdpi %1, %1\n"
+ "fctid %0, %1\n" : "=d"(n), "+d"(x));
+ return n;
+}
+
+#else
+
+#include "../lround.c"
+
+#endif