libc: introduce NOPRINTF_LONGLONG_TO_ASCII
authorEunBong Song <eunb.song@samsung.com>
Fri, 14 Jul 2017 13:03:04 +0000 (06:03 -0700)
committerEunBong Song <eunb.song@samsung.com>
Wed, 30 Aug 2017 04:15:45 +0000 (21:15 -0700)
This patch introduces NOPRINTF_LONGLONG_TO_ASCII config.
If you don't need to support long long type in printf, enable
this feature.

Change-Id: If01bf473292eec5525645cfff2c79d1c48297e1f
Signed-off-by: EunBong Song <eunb.song@samsung.com>
lib/libc/Kconfig
lib/libc/stdio/lib_libvsprintf.c

index e67c8b4..cfb394f 100644 (file)
@@ -50,6 +50,13 @@ config LIBC_FLOATINGPOINT
                By default, floating point
                support in printf, sscanf, etc. is disabled.
 
+config NOPRINTF_LONGLONG_TO_ASCII
+       bool "Disable long long type in printf"
+       default n
+       ---help---
+               sprintf-related logic is a little smaller if we do not support long long type
+               conversion
+
 config LIBC_IOCTL_VARIADIC
        bool "Enable variadic ioctl()"
        default n
index d968a85..6fa7a1e 100644 (file)
@@ -194,7 +194,7 @@ static int getlusize(uint8_t fmt, FAR uint8_t flags, unsigned long ln);
 
 /* Unsigned long long int to ASCII conversions */
 
-#ifdef CONFIG_HAVE_LONG_LONG
+#ifndef CONFIG_NOPRINTF_LONGLONG_TO_ASCII
 static void llutodec(FAR struct lib_outstream_s *obj, unsigned long long lln);
 static void llutohex(FAR struct lib_outstream_s *obj, unsigned long long lln, uint8_t a);
 static void llutooct(FAR struct lib_outstream_s *obj, unsigned long long lln);
@@ -766,7 +766,7 @@ static int getlusize(uint8_t fmt, uint8_t flags, unsigned long ln)
 #endif                                                 /* CONFIG_NOPRINTF_FIELDWIDTH */
 #endif                                                 /* CONFIG_LONG_IS_NOT_INT */
 
-#ifdef CONFIG_HAVE_LONG_LONG
+#ifndef CONFIG_NOPRINTF_LONGLONG_TO_ASCII
 /****************************************************************************
  * Name: llutodec
  ****************************************************************************/
@@ -993,7 +993,7 @@ static int getllusize(uint8_t fmt, uint8_t flags, unsigned long long lln)
 }
 
 #endif                                                 /* CONFIG_NOPRINTF_FIELDWIDTH */
-#endif                                                 /* CONFIG_HAVE_LONG_LONG */
+#endif                                                 /* CONFIG_NOPRINTF_LONGLONG_TO_ASCII */
 
 /****************************************************************************
  * Name: prejustify
@@ -1312,7 +1312,7 @@ int lib_vsprintf(FAR struct lib_outstream_s *obj, FAR const char *src, va_list a
                /* Handle integer conversions */
 
                if (strchr("diuxXpob", FMT_CHAR)) {
-#ifdef CONFIG_HAVE_LONG_LONG
+#ifndef CONFIG_NOPRINTF_LONGLONG_TO_ASCII
                        if (IS_LONGLONGPRECISION(flags) && FMT_CHAR != 'p') {
                                long long lln;
 #ifndef CONFIG_NOPRINTF_FIELDWIDTH
@@ -1348,7 +1348,7 @@ int lib_vsprintf(FAR struct lib_outstream_s *obj, FAR const char *src, va_list a
                                postjustify(obj, fmt, flags, width, lluwidth);
 #endif
                        } else
-#endif                                                 /* CONFIG_HAVE_LONG_LONG */
+#endif                                                 /* CONFIG_NOPRINTF_LONGLONG_TO_ASCII */
 #ifdef CONFIG_LONG_IS_NOT_INT
                        if (IS_LONGPRECISION(flags) && FMT_CHAR != 'p') {
                                long ln;