On Thu, 13 Mar 2025, Jacek Caban wrote:
On 12.03.2025 13:39, Martin Storsjö wrote:
On Tue, 11 Mar 2025, Jacek Caban wrote:
Instead of pseudo-pointers. This changes ABI.
---
mingw-w64-crt/misc/fesetenv.c | 32 ---------------------------
mingw-w64-headers/crt/fenv.h | 41 ++++++++++++++++-------------------
2 files changed, 19 insertions(+), 54 deletions(-)
+/* The default Intel x87 floating point environment (64-bit
mantissa) */
+extern const __MINGW_SELECTANY fenv_t __mingw_fe_pc64_env = {
0x3f3f003f, 0 };
+#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 };
+#define FE_PC53_ENV (&__mingw_fe_pc53_env)
This kind of __MINGW_SELECTANY constant isn't in very wide use so far;
are we certain that it works correctly with all toolchains?
It's used in quite a few places in platform headers, see
DECLSPEC_SELECTANY usage.
Ah, right, yes. (DECLSPEC_SELECTANY uses __declspec(selectany) directly,
not defined based on __MINGW_SELECTANY - that's why I didn't find it when
grepping around.) Yeah that should be used widely enough to consider it
safe to use.
As for the opaque bitmasks here; if I understand this correctly, it
should be possible to express this with the public fenv.h FE_*
constants, right? Although the crucial differing bit isn't one of the
standard constants, but should be _PC_53 from float.h instead (which
fenv_encode then should map into FENV_X_53)? The differing bit,
0x1000, seems wrong though - _PC_53 is 0x10000, while FENV_X_53 indeed
is 0x1000.
Or am I missing something here?
Values stored in fenv_t are encoded, so FENV_X_53 is the right one and
it's not public.
Ah, I see... All the conversions between FE_* flags, the internal float.h
flags like _EM_*, and the platform specific FENV_X/Y_ bits and the
architecture specific bits is more puzzling than I remembered.
So the FENV_X/Y bits are only used for storing in fenv_t (and are
architecture specific); these are then converted back into mostly
architecture independent float.h style flags in fesetenv, and then
converted again to architecture specific flags within __mingw_setfp.
Highly confusing, but it is what it is.
I guess these hardcoded constants are ok then, but please add a comment
explaining the bits they contain.
// Martin
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public