summaryrefslogtreecommitdiff
path: root/lib/stdio.in.h
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2023-03-25 19:36:31 +0100
committerBruno Haible <bruno@clisp.org>2023-03-25 19:49:21 +0100
commiteb8da36e0b3a667444707fb7d0182e54bb2130d0 (patch)
tree2456cce91815d62e13640cffa4e786fecdfb87d4 /lib/stdio.in.h
parentfdae921011d0233db99799edbf4a858596265392 (diff)
downloadgnulib-eb8da36e0b3a667444707fb7d0182e54bb2130d0.tar.gz
stdio: ISO C 23: Define _PRINTF_NAN_LEN_MAX.
* lib/stdio.in.h (_PRINTF_NAN_LEN_MAX): New macro. * m4/stdio_h.m4 (gl_STDIO_H): Invoke gl_MUSL_LIBC. * modules/stdio (Files): Add m4/musl.m4. * tests/test-stdio.c: Check that _PRINTF_NAN_LEN_MAX is defined. Include nan.h, macros.h. (main): Check the value of _PRINTF_NAN_LEN_MAX. * modules/stdio-tests (Files): Add tests/nan.h, tests/macros.h, m4/exponentd.m4. (configure.ac): Invoke gl_DOUBLE_EXPONENT_LOCATION.
Diffstat (limited to 'lib/stdio.in.h')
-rw-r--r--lib/stdio.in.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 098f841738..0ed3e7595c 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -204,6 +204,37 @@
# undef putc_unlocked
#endif
+
+/* Maximum number of characters produced by printing a NaN value. */
+#ifndef _PRINTF_NAN_LEN_MAX
+# if defined __FreeBSD__ || defined __DragonFly__ \
+ || defined __NetBSD__ \
+ || defined __OpenBSD__ \
+ || (defined __APPLE__ && defined __MACH__)
+/* On BSD systems, a NaN value prints as just "nan", without a sign. */
+# define _PRINTF_NAN_LEN_MAX 3
+# elif (__GLIBC__ >= 2) || MUSL_LIBC || defined __sun || defined __CYGWIN__
+/* glibc, musl libc, Solaris libc, and Cygwin produce "[-]nan". */
+# define _PRINTF_NAN_LEN_MAX 4
+# elif defined _AIX
+/* AIX produces "[-]NaNQ". */
+# define _PRINTF_NAN_LEN_MAX 5
+# elif defined _WIN32 && !defined __CYGWIN__
+/* On native Windows, the output can be:
+ - with MSVC ucrt: "[-]nan" or "[-]nan(ind)" or "[-]nan(snan)",
+ - with mingw: "[-]1.#IND" or "[-]1.#QNAN". */
+# define _PRINTF_NAN_LEN_MAX 10
+# elif defined __sgi
+/* On IRIX, the output typically is "[-]nan0xNNNNNNNN" with 8 hexadecimal
+ digits. */
+# define _PRINTF_NAN_LEN_MAX 14
+# else
+/* We don't know, but 32 should be a safe maximum. */
+# define _PRINTF_NAN_LEN_MAX 32
+# endif
+#endif
+
+
#if @GNULIB_DPRINTF@
# if @REPLACE_DPRINTF@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)