Hi Bruno,

Bruno Haible <[email protected]> writes:

> On the GitHub CI machines, I now see compilation failures on mingw:
> [...]
> This means that the mingw people made a release with that change included,
> and it is active in the GitHub CI environments.
>
> I want to get this fixed ASAP, but I don't want to duplicate work that you
> already did. How far did you get on this topic?

I had a look a few weekends ago, but was not able to get it working.
Then forgot about it... Sorry, I do not have much done for you.

But, I think most of my issues came from trying to implement 'fegetenv'
and 'fesetenv'. Because in those functions we must be able to save and
restore the X87 FPU status & control word and the MXCSR control and
status register in 2 32-bit integers:

    typedef struct
    {
      unsigned long _Fe_ctl;
      unsigned long _Fe_stat;
    } fenv_t;

I thought the proper way to do this was to reserve the low bits for the
exception and trap bits and then use the higher bits to mark if they
were set in the X87 FPU, MXCSR, or both.

For the rest of then functions (e.g. 'feenableexcept') we would return
the set of enabled exceptions if they were in either the X87 FPU or
MXCSR.

Since the MinGW update made the FE_* macros match MSVC, I think that the
following diff could be applied [1]:

diff --git a/lib/fenv-private.h b/lib/fenv-private.h
index 24755f1c32..7f3afd9dc3 100644
--- a/lib/fenv-private.h
+++ b/lib/fenv-private.h
@@ -95,7 +95,7 @@ typedef struct
   }
 x86_387_fenv_t;
 
-# if defined _MSC_VER
+# if defined _MSC_VER || (defined __MINGW32__ && FE_INVALID != 0x01)
 /* The MSVC header files have different values for the floating-point 
exceptions
    than all the other platforms.  Define some handy macros for conversion.  */
 #  define exceptions_to_x86hardware(exceptions) \

Then most of the functions for MinGW would be the same as MSVC, except
for the need to check the X87 FPU as well which is not needed on MSVC.

Again, sorry for not having more done. But hopefully my thought process
provides a bit of help...

[1] I think that '(defined __MINGW32__ && FE_INVALID != 0x01)' can also
be used in the configure checks to allow for older MinGW to also build.
For example in m4/fenv-rounding.m4 there is:

        AC_CACHE_CHECK([whether fesetround works],
          [gl_cv_func_fesetround_works],
          [case "$host_os" in
             # Guess no on native Windows other than mingw.
             mingw* | windows*)
               AC_EGREP_CPP([Problem], [
    #ifndef __MINGW32__
     Problem
    #endif
                 ],
                 [gl_cv_func_fesetround_works="guessing no"],
                 [gl_cv_func_fesetround_works="guessing yes"])
               ;;
             *) gl_cv_func_fesetround_works="guessing yes" ;;
           esac

I did not realized that these also needed changing until an
embarrassingly long time messing around with the *.c files...

Collin

Reply via email to