+2014-07-07 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+
+ * config/fpu-387.h, config/fpu-aix.h, config/fpu-sysv.h,
+ config/fpu-glibc.h: Use static assertions.
+
2014-07-05 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* configure, config.h.in: Regenerate.
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
-#include <assert.h>
-
#ifndef __SSE_MATH__
#include "cpuid.h"
#endif
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. */
{
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
{
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));
#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)
{
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);
}
feenableexcept function in fenv.h to set individual exceptions
(there's nothing to do that in C99). */
-#include <assert.h>
-
#ifdef HAVE_FENV_H
#include <fenv.h>
#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
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);
}
/* FPU-related code for SysV platforms with fpsetmask(). */
-#include <assert.h>
-
/* BSD and Solaris systems have slightly different types and functions
naming. We deal with these here, to simplify the code below. */
} 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 ();
{
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);