From d375a26a6c594e89ce8c2fe7c7b3688909acbf77 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 3 Jun 2019 08:45:57 -0600 Subject: [PATCH] libs/libc/stdio: Fix long long usage in all of the newer printf-related logic: The selection CONFIG_LIBC_LONG_LONG must be ignored if the architecture does not support long long types. --- libs/libc/stdio/Kconfig | 3 +++ libs/libc/stdio/lib_libvscanf.c | 13 +++++++++++-- libs/libc/stdio/lib_ultoa_invert.h | 8 ++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/libs/libc/stdio/Kconfig b/libs/libc/stdio/Kconfig index bcec3917cb..3e787562d8 100644 --- a/libs/libc/stdio/Kconfig +++ b/libs/libc/stdio/Kconfig @@ -80,6 +80,9 @@ config LIBC_LONG_LONG libraries that will be drawn into the build if long long support is enabled. + NOTE: This setting has no effect if the underlying architecture + cannot support long long types + config LIBC_NUMBERED_ARGS bool "Enable numbered arguments in printf" default n diff --git a/libs/libc/stdio/lib_libvscanf.c b/libs/libc/stdio/lib_libvscanf.c index e9ca092b34..df805bcd18 100644 --- a/libs/libc/stdio/lib_libvscanf.c +++ b/libs/libc/stdio/lib_libvscanf.c @@ -1,8 +1,8 @@ /**************************************************************************** * libs/libc/stdio/lib_libsscanf.c * - * Copyright (C) 2007, 2008, 2011-2014, 2016, 2019 Gregory Nutt. All rights - * reserved. + * Copyright (C) 2007, 2008, 2011-2014, 2016, 2019 Gregory Nutt. All + * rights reserved. * Author: Gregory Nutt * Johannes Schock * @@ -52,6 +52,7 @@ #include #include +#include #include #include "libc.h" @@ -60,6 +61,14 @@ * Pre-processor Definitions ****************************************************************************/ +/* CONFIG_LIBC_LONG_LONG is not a valid selection of the compiler does not + * support long long types. + */ + +#ifndef CONFIG_HAVE_LONG_LONG +# undef CONFIG_LIBC_LONG_LONG +#endif + #define MAXLN 128 #define HH_MOD -2 diff --git a/libs/libc/stdio/lib_ultoa_invert.h b/libs/libc/stdio/lib_ultoa_invert.h index c7e89bdb8a..7f7d3fb86a 100644 --- a/libs/libc/stdio/lib_ultoa_invert.h +++ b/libs/libc/stdio/lib_ultoa_invert.h @@ -48,6 +48,14 @@ * Pre-processor Definitions ****************************************************************************/ +/* CONFIG_LIBC_LONG_LONG is not a valid selection of the compiler does not + * support long long types. + */ + +#ifndef CONFIG_HAVE_LONG_LONG +# undef CONFIG_LIBC_LONG_LONG +#endif + /* Next flags are to use with `base'. Unused fields are reserved. */ #define XTOA_PREFIX 0x0100 /* Put prefix for octal or hex */