summaryrefslogtreecommitdiff
path: root/soft-fp
diff options
context:
space:
mode:
Diffstat (limited to 'soft-fp')
-rw-r--r--soft-fp/extenddftf2.c1
-rw-r--r--soft-fp/extendsfdf2.c1
-rw-r--r--soft-fp/extendsftf2.c1
-rw-r--r--soft-fp/extendxftf2.c2
-rw-r--r--soft-fp/op-common.h2
-rw-r--r--soft-fp/soft-fp.h18
6 files changed, 23 insertions, 2 deletions
diff --git a/soft-fp/extenddftf2.c b/soft-fp/extenddftf2.c
index 6984b41a80..17655326d8 100644
--- a/soft-fp/extenddftf2.c
+++ b/soft-fp/extenddftf2.c
@@ -28,6 +28,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#define FP_NO_EXACT_UNDERFLOW
#include "soft-fp.h"
#include "double.h"
#include "quad.h"
diff --git a/soft-fp/extendsfdf2.c b/soft-fp/extendsfdf2.c
index a9b6bfbee7..6224195ce9 100644
--- a/soft-fp/extendsfdf2.c
+++ b/soft-fp/extendsfdf2.c
@@ -28,6 +28,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#define FP_NO_EXACT_UNDERFLOW
#include "soft-fp.h"
#include "single.h"
#include "double.h"
diff --git a/soft-fp/extendsftf2.c b/soft-fp/extendsftf2.c
index 07fc3679ac..f67d614d7c 100644
--- a/soft-fp/extendsftf2.c
+++ b/soft-fp/extendsftf2.c
@@ -28,6 +28,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#define FP_NO_EXACT_UNDERFLOW
#include "soft-fp.h"
#include "single.h"
#include "quad.h"
diff --git a/soft-fp/extendxftf2.c b/soft-fp/extendxftf2.c
index 67b909563f..a1386a68e6 100644
--- a/soft-fp/extendxftf2.c
+++ b/soft-fp/extendxftf2.c
@@ -39,7 +39,7 @@ __extendxftf2 (XFtype a)
FP_DECL_Q (R);
TFtype r;
- FP_INIT_ROUNDMODE;
+ FP_INIT_TRAPPING_EXCEPTIONS;
FP_UNPACK_RAW_E (A, a);
#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
FP_EXTEND (Q, E, 4, 4, R, A);
diff --git a/soft-fp/op-common.h b/soft-fp/op-common.h
index ec0bc426e3..e3212ecfd5 100644
--- a/soft-fp/op-common.h
+++ b/soft-fp/op-common.h
@@ -1522,6 +1522,8 @@
_FP_FRAC_SLL_##dwc (D, (_FP_FRACBITS_##dfs \
- _FP_FRACBITS_##sfs)); \
D##_e = 0; \
+ if (FP_TRAPPING_EXCEPTIONS & FP_EX_UNDERFLOW) \
+ FP_SET_EXCEPTION (FP_EX_UNDERFLOW); \
} \
else \
{ \
diff --git a/soft-fp/soft-fp.h b/soft-fp/soft-fp.h
index ead9c97874..4018b0ee91 100644
--- a/soft-fp/soft-fp.h
+++ b/soft-fp/soft-fp.h
@@ -108,9 +108,15 @@
#endif
/* Initialize any machine-specific state used in
+ FP_TRAPPING_EXCEPTIONS or FP_HANDLE_EXCEPTIONS. */
+#ifndef FP_INIT_TRAPPING_EXCEPTIONS
+# define FP_INIT_TRAPPING_EXCEPTIONS FP_INIT_ROUNDMODE
+#endif
+
+/* Initialize any machine-specific state used in
FP_HANDLE_EXCEPTIONS. */
#ifndef FP_INIT_EXCEPTIONS
-# define FP_INIT_EXCEPTIONS FP_INIT_ROUNDMODE
+# define FP_INIT_EXCEPTIONS FP_INIT_TRAPPING_EXCEPTIONS
#endif
#ifndef FP_HANDLE_EXCEPTIONS
@@ -162,6 +168,16 @@
#endif
+/* A file using soft-fp may define FP_NO_EXACT_UNDERFLOW before
+ including soft-fp.h to indicate that, although a macro used there
+ could allow for the case of exact underflow requiring the underflow
+ exception to be raised if traps are enabled, for the particular
+ arguments used in that file no exact underflow can occur. */
+#ifdef FP_NO_EXACT_UNDERFLOW
+# undef FP_TRAPPING_EXCEPTIONS
+# define FP_TRAPPING_EXCEPTIONS 0
+#endif
+
#define _FP_ROUND_NEAREST(wc, X) \
do \
{ \