From 75d2f919958212f98f4dcbff624e963a5d619f01 Mon Sep 17 00:00:00 2001 From: EunBong Song Date: Fri, 14 Jul 2017 06:03:04 -0700 Subject: [PATCH] libc: introduce NOPRINTF_LONGLONG_TO_ASCII 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 --- lib/libc/Kconfig | 7 +++++++ lib/libc/stdio/lib_libvsprintf.c | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/libc/Kconfig b/lib/libc/Kconfig index e67c8b4..cfb394f 100644 --- a/lib/libc/Kconfig +++ b/lib/libc/Kconfig @@ -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 diff --git a/lib/libc/stdio/lib_libvsprintf.c b/lib/libc/stdio/lib_libvsprintf.c index d968a85..6fa7a1e 100644 --- a/lib/libc/stdio/lib_libvsprintf.c +++ b/lib/libc/stdio/lib_libvsprintf.c @@ -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; -- 2.7.4