xiaoxiang781216 commented on code in PR #21493:
URL: https://github.com/apache/nuttx/pull/21493#discussion_r4490197709
##########
libs/libc/stream/lib_ultoa_invert.h:
##########
@@ -51,12 +54,30 @@
#define XTOA_PREFIX 0x0100 /* Put prefix for octal or hex */
#define XTOA_UPPER 0x0200 /* Use upper case letters */
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/* The integer that printf() can print */
+
+#if defined(CONFIG_LIBC_PRINTF_LONG_LONG) || ULLONG_MAX == ULONG_MAX
+typedef long long ultoa_int_t;
+typedef unsigned long long ultoa_uint_t;
+#else
+typedef long ultoa_int_t;
+typedef unsigned long ultoa_uint_t;
+
+/* The digit loop works on long, so it needs no 64-bit division method */
+
+# undef CONFIG_HAVE_EXPRESSION_STATEMENT
Review Comment:
where in printf code reference CONFIG_HAVE_EXPRESSION_STATEMENT
##########
libs/libc/stdio/Kconfig:
##########
@@ -52,9 +52,39 @@ config NUNGET_CHARS
Number of characters that can be buffered by ungetc() (Only if
FILE_STREAM equals y)
+choice
+ prompt "printf profile"
+ default LIBC_PRINTF_DEFAULT
+ ---help---
+ A profile only sets the defaults of the printf feature options.
+ Each option keeps its own prompt, so any feature can be added to
+ or removed from any profile.
+
+ printf() is safe with a correct call in every profile. A
feature
+ that is off still reads its argument at the right size, so the
+ arguments after it stay correct.
+
+config LIBC_PRINTF_MINIMAL
+ bool "Minimal"
+ ---help---
+ The smallest printf. It has less than the Default profile.
+
+config LIBC_PRINTF_DEFAULT
+ bool "Default"
+ ---help---
+ The features that printf has always had by default.
+
+config LIBC_PRINTF_FULL
+ bool "Full"
+ ---help---
+ All features.
+
+endchoice # printf profile
+
config LIBC_FLOATINGPOINT
bool "Enable floating point in printf"
- default !DEFAULT_SMALL && ARCH_FPU
+ default y if LIBC_PRINTF_FULL
+ default !DEFAULT_SMALL && ARCH_FPU && !LIBC_PRINTF_MINIMAL
Review Comment:
LIBC_PRINTF_FULL || (!DEFAULT_SMALL && ARCH_FPU && !LIBC_PRINTF_MINIMAL)
##########
libs/libc/locale/Kconfig:
##########
@@ -7,7 +7,7 @@ menu "Locale Support"
config LIBC_LOCALE
bool "Enable I18N (LOCALE) support"
- default n
+ default LIBC_PRINTF_FULL
Review Comment:
should we let LIBC_PRINTF_FULL to depend on LIBC_LOCALE
##########
libs/libc/stream/lib_ultoa_invert.h:
##########
@@ -51,12 +54,30 @@
#define XTOA_PREFIX 0x0100 /* Put prefix for octal or hex */
#define XTOA_UPPER 0x0200 /* Use upper case letters */
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/* The integer that printf() can print */
+
+#if defined(CONFIG_LIBC_PRINTF_LONG_LONG) || ULLONG_MAX == ULONG_MAX
+typedef long long ultoa_int_t;
+typedef unsigned long long ultoa_uint_t;
+#else
+typedef long ultoa_int_t;
+typedef unsigned long ultoa_uint_t;
+
+/* The digit loop works on long, so it needs no 64-bit division method */
+
+# undef CONFIG_HAVE_EXPRESSION_STATEMENT
Review Comment:
where the print code use this macro
##########
libs/libc/stream/lib_libvsprintf.c:
##########
@@ -124,6 +124,18 @@
#define FL_ALT_IS_HEX(f) (FL_ALT_FORM == 0 || !HAVE_OCTAL_OUTPUT || \
((f) & FL_ALTHEX) != 0)
+/* An integer conversion with a feature that is off prints a question mark.
+ * A flag that is 0 lets the compiler remove the code of its feature.
+ */
+
+#ifdef CONFIG_LIBC_PRINTF_INT_PRECISION
+# define FL_INT_PREC FL_PREC
+# define FL_INT_UNAVAIL 0
Review Comment:
FL_INT_PREC_UNAVAIL
##########
libs/libc/stream/lib_libvsprintf.c:
##########
@@ -130,12 +130,22 @@
#ifdef CONFIG_LIBC_PRINTF_INT_PRECISION
# define FL_INT_PREC FL_PREC
-# define FL_INT_UNAVAIL 0
+# define FL_NO_INT_PREC 0
#else
# define FL_INT_PREC 0
-# define FL_INT_UNAVAIL FL_PREC
+# define FL_NO_INT_PREC FL_PREC
Review Comment:
move to previous patch
##########
libs/libc/stdio/Kconfig:
##########
@@ -52,9 +52,39 @@ config NUNGET_CHARS
Number of characters that can be buffered by ungetc() (Only if
FILE_STREAM equals y)
+choice
+ prompt "printf profile"
+ default LIBC_PRINTF_DEFAULT
+ ---help---
+ A profile only sets the defaults of the printf feature options.
+ Each option keeps its own prompt, so any feature can be added to
+ or removed from any profile.
+
+ printf() is safe with a correct call in every profile. A
feature
+ that is off still reads its argument at the right size, so the
+ arguments after it stay correct.
+
+config LIBC_PRINTF_MINIMAL
+ bool "Minimal"
+ ---help---
+ The smallest printf. It has less than the Default profile.
+
+config LIBC_PRINTF_DEFAULT
+ bool "Default"
+ ---help---
+ The features that printf has always had by default.
+
+config LIBC_PRINTF_FULL
+ bool "Full"
+ ---help---
+ All features.
+
+endchoice # printf profile
+
config LIBC_FLOATINGPOINT
bool "Enable floating point in printf"
- default !DEFAULT_SMALL && ARCH_FPU
+ default y if LIBC_PRINTF_FULL
+ default !DEFAULT_SMALL && ARCH_FPU && !LIBC_PRINTF_MINIMAL
Review Comment:
`default LIBC_PRINTF_FULL || !DEFAULT_SMALL && ARCH_FPU &&
!LIBC_PRINTF_MINIMAL`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]