Tests: Trap floating point exceptions also on Windows

This commit is contained in:
Luca Bacci 2025-06-30 17:39:44 +02:00
parent 3834a79741
commit 7d744d78ed
2 changed files with 10 additions and 0 deletions

View file

@ -35,6 +35,9 @@
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef _WIN32
#include <float.h>
#endif
#include <errno.h>
#include <string.h>
#if HAVE_FCFINI
@ -146,6 +149,8 @@ _cairo_test_init (cairo_test_context_t *ctx,
#if HAVE_FEENABLEEXCEPT
feenableexcept (FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
#elif defined (_WIN32)
_controlfp_s (NULL, 0, _EM_ZERODIVIDE | _EM_INVALID | _EM_OVERFLOW);
#endif
ctx->test = test;

View file

@ -30,6 +30,9 @@
#include "cairo-test.h"
#include <fenv.h>
#ifdef _WIN32
#include <float.h>
#endif
#if !defined(INFINITY)
#define INFINITY HUGE_VAL
@ -71,6 +74,8 @@ if ((status) == CAIRO_STATUS_SUCCESS) { \
/* clear floating point exceptions (added by cairo_test_init()) */
#if HAVE_FEDISABLEEXCEPT
fedisableexcept (FE_INVALID);
#elif defined (_WIN32)
_controlfp_s (NULL, _EM_INVALID, _EM_INVALID);
#endif
/* create a bogus matrix and check results of attempted inversion */