summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2019-02-22 14:22:52 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2019-02-22 14:22:52 +0000
commitf0a27d5e05ca4f65a2210e2f42e45b961603f013 (patch)
treeb2eb8a5ed3dda8bf09569fa6ef7ea2a86674b7e2 /regress
parent86c618bdb9ae8d3a8e1b366c072b9df35ac87e80 (diff)
For ia32 use a volatile double to force 64 bit rounding. Otherwise
the i387 would use its internal 80 bit stack. This fixes getround() on i386.
Diffstat (limited to 'regress')
-rw-r--r--regress/lib/libm/msun/fenv_test.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/regress/lib/libm/msun/fenv_test.c b/regress/lib/libm/msun/fenv_test.c
index 97abe77e78c..f01e5a57ac6 100644
--- a/regress/lib/libm/msun/fenv_test.c
+++ b/regress/lib/libm/msun/fenv_test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fenv_test.c,v 1.2 2019/02/21 17:36:41 bluhm Exp $ */
+/* $OpenBSD: fenv_test.c,v 1.3 2019/02/22 14:22:51 bluhm Exp $ */
/*-
* Copyright (c) 2004 David Schultz <das@FreeBSD.org>
* All rights reserved.
@@ -137,11 +137,13 @@ raiseexcept(int excepts)
static int
getround(void)
{
- volatile double d;
+ volatile double d, e;
/*
* This test works just as well with 0.0 - 0.0, except on ia64
* where 0.0 - 0.0 gives the wrong sign when rounding downwards.
+ * For ia32 use a volatile double to force 64 bit rounding.
+ * Otherwise the i387 would use its internal 80 bit stack.
*/
d = 1.0;
d -= 1.0;
@@ -149,9 +151,11 @@ getround(void)
return (FE_DOWNWARD);
d = 1.0;
- if (d + (DBL_EPSILON * 3.0 / 4.0) == 1.0)
+ e = d + (DBL_EPSILON * 3.0 / 4.0);
+ if (e == 1.0)
return (FE_TOWARDZERO);
- if (d + (DBL_EPSILON * 1.0 / 4.0) > 1.0)
+ e = d + (DBL_EPSILON * 1.0 / 4.0);
+ if (e > 1.0)
return (FE_UPWARD);
return (FE_TONEAREST);