1
0
mirror of https://git.code.sf.net/p/mingw-w64/mingw-w64 synced 2025-04-18 17:44:18 +03:00

crt: Move definitions of __mingw_fe_dfl_env to 'fesetenv.c'

These macros are to be used with `fesetenv()`, so they belong there.

Having these `selectany` variables in 'fenv.h' causes them to be defined with
external linkage in every source file which includes 'fenv.h'. They can also
be exported inappropriately from a DLL, which either is built with
`--export-all-symbols`, or does not contain explicit `dllexport` and is not
built with a DEF file.

Signed-off-by: LIU Hao <lh_mouse@126.com>
This commit is contained in:
LIU Hao 2025-03-31 21:11:55 +08:00
parent 2f7aff6511
commit 22f9ed9987
No known key found for this signature in database
2 changed files with 19 additions and 3 deletions

View File

@ -6,6 +6,22 @@
#include <internal.h>
/* The FE_DFL_ENV macro is required by standard.
fesetenv will use the environment set at app startup.*/
const fenv_t __mingw_fe_dfl_env = { 0, 0 };
/* The C99 standard (7.6.9) allows us to define implementation-specific macros for
different fp environments */
#if defined(__i386__) || defined(__x86_64__)
/* The default Intel x87 floating point environment (64-bit mantissa) */
const fenv_t __mingw_fe_pc64_env = { 0x3f3f003f, 0 };
/* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */
const fenv_t __mingw_fe_pc53_env = { 0x3f3f103f, 0 };
#endif
/* 7.6.4.3
The fesetenv function establishes the floating-point environment
represented by the object pointed to by envp. The argument envp

View File

@ -61,7 +61,7 @@ extern "C" {
/* The FE_DFL_ENV macro is required by standard.
fesetenv will use the environment set at app startup.*/
extern const __MINGW_SELECTANY fenv_t __mingw_fe_dfl_env = { 0, 0 };
extern const fenv_t __mingw_fe_dfl_env;
#define FE_DFL_ENV (&__mingw_fe_dfl_env)
/* The C99 standard (7.6.9) allows us to define implementation-specific macros for
@ -69,11 +69,11 @@ extern const __MINGW_SELECTANY fenv_t __mingw_fe_dfl_env = { 0, 0 };
#if defined(__i386__) || defined(__x86_64__)
/* The default Intel x87 floating point environment (64-bit mantissa) */
extern const __MINGW_SELECTANY fenv_t __mingw_fe_pc64_env = { 0x3f3f003f, 0 };
extern const fenv_t __mingw_fe_pc64_env;
#define FE_PC64_ENV (&__mingw_fe_pc64_env)
/* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */
extern const __MINGW_SELECTANY fenv_t __mingw_fe_pc53_env = { 0x3f3f103f, 0 };
extern const fenv_t __mingw_fe_pc53_env;
#define FE_PC53_ENV (&__mingw_fe_pc53_env)
#endif