On x86 or x86_64 platforms where 'long double' is identical to 'double'
(such as MSVC), it is not necessary to switch to a higher precision for
working with 'long double' values.

Currently this is a no-op because fpucw.h does not have definitions
for _MSC_VER. But anyway.


2026-01-20  Bruno Haible  <[email protected]>

        vasnprintf: Optimize when 'long double' is the same as 'double'.
        * lib/vasnprintf.c (DECL_LONG_DOUBLE_ROUNDING,
        BEGIN_LONG_DOUBLE_ROUNDING, END_LONG_DOUBLE_ROUNDING): Override when
        HAVE_SAME_LONG_DOUBLE_AS_DOUBLE.

diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 85e30b9049..12bdd45ba1 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -134,6 +134,16 @@
 # include "fpucw.h"
 #endif
 
+#if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
+/* Override macros from fpucw.h.  */
+# undef DECL_LONG_DOUBLE_ROUNDING
+# define DECL_LONG_DOUBLE_ROUNDING
+# undef BEGIN_LONG_DOUBLE_ROUNDING
+# define BEGIN_LONG_DOUBLE_ROUNDING()
+# undef END_LONG_DOUBLE_ROUNDING
+# define END_LONG_DOUBLE_ROUNDING()
+#endif
+
 /* Default parameters.  */
 #ifndef VASNPRINTF
 # if WIDE_CHAR_VERSION




Reply via email to