summaryrefslogtreecommitdiff
path: root/emulators/qemu/files/patch-libmath2
blob: ecff96d0d89ecc2480e32626b54917fff090929e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Index: qemu/bsd/Makefile
@@ -16,7 +16,8 @@
 	${MACHINE_ARCH}/s_rintl.c	\
 	${MACHINE_ARCH}/s_round.c	\
 	${MACHINE_ARCH}/s_sinl.S	\
-	${MACHINE_ARCH}/s_tanl.S
+	${MACHINE_ARCH}/s_tanl.S	\
+	${MACHINE_ARCH}/s_ldexpl.c
 
 OBJS=	${SRCS:R:S/$/.o/}
 
Index: qemu/bsd/i386/s_ldexpl.c
@@ -0,0 +1,21 @@
+#include <math.h>
+#include <errno.h>
+#include <sysdep.h>
+
+long double __ldexpl(long double x, int expn)
+{
+  long double res;
+  if (!isfinite (x) || x == 0.0L)
+    return x;
+
+  __asm__ ("fscale"
+  	    : "=t" (res)
+	    : "0" (x), "u" ((long double) expn));
+
+  if (!isfinite (res) || res == 0.0L)
+    errno = ERANGE;
+
+  return res;
+}
+
+weak_alias(__ldexpl,ldexpl)
Index: qemu/bsd/amd64/s_ldexpl.c
@@ -0,0 +1,21 @@
+#include <math.h>
+#include <errno.h>
+#include <sysdep.h>
+
+long double __ldexpl(long double x, int expn)
+{
+  long double res;
+  if (!isfinite (x) || x == 0.0L)
+    return x;
+
+  __asm__ ("fscale"
+  	    : "=t" (res)
+	    : "0" (x), "u" ((long double) expn));
+
+  if (!isfinite (res) || res == 0.0L)
+    errno = ERANGE;
+
+  return res;
+}
+
+weak_alias(__ldexpl,ldexpl)