summaryrefslogtreecommitdiff
path: root/lib/libm/arch
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2009-06-30 20:20:21 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2009-06-30 20:20:21 +0000
commit5203f4d21828c1b7d04baab833c5c56f73ffea73 (patch)
tree165fbbb67f7d900bc4c3d43ad9c87cdfd77adb54 /lib/libm/arch
parente2784ce47281b13438d6cc5924caf41d1ff95c14 (diff)
floor(3) should round towards -inf instead of towards zero.
ok martynas@, deraadt@
Diffstat (limited to 'lib/libm/arch')
-rw-r--r--lib/libm/arch/hppa/s_floor.c5
-rw-r--r--lib/libm/arch/hppa/s_floorf.c5
2 files changed, 4 insertions, 6 deletions
diff --git a/lib/libm/arch/hppa/s_floor.c b/lib/libm/arch/hppa/s_floor.c
index 9c65cdc5ed2..ef9c29dbd51 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.4 2003/10/31 23:22:37 mickey Exp $";
+static char rcsid[] = "$OpenBSD: s_floor.c,v 1.5 2009/06/30 20:20:20 kettenis Exp $";
#endif
#include <sys/types.h>
@@ -16,8 +16,7 @@ floor(double x)
u_int64_t ofpsr, fpsr;
__asm__ __volatile__("fstds %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr));
- fpsr = (ofpsr & ~((u_int64_t)FP_RM << (9 + 32))) |
- ((u_int64_t)FP_RZ << (9 + 32));
+ fpsr = ofpsr | ((u_int64_t)FP_RM << (9 + 32));
__asm__ __volatile__("fldds 0(%0), %%fr0" :: "r" (&fpsr));
__asm__ __volatile__("frnd,dbl %0,%0" : "+f" (x));
diff --git a/lib/libm/arch/hppa/s_floorf.c b/lib/libm/arch/hppa/s_floorf.c
index 6631d3e5d5e..a719cd3a3fd 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.4 2003/10/31 23:22:37 mickey Exp $";
+static char rcsid[] = "$OpenBSD: s_floorf.c,v 1.5 2009/06/30 20:20:20 kettenis Exp $";
#endif
#include <sys/types.h>
@@ -16,8 +16,7 @@ floorf(float x)
u_int64_t ofpsr, fpsr;
__asm__ __volatile__("fstds %%fr0,0(%1)" : "=m" (ofpsr) : "r" (&ofpsr));
- fpsr = (ofpsr & ~((u_int64_t)FP_RM << (9 + 32))) |
- ((u_int64_t)FP_RZ << (9 + 32));
+ fpsr = ofpsr | ((u_int64_t)FP_RM << (9 + 32));
__asm__ __volatile__("fldds 0(%0), %%fr0" :: "r" (&fpsr));
__asm__ __volatile__("frnd,sgl %0,%0" : "+f" (x));