summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2003-01-16 19:17:34 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2003-01-16 19:17:34 +0000
commit2f7a46aa521243e3e0f569672991324b78d2cfbd (patch)
treee31ef768e1a11ae33b824ad519022a9bb8e2de42 /lib
parent07db4039bdf900bcffc7951062c102f5866e5f3e (diff)
fpr0 is recommended to be operated in full 64bits, although seemed to work otherwise, fix it
Diffstat (limited to 'lib')
-rw-r--r--lib/libm/arch/hppa/s_ceil.c13
-rw-r--r--lib/libm/arch/hppa/s_ceilf.c13
-rw-r--r--lib/libm/arch/hppa/s_floor.c13
-rw-r--r--lib/libm/arch/hppa/s_floorf.c13
4 files changed, 28 insertions, 24 deletions
diff --git a/lib/libm/arch/hppa/s_ceil.c b/lib/libm/arch/hppa/s_ceil.c
index da87f4a6041..3a5a83cdcad 100644
--- a/lib/libm/arch/hppa/s_ceil.c
+++ b/lib/libm/arch/hppa/s_ceil.c
@@ -3,7 +3,7 @@
*/
#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: s_ceil.c,v 1.2 2002/09/11 15:16:52 mickey Exp $";
+static char rcsid[] = "$OpenBSD: s_ceil.c,v 1.3 2003/01/16 19:17:33 mickey Exp $";
#endif
#include <sys/types.h>
@@ -13,14 +13,15 @@ static char rcsid[] = "$OpenBSD: s_ceil.c,v 1.2 2002/09/11 15:16:52 mickey Exp $
double
ceil(double x)
{
- u_int32_t ofpsr, fpsr;
+ u_int64_t ofpsr, fpsr;
- __asm__ __volatile__("fstw %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr));
- fpsr = (ofpsr & ~0x600) | (FP_RP << 9);
- __asm__ __volatile__("fldw 0(%0), %%fr0" :: "r" (&fpsr));
+ __asm__ __volatile__("fstds %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr));
+ fpsr = (ofpsr & ~((u_int64_t)FP_RM << (9 + 32))) |
+ ((u_int64_t)FP_RP << (9 + 32));
+ __asm__ __volatile__("fldds 0(%0), %%fr0" :: "r" (&fpsr));
__asm__ __volatile__("frnd,dbl %0,%0" : "+f" (x));
- __asm__ __volatile__("fldw 0(%0), %%fr0" :: "r" (&ofpsr));
+ __asm__ __volatile__("fldds 0(%0), %%fr0" :: "r" (&ofpsr));
return (x);
}
diff --git a/lib/libm/arch/hppa/s_ceilf.c b/lib/libm/arch/hppa/s_ceilf.c
index 63f16f1d2fc..1ca5decd9d7 100644
--- a/lib/libm/arch/hppa/s_ceilf.c
+++ b/lib/libm/arch/hppa/s_ceilf.c
@@ -3,7 +3,7 @@
*/
#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: s_ceilf.c,v 1.2 2002/09/11 15:16:52 mickey Exp $";
+static char rcsid[] = "$OpenBSD: s_ceilf.c,v 1.3 2003/01/16 19:17:33 mickey Exp $";
#endif
#include <sys/types.h>
@@ -13,14 +13,15 @@ static char rcsid[] = "$OpenBSD: s_ceilf.c,v 1.2 2002/09/11 15:16:52 mickey Exp
float
ceilf(float x)
{
- u_int32_t ofpsr, fpsr;
+ u_int64_t ofpsr, fpsr;
- __asm__ __volatile__("fstw %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr));
- fpsr = (ofpsr & ~0x600) | (FP_RP << 9);
- __asm__ __volatile__("fldw 0(%0), %%fr0" :: "r" (&fpsr));
+ __asm__ __volatile__("fstds %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr));
+ fpsr = (ofpsr & ~((u_int64_t)FP_RM << (9 + 32))) |
+ ((u_int64_t)FP_RP << (9 + 32));
+ __asm__ __volatile__("fldds 0(%0), %%fr0" :: "r" (&fpsr));
__asm__ __volatile__("frnd,sgl %0,%0" : "+f" (x));
- __asm__ __volatile__("fldw 0(%0), %%fr0" :: "r" (&ofpsr));
+ __asm__ __volatile__("fldds 0(%0), %%fr0" :: "r" (&ofpsr));
return (x);
}
diff --git a/lib/libm/arch/hppa/s_floor.c b/lib/libm/arch/hppa/s_floor.c
index e4b8502de9c..22be65c1fe4 100644
--- a/lib/libm/arch/hppa/s_floor.c
+++ b/lib/libm/arch/hppa/s_floor.c
@@ -3,7 +3,7 @@
*/
#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: s_floor.c,v 1.2 2002/09/11 15:16:52 mickey Exp $";
+static char rcsid[] = "$OpenBSD: s_floor.c,v 1.3 2003/01/16 19:17:33 mickey Exp $";
#endif
#include <sys/types.h>
@@ -13,14 +13,15 @@ static char rcsid[] = "$OpenBSD: s_floor.c,v 1.2 2002/09/11 15:16:52 mickey Exp
double
floor(double x)
{
- u_int32_t ofpsr, fpsr;
+ u_int64_t ofpsr, fpsr;
- __asm__ __volatile__("fstw %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr));
- fpsr = (ofpsr & ~0x600) | (FP_RN << 9);
- __asm__ __volatile__("fldw 0(%0), %%fr0" :: "r" (&fpsr));
+ __asm__ __volatile__("fstds %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr));
+ fpsr = (ofpsr & ~((u_int64_t)FP_RM << (9 + 32))) |
+ ((u_int64_t)FP_RN << (9 + 32));
+ __asm__ __volatile__("fldds 0(%0), %%fr0" :: "r" (&fpsr));
__asm__ __volatile__("frnd,dbl %0,%0" : "+f" (x));
- __asm__ __volatile__("fldw 0(%0), %%fr0" :: "r" (&ofpsr));
+ __asm__ __volatile__("fldds 0(%0), %%fr0" :: "r" (&ofpsr));
return (x);
}
diff --git a/lib/libm/arch/hppa/s_floorf.c b/lib/libm/arch/hppa/s_floorf.c
index b318eb055d1..25756a29937 100644
--- a/lib/libm/arch/hppa/s_floorf.c
+++ b/lib/libm/arch/hppa/s_floorf.c
@@ -3,7 +3,7 @@
*/
#if defined(LIBM_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: s_floorf.c,v 1.2 2002/09/11 15:16:52 mickey Exp $";
+static char rcsid[] = "$OpenBSD: s_floorf.c,v 1.3 2003/01/16 19:17:33 mickey Exp $";
#endif
#include <sys/types.h>
@@ -13,14 +13,15 @@ static char rcsid[] = "$OpenBSD: s_floorf.c,v 1.2 2002/09/11 15:16:52 mickey Exp
float
floorf(float x)
{
- u_int32_t ofpsr, fpsr;
+ u_int64_t ofpsr, fpsr;
- __asm__ __volatile__("fstw %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr));
- fpsr = (ofpsr & ~0x600) | (FP_RN << 9);
- __asm__ __volatile__("fldw 0(%0), %%fr0" :: "r" (&fpsr));
+ __asm__ __volatile__("fstds %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr));
+ fpsr = (ofpsr & ~((u_int64_t)FP_RM << (9 + 32))) |
+ ((u_int64_t)FP_RN << (9 + 32));
+ __asm__ __volatile__("fldds 0(%0), %%fr0" :: "r" (&fpsr));
__asm__ __volatile__("frnd,sgl %0,%0" : "+f" (x));
- __asm__ __volatile__("fldw 0(%0), %%fr0" :: "r" (&ofpsr));
+ __asm__ __volatile__("fldds 0(%0), %%fr0" :: "r" (&ofpsr));
return (x);
}