--
Best regards,
LIU Hao

From 27c6bbadfbf9341965042f32e911a603422d1e07 Mon Sep 17 00:00:00 2001
From: LIU Hao <[email protected]>
Date: Sun, 30 Mar 2025 02:01:39 +0800
Subject: [PATCH] crt: Move definitions of `__mingw_fe_dfl_env` to 'fesetenv.c'
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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

This eliminates such warnings in C:

   .../mingw-w64-headers/crt/fenv.h:64:39: warning: ‘__mingw_fe_dfl_env’ 
initialized and declared ‘extern’
    extern const __MINGW_SELECTANY fenv_t __mingw_fe_dfl_env = { 0, 0 };
                                          ^~~~~~~~~~~~~~~~~~

and for some unknown reasons, when compiling libquadmath:

   math/.libs/x2y2m1q.o: duplicate section 
`.rdata$__mingw_fe_pc53_env[__mingw_fe_pc53_env]' has different size
   math/.libs/x2y2m1q.o: duplicate section 
`.rdata$__mingw_fe_pc64_env[__mingw_fe_pc64_env]' has different size
   math/.libs/x2y2m1q.o: duplicate section 
`.rdata$__mingw_fe_dfl_env[__mingw_fe_dfl_env]' has different size
   math/.libs/acoshq.o: duplicate section 
`.rdata$__mingw_fe_pc53_env[__mingw_fe_pc53_env]' has different size
   math/.libs/acoshq.o: duplicate section 
`.rdata$__mingw_fe_pc64_env[__mingw_fe_pc64_env]' has different size
   math/.libs/acoshq.o: duplicate section 
`.rdata$__mingw_fe_dfl_env[__mingw_fe_dfl_env]' has different size
   ...

Signed-off-by: LIU Hao <[email protected]>
---
 mingw-w64-crt/misc/fesetenv.c | 4 ++++
 mingw-w64-headers/crt/fenv.h  | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/mingw-w64-crt/misc/fesetenv.c b/mingw-w64-crt/misc/fesetenv.c
index 5a4426a30..61c0f1b21 100644
--- a/mingw-w64-crt/misc/fesetenv.c
+++ b/mingw-w64-crt/misc/fesetenv.c
@@ -16,6 +16,10 @@
    exceptions.
  */
 
+const fenv_t __mingw_fe_dfl_env = { 0, 0 };
+const fenv_t __mingw_fe_pc64_env = { 0x3f3f003f, 0 };
+const fenv_t __mingw_fe_pc53_env = { 0x3f3f103f, 0 };
+
 extern void (* __MINGW_IMP_SYMBOL(_fpreset))(void);
 extern void _fpreset(void);
 
diff --git a/mingw-w64-headers/crt/fenv.h b/mingw-w64-headers/crt/fenv.h
index 7d441c287..b4ab0718c 100644
--- a/mingw-w64-headers/crt/fenv.h
+++ b/mingw-w64-headers/crt/fenv.h
@@ -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
-- 
2.49.0

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to