summaryrefslogtreecommitdiff
path: root/libgfortran/config
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2013-06-17 07:48:21 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2013-06-17 07:48:21 +0000
commit553e7cefa6034f54ee588e22cd96e64e343d500a (patch)
treef0f53ca508f0a7d7947323827651db99fab185cc /libgfortran/config
parent5530d2ddc939f410566f957ad5296fe17ab2297c (diff)
downloadgcc-553e7cefa6034f54ee588e22cd96e64e343d500a.tar.gz
2013-06-17 Tobias Burnus <burnus@net-b.de>
* gfortran.h (gfc_option_t): Add fpe_summary. * gfortran.texi (_gfortran_set_options): Update. * invoke.texi (-ffpe-summary): Add doc. * lang.opt (ffpe-summary): Add flag. * options.c (gfc_init_options, gfc_handle_option): Handle it. (gfc_handle_fpe_option): Renamed from gfc_handle_fpe_trap_option, also handle fpe_summary. * trans-decl.c (create_main_function): Update _gfortran_set_options call. 2013-06-17 Tobias Burnus <burnus@net-b.de> * libgfortran.h (compile_options_t) Add fpe_summary. (get_fpu_except_flags): New prototype. * runtime/compile_options.c (set_options, init_compile_options): Handle fpe_summary. * runtime/stop.c (report_exception): New function. (stop_numeric, stop_numeric_f08, stop_string, error_stop_string, error_stop_numeric): Call it. * config/fpu-387.h (get_fpu_except_flags): New function. * config/fpu-aix.h (get_fpu_except_flags): New function. * config/fpu-generic.h (get_fpu_except_flags): New function. * config/fpu-glibc.h (get_fpu_except_flags): New function. * config/fpu-glibc.h (get_fpu_except_flags): New function. * configure.ac: Check for fpxcp.h. * configure: Regenerate. * config.h.in: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200147 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/config')
-rw-r--r--libgfortran/config/fpu-387.h37
-rw-r--r--libgfortran/config/fpu-aix.h35
-rw-r--r--libgfortran/config/fpu-generic.h6
-rw-r--r--libgfortran/config/fpu-glibc.h42
-rw-r--r--libgfortran/config/fpu-sysv.h42
5 files changed, 162 insertions, 0 deletions
diff --git a/libgfortran/config/fpu-387.h b/libgfortran/config/fpu-387.h
index 913eb60b1d9..608354d975a 100644
--- a/libgfortran/config/fpu-387.h
+++ b/libgfortran/config/fpu-387.h
@@ -134,3 +134,40 @@ void set_fpu (void)
asm volatile ("%vldmxcsr %0" : : "m" (cw_sse));
}
}
+
+
+int
+get_fpu_except_flags (void)
+{
+ int result;
+ unsigned short cw;
+
+ __asm__ __volatile__ ("fnstsw\t%0" : "=a" (cw));
+
+ if (has_sse())
+ {
+ unsigned int cw_sse;
+ __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (cw_sse));
+ cw |= cw_sse;
+ }
+
+ if (cw & _FPU_MASK_IM)
+ result |= GFC_FPE_INVALID;
+
+ if (cw & _FPU_MASK_ZM)
+ result |= GFC_FPE_ZERO;
+
+ if (cw & _FPU_MASK_OM)
+ result |= GFC_FPE_OVERFLOW;
+
+ if (cw & _FPU_MASK_UM)
+ result |= GFC_FPE_UNDERFLOW;
+
+ if (cw & _FPU_MASK_DM)
+ result |= GFC_FPE_DENORMAL;
+
+ if (cw & _FPU_MASK_PM)
+ result |= GFC_FPE_INEXACT;
+
+ return result;
+}
diff --git a/libgfortran/config/fpu-aix.h b/libgfortran/config/fpu-aix.h
index bcb5500c657..1ba9d4cfb22 100644
--- a/libgfortran/config/fpu-aix.h
+++ b/libgfortran/config/fpu-aix.h
@@ -29,6 +29,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <fptrap.h>
#endif
+#ifdef HAVE_FPXCP_H
+#include <fpxcp.h>
+#endif
+
void
set_fpu (void)
{
@@ -81,3 +85,34 @@ set_fpu (void)
fp_trap(FP_TRAP_SYNC);
fp_enable(mode);
}
+
+
+int
+get_fpu_except_flags (void)
+{
+ int result, set_excepts;
+
+ result = 0;
+
+#ifdef HAVE_FPXCP_H
+ if (!fp_any_xcp ())
+ return 0;
+
+ if (fp_invalid_op ())
+ result |= GFC_FPE_INVALID;
+
+ if (fp_divbyzero ())
+ result |= GFC_FPE_ZERO;
+
+ if (fp_overflow ())
+ result |= GFC_FPE_OVERFLOW;
+
+ if (fp_underflow ())
+ result |= GFC_FPE_UNDERFLOW;
+
+ if (fp_inexact ())
+ result |= GFC_FPE_INEXACT;
+#endif
+
+ return result;
+}
diff --git a/libgfortran/config/fpu-generic.h b/libgfortran/config/fpu-generic.h
index 23212f8fb3c..4223f2e27d4 100644
--- a/libgfortran/config/fpu-generic.h
+++ b/libgfortran/config/fpu-generic.h
@@ -50,3 +50,9 @@ set_fpu (void)
estr_write ("Fortran runtime warning: IEEE 'inexact' "
"exception not supported.\n");
}
+
+int
+get_fpu_except_flags (void)
+{
+ return 0;
+}
diff --git a/libgfortran/config/fpu-glibc.h b/libgfortran/config/fpu-glibc.h
index 5c7ad84ff39..e0d1019b919 100644
--- a/libgfortran/config/fpu-glibc.h
+++ b/libgfortran/config/fpu-glibc.h
@@ -85,3 +85,45 @@ void set_fpu (void)
"exception not supported.\n");
#endif
}
+
+
+int
+get_fpu_except_flags (void)
+{
+ int result, set_excepts;
+
+ result = 0;
+ set_excepts = fetestexcept (FE_ALL_EXCEPT);
+
+#ifdef FE_INVALID
+ if (set_excepts & FE_INVALID)
+ result |= GFC_FPE_INVALID;
+#endif
+
+#ifdef FE_DIVBYZERO
+ if (set_excepts & FE_DIVBYZERO)
+ result |= GFC_FPE_ZERO;
+#endif
+
+#ifdef FE_OVERFLOW
+ if (set_excepts & FE_OVERFLOW)
+ result |= GFC_FPE_OVERFLOW;
+#endif
+
+#ifdef FE_UNDERFLOW
+ if (set_excepts & FE_UNDERFLOW)
+ result |= GFC_FPE_UNDERFLOW;
+#endif
+
+#ifdef FE_DENORMAL
+ if (set_excepts & FE_DENORMAL)
+ result |= GFC_FPE_DENORMAL;
+#endif
+
+#ifdef FE_INEXACT
+ if (set_excepts & FE_INEXACT)
+ result |= GFC_FPE_INEXACT;
+#endif
+
+ return result;
+}
diff --git a/libgfortran/config/fpu-sysv.h b/libgfortran/config/fpu-sysv.h
index b32702b3ce9..8fc52d5eade 100644
--- a/libgfortran/config/fpu-sysv.h
+++ b/libgfortran/config/fpu-sysv.h
@@ -80,3 +80,45 @@ set_fpu (void)
fpsetmask(cw);
}
+
+int
+get_fpu_except_flags (void)
+{
+ int result;
+ fp_except_t set_excepts;
+
+ result = 0;
+ set_excepts = fpgetsticky ();
+
+#ifdef FP_X_INV
+ if (set_excepts & FP_X_INV)
+ result |= GFC_FPE_INVALID;
+#endif
+
+#ifdef FP_X_DZ
+ if (set_excepts & FP_X_DZ)
+ result |= GFC_FPE_ZERO;
+#endif
+
+#ifdef FP_X_OFL
+ if (set_excepts & FP_X_OFL)
+ result |= GFC_FPE_OVERFLOW;
+#endif
+
+#ifdef FP_X_UFL
+ if (set_excepts & FP_X_UFL)
+ result |= GFC_FPE_UNDERFLOW;
+#endif
+
+#ifdef FP_X_DNML
+ if (set_excepts & FP_X_DNML)
+ result |= GFC_FPE_DENORMAL;
+#endif
+
+#ifdef FP_X_IMP
+ if (set_excepts & FP_X_IMP)
+ result |= GFC_FPE_INEXACT;
+#endif
+
+ return result;
+}