summaryrefslogtreecommitdiff
path: root/lib/libm/arch/hppa/s_ceil.c
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/libm/arch/hppa/s_ceil.c
parent07db4039bdf900bcffc7951062c102f5866e5f3e (diff)
fpr0 is recommended to be operated in full 64bits, although seemed to work otherwise, fix it
Diffstat (limited to 'lib/libm/arch/hppa/s_ceil.c')
-rw-r--r--lib/libm/arch/hppa/s_ceil.c13
1 files changed, 7 insertions, 6 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);
}