aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--math/libm-test.inc141
-rw-r--r--sysdeps/i386/fpu/s_floor.S12
-rw-r--r--sysdeps/i386/fpu/s_floorf.S12
-rw-r--r--sysdeps/i386/fpu/s_floorl.S17
-rw-r--r--sysdeps/x86_64/fpu/s_floorl.S15
6 files changed, 114 insertions, 94 deletions
diff --git a/ChangeLog b/ChangeLog
index d9d93edc02..a67e532b72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,17 @@
2016-06-27 Joseph Myers <joseph@codesourcery.com>
[BZ #15479]
+ * sysdeps/i386/fpu/s_floor.S (__floor): Save and restore
+ floating-point environment rather than just control word.
+ * sysdeps/i386/fpu/s_floorf.S (__floorf): Likewise.
+ * sysdeps/i386/fpu/s_floorl.S (__floorl): Save and restore
+ floating-point environment, with "invalid" exceptions merged in,
+ rather than just control word.
+ * sysdeps/x86_64/fpu/s_floorl.S (__floorl): Likewise.
+ * math/libm-test.inc (floor_test_data): Do not allow spurious
+ "inexact" exceptions.
+
+ [BZ #15479]
* sysdeps/i386/fpu/s_ceil.S (__ceil): Save and restore
floating-point environment rather than just control word.
* sysdeps/i386/fpu/s_ceilf.S (__ceilf): Likewise.
diff --git a/math/libm-test.inc b/math/libm-test.inc
index ad97da1cc0..9f6e21da5b 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -7308,14 +7308,13 @@ static const struct test_f_f_data floor_test_data[] =
TEST_f_f (floor, snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
TEST_f_f (floor, -snan_value, qnan_value, NO_INEXACT_EXCEPTION|INVALID_EXCEPTION),
- /* Bug 15479: spurious "inexact" exception may occur. */
- TEST_f_f (floor, lit_pi, 3.0, ERRNO_UNCHANGED),
- TEST_f_f (floor, -lit_pi, -4.0, ERRNO_UNCHANGED),
- TEST_f_f (floor, min_subnorm_value, 0.0, ERRNO_UNCHANGED),
- TEST_f_f (floor, min_value, 0.0, ERRNO_UNCHANGED),
- TEST_f_f (floor, 0.1, 0.0, ERRNO_UNCHANGED),
- TEST_f_f (floor, 0.25, 0.0, ERRNO_UNCHANGED),
- TEST_f_f (floor, 0.625, 0.0, ERRNO_UNCHANGED),
+ TEST_f_f (floor, lit_pi, 3.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -lit_pi, -4.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, min_subnorm_value, 0.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, min_value, 0.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 0.1, 0.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 0.25, 0.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 0.625, 0.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_f (floor, 1, 1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_f (floor, 2, 2, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_f (floor, 0x1p23, 0x1p23, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
@@ -7334,11 +7333,11 @@ static const struct test_f_f_data floor_test_data[] =
TEST_f_f (floor, 0x1p113, 0x1p113, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_f (floor, 0x1p114, 0x1p114, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_f (floor, max_value, max_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
- TEST_f_f (floor, -min_subnorm_value, -1.0, ERRNO_UNCHANGED),
- TEST_f_f (floor, -min_value, -1.0, ERRNO_UNCHANGED),
- TEST_f_f (floor, -0.1, -1.0, ERRNO_UNCHANGED),
- TEST_f_f (floor, -0.25, -1.0, ERRNO_UNCHANGED),
- TEST_f_f (floor, -0.625, -1.0, ERRNO_UNCHANGED),
+ TEST_f_f (floor, -min_subnorm_value, -1.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -min_value, -1.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -0.1, -1.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -0.25, -1.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -0.625, -1.0, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_f (floor, -1, -1, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_f (floor, -2, -2, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
TEST_f_f (floor, -0x1p23, -0x1p23, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
@@ -7360,78 +7359,78 @@ static const struct test_f_f_data floor_test_data[] =
#if MANT_DIG >= 64
/* The result can only be represented in long double. */
- TEST_f_f (floor, 4503599627370495.5L, 4503599627370495.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 4503599627370496.25L, 4503599627370496.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 4503599627370496.5L, 4503599627370496.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 4503599627370496.75L, 4503599627370496.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 4503599627370497.5L, 4503599627370497.0L, ERRNO_UNCHANGED),
+ TEST_f_f (floor, 4503599627370495.5L, 4503599627370495.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 4503599627370496.25L, 4503599627370496.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 4503599627370496.5L, 4503599627370496.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 4503599627370496.75L, 4503599627370496.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 4503599627370497.5L, 4503599627370497.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
# if MANT_DIG > 100
- TEST_f_f (floor, 4503599627370494.5000000000001L, 4503599627370494.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 4503599627370495.5000000000001L, 4503599627370495.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 4503599627370496.5000000000001L, 4503599627370496.0L, ERRNO_UNCHANGED),
+ TEST_f_f (floor, 4503599627370494.5000000000001L, 4503599627370494.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 4503599627370495.5000000000001L, 4503599627370495.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 4503599627370496.5000000000001L, 4503599627370496.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
# endif
- TEST_f_f (floor, -4503599627370495.5L, -4503599627370496.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -4503599627370496.25L, -4503599627370497.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -4503599627370496.5L, -4503599627370497.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -4503599627370496.75L, -4503599627370497.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -4503599627370497.5L, -4503599627370498.0L, ERRNO_UNCHANGED),
+ TEST_f_f (floor, -4503599627370495.5L, -4503599627370496.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -4503599627370496.25L, -4503599627370497.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -4503599627370496.5L, -4503599627370497.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -4503599627370496.75L, -4503599627370497.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -4503599627370497.5L, -4503599627370498.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
# if MANT_DIG > 100
- TEST_f_f (floor, -4503599627370494.5000000000001L, -4503599627370495.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -4503599627370495.5000000000001L, -4503599627370496.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -4503599627370496.5000000000001L, -4503599627370497.0L, ERRNO_UNCHANGED),
+ TEST_f_f (floor, -4503599627370494.5000000000001L, -4503599627370495.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -4503599627370495.5000000000001L, -4503599627370496.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -4503599627370496.5000000000001L, -4503599627370497.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
# endif
- TEST_f_f (floor, 9007199254740991.5L, 9007199254740991.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 9007199254740992.25L, 9007199254740992.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 9007199254740992.5L, 9007199254740992.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 9007199254740992.75L, 9007199254740992.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 9007199254740993.5L, 9007199254740993.0L, ERRNO_UNCHANGED),
+ TEST_f_f (floor, 9007199254740991.5L, 9007199254740991.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 9007199254740992.25L, 9007199254740992.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 9007199254740992.5L, 9007199254740992.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 9007199254740992.75L, 9007199254740992.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 9007199254740993.5L, 9007199254740993.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
# if MANT_DIG > 100
- TEST_f_f (floor, 9007199254740991.0000000000001L, 9007199254740991.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 9007199254740992.0000000000001L, 9007199254740992.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 9007199254740993.0000000000001L, 9007199254740993.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 9007199254740991.5000000000001L, 9007199254740991.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 9007199254740992.5000000000001L, 9007199254740992.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 9007199254740993.5000000000001L, 9007199254740993.0L, ERRNO_UNCHANGED),
+ TEST_f_f (floor, 9007199254740991.0000000000001L, 9007199254740991.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 9007199254740992.0000000000001L, 9007199254740992.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 9007199254740993.0000000000001L, 9007199254740993.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 9007199254740991.5000000000001L, 9007199254740991.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 9007199254740992.5000000000001L, 9007199254740992.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 9007199254740993.5000000000001L, 9007199254740993.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
# endif
- TEST_f_f (floor, -9007199254740991.5L, -9007199254740992.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -9007199254740992.25L, -9007199254740993.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -9007199254740992.5L, -9007199254740993.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -9007199254740992.75L, -9007199254740993.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -9007199254740993.5L, -9007199254740994.0L, ERRNO_UNCHANGED),
+ TEST_f_f (floor, -9007199254740991.5L, -9007199254740992.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -9007199254740992.25L, -9007199254740993.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -9007199254740992.5L, -9007199254740993.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -9007199254740992.75L, -9007199254740993.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -9007199254740993.5L, -9007199254740994.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
# if MANT_DIG > 100
- TEST_f_f (floor, -9007199254740991.0000000000001L, -9007199254740992.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -9007199254740992.0000000000001L, -9007199254740993.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -9007199254740993.0000000000001L, -9007199254740994.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -9007199254740991.5000000000001L, -9007199254740992.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -9007199254740992.5000000000001L, -9007199254740993.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -9007199254740993.5000000000001L, -9007199254740994.0L, ERRNO_UNCHANGED),
+ TEST_f_f (floor, -9007199254740991.0000000000001L, -9007199254740992.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -9007199254740992.0000000000001L, -9007199254740993.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -9007199254740993.0000000000001L, -9007199254740994.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -9007199254740991.5000000000001L, -9007199254740992.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -9007199254740992.5000000000001L, -9007199254740993.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -9007199254740993.5000000000001L, -9007199254740994.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
# endif
- TEST_f_f (floor, 72057594037927935.5L, 72057594037927935.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 72057594037927936.25L, 72057594037927936.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 72057594037927936.5L, 72057594037927936.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 72057594037927936.75L, 72057594037927936.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 72057594037927937.5L, 72057594037927937.0L, ERRNO_UNCHANGED),
-
- TEST_f_f (floor, -72057594037927935.5L, -72057594037927936.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -72057594037927936.25L, -72057594037927937.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -72057594037927936.5L, -72057594037927937.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -72057594037927936.75L, -72057594037927937.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -72057594037927937.5L, -72057594037927938.0L, ERRNO_UNCHANGED),
-
- TEST_f_f (floor, 10141204801825835211973625643007.5L, 10141204801825835211973625643007.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 10141204801825835211973625643008.25L, 10141204801825835211973625643008.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 10141204801825835211973625643008.5L, 10141204801825835211973625643008.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 10141204801825835211973625643008.75L, 10141204801825835211973625643008.0L, ERRNO_UNCHANGED),
- TEST_f_f (floor, 10141204801825835211973625643009.5L, 10141204801825835211973625643009.0L, ERRNO_UNCHANGED),
-
- TEST_f_f (floor, 0xf.ffffffffffffff8p+47L, 0xf.fffffffffffep+47L, ERRNO_UNCHANGED),
- TEST_f_f (floor, -0x8.000000000000004p+48L, -0x8.000000000001p+48L, ERRNO_UNCHANGED),
+ TEST_f_f (floor, 72057594037927935.5L, 72057594037927935.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 72057594037927936.25L, 72057594037927936.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 72057594037927936.5L, 72057594037927936.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 72057594037927936.75L, 72057594037927936.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 72057594037927937.5L, 72057594037927937.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+
+ TEST_f_f (floor, -72057594037927935.5L, -72057594037927936.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -72057594037927936.25L, -72057594037927937.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -72057594037927936.5L, -72057594037927937.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -72057594037927936.75L, -72057594037927937.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -72057594037927937.5L, -72057594037927938.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+
+ TEST_f_f (floor, 10141204801825835211973625643007.5L, 10141204801825835211973625643007.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 10141204801825835211973625643008.25L, 10141204801825835211973625643008.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 10141204801825835211973625643008.5L, 10141204801825835211973625643008.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 10141204801825835211973625643008.75L, 10141204801825835211973625643008.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, 10141204801825835211973625643009.5L, 10141204801825835211973625643009.0L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+
+ TEST_f_f (floor, 0xf.ffffffffffffff8p+47L, 0xf.fffffffffffep+47L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+ TEST_f_f (floor, -0x8.000000000000004p+48L, -0x8.000000000001p+48L, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
#endif
};
diff --git a/sysdeps/i386/fpu/s_floor.S b/sysdeps/i386/fpu/s_floor.S
index 2d6287dc79..ed837dae40 100644
--- a/sysdeps/i386/fpu/s_floor.S
+++ b/sysdeps/i386/fpu/s_floor.S
@@ -9,10 +9,10 @@ RCSID("$NetBSD: s_floor.S,v 1.4 1995/05/09 00:01:59 jtc Exp $")
ENTRY(__floor)
fldl 4(%esp)
- subl $8,%esp
- cfi_adjust_cfa_offset (8)
+ subl $32,%esp
+ cfi_adjust_cfa_offset (32)
- fstcw 4(%esp) /* store fpu control word */
+ fnstenv 4(%esp) /* store fpu environment */
/* We use here %edx although only the low 1 bits are defined.
But none of the operations should care and they are faster
@@ -25,10 +25,10 @@ ENTRY(__floor)
frndint /* round */
- fldcw 4(%esp) /* restore original control word */
+ fldenv 4(%esp) /* restore original environment */
- addl $8,%esp
- cfi_adjust_cfa_offset (-8)
+ addl $32,%esp
+ cfi_adjust_cfa_offset (-32)
ret
END (__floor)
weak_alias (__floor, floor)
diff --git a/sysdeps/i386/fpu/s_floorf.S b/sysdeps/i386/fpu/s_floorf.S
index e969fbe587..84b6f7ed99 100644
--- a/sysdeps/i386/fpu/s_floorf.S
+++ b/sysdeps/i386/fpu/s_floorf.S
@@ -9,10 +9,10 @@ RCSID("$NetBSD: s_floorf.S,v 1.3 1995/05/09 00:04:32 jtc Exp $")
ENTRY(__floorf)
flds 4(%esp)
- subl $8,%esp
- cfi_adjust_cfa_offset (8)
+ subl $32,%esp
+ cfi_adjust_cfa_offset (32)
- fstcw 4(%esp) /* store fpu control word */
+ fnstenv 4(%esp) /* store fpu environment */
/* We use here %edx although only the low 1 bits are defined.
But none of the operations should care and they are faster
@@ -25,10 +25,10 @@ ENTRY(__floorf)
frndint /* round */
- fldcw 4(%esp) /* restore original control word */
+ fldenv 4(%esp) /* restore original environment */
- addl $8,%esp
- cfi_adjust_cfa_offset (-8)
+ addl $32,%esp
+ cfi_adjust_cfa_offset (-32)
ret
END (__floorf)
weak_alias (__floorf, floorf)
diff --git a/sysdeps/i386/fpu/s_floorl.S b/sysdeps/i386/fpu/s_floorl.S
index 1206554c4a..dc74a0c446 100644
--- a/sysdeps/i386/fpu/s_floorl.S
+++ b/sysdeps/i386/fpu/s_floorl.S
@@ -10,10 +10,10 @@ RCSID("$NetBSD: $")
ENTRY(__floorl)
fldt 4(%esp)
- subl $8,%esp
- cfi_adjust_cfa_offset (8)
+ subl $32,%esp
+ cfi_adjust_cfa_offset (32)
- fstcw 4(%esp) /* store fpu control word */
+ fnstenv 4(%esp) /* store fpu environment */
/* We use here %edx although only the low 1 bits are defined.
But none of the operations should care and they are faster
@@ -26,10 +26,15 @@ ENTRY(__floorl)
frndint /* round */
- fldcw 4(%esp) /* restore original control word */
+ /* Preserve "invalid" exceptions from sNaN input. */
+ fnstsw
+ andl $0x1, %eax
+ orl %eax, 8(%esp)
- addl $8,%esp
- cfi_adjust_cfa_offset (-8)
+ fldenv 4(%esp) /* restore original environment */
+
+ addl $32,%esp
+ cfi_adjust_cfa_offset (-32)
ret
END (__floorl)
weak_alias (__floorl, floorl)
diff --git a/sysdeps/x86_64/fpu/s_floorl.S b/sysdeps/x86_64/fpu/s_floorl.S
index f9ecc388df..535fdd8571 100644
--- a/sysdeps/x86_64/fpu/s_floorl.S
+++ b/sysdeps/x86_64/fpu/s_floorl.S
@@ -10,20 +10,25 @@
ENTRY(__floorl)
fldt 8(%rsp)
- fstcw -4(%rsp) /* store fpu control word */
+ fnstenv -28(%rsp) /* store fpu environment */
/* We use here %edx although only the low 1 bits are defined.
But none of the operations should care and they are faster
than the 16 bit operations. */
movl $0x400,%edx /* round towards -oo */
- orl -4(%rsp),%edx
+ orl -28(%rsp),%edx
andl $0xf7ff,%edx
- movl %edx,-8(%rsp)
- fldcw -8(%rsp) /* load modified control word */
+ movl %edx,-32(%rsp)
+ fldcw -32(%rsp) /* load modified control word */
frndint /* round */
- fldcw -4(%rsp) /* restore original control word */
+ /* Preserve "invalid" exceptions from sNaN input. */
+ fnstsw
+ andl $0x1, %eax
+ orl %eax, -24(%rsp)
+
+ fldenv -28(%rsp) /* restore original environment */
ret
END (__floorl)