diff --git a/libs/libc/stdio/Kconfig b/libs/libc/stdio/Kconfig index 05d8523ba44..a63bf8e1651 100644 --- a/libs/libc/stdio/Kconfig +++ b/libs/libc/stdio/Kconfig @@ -118,7 +118,6 @@ config NANO_PRINTF bool "Use nano printf code" default y if DEFAULT_SMALL default n if !DEFAULT_SMALL - depends on !LIBC_LONG_LONG ---help--- Replace printf code with version from newlib-nano. Can be signifcantly smaller, especially if floating support is enabled. @@ -128,8 +127,10 @@ config NANO_PRINTLEVEL int "Nano printf support level" default 2 if !LIBC_FLOATINGPOINT default 3 if LIBC_FLOATINGPOINT - range 1 2 if !LIBC_FLOATINGPOINT - range 1 3 if LIBC_FLOATINGPOINT + range 1 2 if !LIBC_FLOATINGPOINT && !LIBC_LONG_LONG + range 1 3 if LIBC_FLOATINGPOINT && !LIBC_LONG_LONG + range 2 2 if !LIBC_FLOATINGPOINT && LIBC_LONG_LONG + range 2 3 if LIBC_FLOATINGPOINT && LIBC_LONG_LONG depends on NANO_PRINTF ---help--- Nano printf can be built into more than one support level. The diff --git a/libs/libc/stdio/nano_libvsprintf.c b/libs/libc/stdio/nano_libvsprintf.c index 98a9638f39e..7aeea5bb3b3 100644 --- a/libs/libc/stdio/nano_libvsprintf.c +++ b/libs/libc/stdio/nano_libvsprintf.c @@ -326,7 +326,11 @@ int lib_vsprintf(FAR struct lib_outstream_s *stream, int prec; union { +# ifdef CONFIG_LIBC_LONG_LONG + unsigned char __buf[22]; /* Size for -1 in octal, without '\0' */ +# else unsigned char __buf[11]; /* Size for -1 in octal, without '\0' */ +# endif # if PRINTF_LEVEL >= PRINTF_FLT struct dtoa_s __dtoa; # endif @@ -833,8 +837,16 @@ int lib_vsprintf(FAR struct lib_outstream_s *stream, if (c == 'd' || c == 'i') { long x; +#ifdef CONFIG_LIBC_LONG_LONG + long long x; - if (flags & FL_LONG) + if ((flags & FL_LONGLONG) != 0) + { + x = va_arg(ap, long long); + } + else +#endif + if ((flags & FL_LONG) != 0) { x = va_arg(ap, long); } @@ -865,10 +877,18 @@ int lib_vsprintf(FAR struct lib_outstream_s *stream, } else { - int base; unsigned long x; + int base; +#ifdef CONFIG_LIBC_LONG_LONG + unsigned long long x; - if (flags & FL_LONG) + if (flags & FL_LONGLONG) != 0) + { + x = va_arg(ap, unsigned long long); + } + else +#endif + if ((flags & FL_LONG) != 0) { x = va_arg(ap, unsigned long); } @@ -921,7 +941,7 @@ int lib_vsprintf(FAR struct lib_outstream_s *stream, } else { - c = __ultoa_invert(x, (char *)buf, base) - (char *)buf; + c = __ultoa_invert(x, (char *)buf, base) - (char *)buf; } flags &= ~FL_NEGATIVE; diff --git a/libs/libc/stdio/nano_ultoa_invert.c b/libs/libc/stdio/nano_ultoa_invert.c index 6bd28e9067f..f538a5416fe 100644 --- a/libs/libc/stdio/nano_ultoa_invert.c +++ b/libs/libc/stdio/nano_ultoa_invert.c @@ -43,7 +43,11 @@ * Public Functions ****************************************************************************/ +#ifdef CONFIG_LIBC_LONG_LONG +FAR char *__ultoa_invert(unsigned long long val, FAR char *str, int base) +#else FAR char *__ultoa_invert(unsigned long val, FAR char *str, int base) +#endif { int upper = 0; diff --git a/libs/libc/stdio/nano_ultoa_invert.h b/libs/libc/stdio/nano_ultoa_invert.h index 634d2eb88a6..969ebeafd3f 100644 --- a/libs/libc/stdio/nano_ultoa_invert.h +++ b/libs/libc/stdio/nano_ultoa_invert.h @@ -42,6 +42,8 @@ #include +#include + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -57,6 +59,10 @@ /* Internal function for use from `printf'. */ -FAR char *__ultoa_invert(unsigned long val, FAR char *s, int base); +#ifdef CONFIG_LIBC_LONG_LONG +FAR char *__ultoa_invert(unsigned long long val, FAR char *str, int base); +#else +FAR char *__ultoa_invert(unsigned long val, FAR char *str, int base); +#endif #endif /* __LIBS_LIBC_STDIO_NANO_ULTOA_INVERT_H */