From eef2f4599e5c7f2e6e157e6504e5475187046791 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 29 Jul 2019 14:34:29 -0600 Subject: [PATCH] Commit 933e9e407b55cec357d3e7daf558a105d2c7507d broke the simulator on a 64-bit platform. --- arch/sim/include/limits.h | 56 +++++++++++++++++-------------- libs/libc/stdio/lib_libvsprintf.c | 2 +- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/arch/sim/include/limits.h b/arch/sim/include/limits.h index 6a52c2c1b1..d0637e2f20 100644 --- a/arch/sim/include/limits.h +++ b/arch/sim/include/limits.h @@ -44,48 +44,54 @@ * Pre-processor Definitions ****************************************************************************/ -#define CHAR_BIT 8 -#define SCHAR_MIN (-SCHAR_MAX - 1) -#define SCHAR_MAX 127 -#define UCHAR_MAX 255 +#define CHAR_BIT 8 +#define SCHAR_MIN (-SCHAR_MAX - 1) +#define SCHAR_MAX 127 +#define UCHAR_MAX 255 /* These could be different on machines where char is unsigned */ #ifdef __CHAR_UNSIGNED__ -#define CHAR_MIN 0 -#define CHAR_MAX UCHAR_MAX +#define CHAR_MIN 0 +#define CHAR_MAX UCHAR_MAX #else -#define CHAR_MIN SCHAR_MIN -#define CHAR_MAX SCHAR_MAX +#define CHAR_MIN SCHAR_MIN +#define CHAR_MAX SCHAR_MAX #endif -#define SHRT_MIN (-SHRT_MAX - 1) -#define SHRT_MAX 32767 -#define USHRT_MAX 65535U +#define SHRT_MIN (-SHRT_MAX - 1) +#define SHRT_MAX 32767 +#define USHRT_MAX 65535U -#define INT_MIN (-INT_MAX - 1) -#define INT_MAX 2147483647 -#define UINT_MAX 4294967295U +#define INT_MIN (-INT_MAX - 1) +#define INT_MAX 2147483647 +#define UINT_MAX 4294967295U /* These change on 32-bit and 64-bit platforms */ -#define LONG_MIN (-LONG_MAX - 1) -#define LONG_MAX 2147483647L -#define ULONG_MAX 4294967295UL +#if !defined(CONFIG_HOST_X86_64) || defined(CONFIG_SIM_M32) +# define LONG_MIN (-LONG_MAX - 1) +# define LONG_MAX 2147483647L +# define ULONG_MAX 4294967295UL +#else +# define LONG_MIN (-LLONG_MAX - 1) +# define LONG_MAX 9223372036854775807LL +# define ULONG_MAX 18446744073709551615ULL +#endif -#define LLONG_MIN (-LLONG_MAX - 1) -#define LLONG_MAX 9223372036854775807LL -#define ULLONG_MAX 18446744073709551615ULL +#define LLONG_MIN (-LLONG_MAX - 1) +#define LLONG_MAX 9223372036854775807LL +#define ULLONG_MAX 18446744073709551615ULL /* A pointer is 4 or 8 bytes */ -#define PTR_MIN (-PTR_MAX - 1) +#define PTR_MIN (-PTR_MAX - 1) #if !defined(CONFIG_HOST_X86_64) || defined(CONFIG_SIM_M32) -# define PTR_MAX 2147483647 -# define UPTR_MAX 4294967295U +# define PTR_MAX 2147483647 +# define UPTR_MAX 4294967295U #else -# define PTR_MAX 9223372036854775807LL -# define UPTR_MAX 18446744073709551615ULL +# define PTR_MAX 9223372036854775807LL +# define UPTR_MAX 18446744073709551615ULL #endif #endif /* __ARCH_SIM_INCLUDE_LIMITS_H */ diff --git a/libs/libc/stdio/lib_libvsprintf.c b/libs/libc/stdio/lib_libvsprintf.c index 4cd52d9802..be54e2d479 100644 --- a/libs/libc/stdio/lib_libvsprintf.c +++ b/libs/libc/stdio/lib_libvsprintf.c @@ -395,7 +395,7 @@ static int vsprintf_internal(FAR struct lib_outstream_s *stream, c = 'l'; break; -#ifdef CONFIG_HAVE_LONG_LONG +#if defined(CONFIG_LIBC_LONG_LONG) && ULLONG_MAX != ULONG_MAX case sizeof(unsigned long long): c = 'l'; flags |= FL_LONG;