about summary refs log tree commit diff
path: root/src/math/powerpc64/truncf.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/truncf.c
parent9d12a6a21fd146f543e8a6b8ec4cce7fd61be606 (diff)
downloadmusl-94f744195e17cf787a36c259254d56386b31fe20.tar.gz
musl-94f744195e17cf787a36c259254d56386b31fe20.tar.xz
musl-94f744195e17cf787a36c259254d56386b31fe20.zip
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/truncf.c')
-rw-r--r--src/math/powerpc64/truncf.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/math/powerpc64/truncf.c b/src/math/powerpc64/truncf.c
new file mode 100644
index 00000000..94e638fb
--- /dev/null
+++ b/src/math/powerpc64/truncf.c
@@ -0,0 +1,15 @@
+#include <math.h>
+
+#ifdef _ARCH_PWR5X
+
+float truncf(float x)
+{
+	__asm__ ("friz %0, %1" : "=f"(x) : "f"(x));
+	return x;
+}
+
+#else
+
+#include "../truncf.c"
+
+#endif