Index: libgfortran/config/fpu-387.h
===================================================================
--- libgfortran/config/fpu-387.h (revision 212313)
+++ libgfortran/config/fpu-387.h (working copy)
@@ -23,8 +23,6 @@
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
. */
-#include
-
#ifndef __SSE_MATH__
#include "cpuid.h"
#endif
@@ -85,6 +83,11 @@
my_fenv_t;
+/* Check we can actually store the FPU state in the allocated size. */
+_Static_assert (sizeof(my_fenv_t) <= (size_t) GFC_FPE_STATE_BUFFER_SIZE,
+ "GFC_FPE_STATE_BUFFER_SIZE is too small");
+
+
/* Raise the supported floating-point exceptions from EXCEPTS. Other
bits in EXCEPTS are ignored. Code originally borrowed from
libatomic/config/x86/fenv.c. */
@@ -429,9 +432,6 @@
{
my_fenv_t *envp = state;
- /* Check we can actually store the FPU state in the allocated size. */
- assert (sizeof(my_fenv_t) <= (size_t) GFC_FPE_STATE_BUFFER_SIZE);
-
__asm__ __volatile__ ("fnstenv\t%0" : "=m" (*envp));
/* fnstenv has the side effect of masking all exceptions, so we need
@@ -447,9 +447,6 @@
{
my_fenv_t *envp = state;
- /* Check we can actually store the FPU state in the allocated size. */
- assert (sizeof(my_fenv_t) <= (size_t) GFC_FPE_STATE_BUFFER_SIZE);
-
/* glibc sources (sysdeps/x86_64/fpu/fesetenv.c) do something more
complex than this, but I think it suffices in our case. */
__asm__ __volatile__ ("fldenv\t%0" : : "m" (*envp));
Index: libgfortran/config/fpu-aix.h
===================================================================
--- libgfortran/config/fpu-aix.h (revision 212313)
+++ libgfortran/config/fpu-aix.h (working copy)
@@ -38,6 +38,11 @@
#endif
+/* Check we can actually store the FPU state in the allocated size. */
+_Static_assert (sizeof(fenv_t) <= (size_t) GFC_FPE_STATE_BUFFER_SIZE,
+ "GFC_FPE_STATE_BUFFER_SIZE is too small");
+
+
void
set_fpu_trap_exceptions (int trap, int notrap)
{
@@ -403,18 +408,12 @@
void
get_fpu_state (void *state)
{
- /* Check we can actually store the FPU state in the allocated size. */
- assert (sizeof(fenv_t) <= GFC_FPE_STATE_BUFFER_SIZE);
-
fegetenv (state);
}
void
set_fpu_state (void *state)
{
- /* Check we can actually store the FPU state in the allocated size. */
- assert (sizeof(fenv_t) <= GFC_FPE_STATE_BUFFER_SIZE);
-
fesetenv (state);
}
Index: libgfortran/config/fpu-sysv.h
===================================================================
--- libgfortran/config/fpu-sysv.h (revision 212313)
+++ libgfortran/config/fpu-sysv.h (working copy)
@@ -25,8 +25,6 @@
/* FPU-related code for SysV platforms with fpsetmask(). */
-#include
-
/* BSD and Solaris systems have slightly different types and functions
naming. We deal with these here, to simplify the code below. */
@@ -55,6 +53,8 @@
#endif
+
+
void
set_fpu_trap_exceptions (int trap, int notrap)
{
@@ -444,14 +444,16 @@
} fpu_state_t;
+/* Check we can actually store the FPU state in the allocated size. */
+_Static_assert (sizeof(fpu_state_t) <= (size_t) GFC_FPE_STATE_BUFFER_SIZE,
+ "GFC_FPE_STATE_BUFFER_SIZE is too small");
+
+
void
get_fpu_state (void *s)
{
fpu_state_t *state = s;
- /* Check we can actually store the FPU state in the allocated size. */
- assert (sizeof(fpu_state_t) <= GFC_FPE_STATE_BUFFER_SIZE);
-
state->mask = fpgetmask ();
state->sticky = fpgetsticky ();
state->round = fpgetround ();
@@ -462,9 +464,6 @@
{
fpu_state_t *state = s;
- /* Check we can actually store the FPU state in the allocated size. */
- assert (sizeof(fpu_state_t) <= GFC_FPE_STATE_BUFFER_SIZE);
-
fpsetmask (state->mask);
FPSETSTICKY (state->sticky);
fpsetround (state->round);
Index: libgfortran/config/fpu-glibc.h
===================================================================
--- libgfortran/config/fpu-glibc.h (revision 212313)
+++ libgfortran/config/fpu-glibc.h (working copy)
@@ -27,13 +27,16 @@
feenableexcept function in fenv.h to set individual exceptions
(there's nothing to do that in C99). */
-#include
-
#ifdef HAVE_FENV_H
#include
#endif
+/* Check we can actually store the FPU state in the allocated size. */
+_Static_assert (sizeof(fenv_t) <= (size_t) GFC_FPE_STATE_BUFFER_SIZE,
+ "GFC_FPE_STATE_BUFFER_SIZE is too small");
+
+
void set_fpu_trap_exceptions (int trap, int notrap)
{
#ifdef FE_INVALID
@@ -416,9 +419,6 @@
void
get_fpu_state (void *state)
{
- /* Check we can actually store the FPU state in the allocated size. */
- assert (sizeof(fenv_t) <= GFC_FPE_STATE_BUFFER_SIZE);
-
fegetenv (state);
}
@@ -426,9 +426,6 @@
void
set_fpu_state (void *state)
{
- /* Check we can actually store the FPU state in the allocated size. */
- assert (sizeof(fenv_t) <= GFC_FPE_STATE_BUFFER_SIZE);
-
fesetenv (state);
}