This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix inttypes.h


Polite Ping now that Jeff appears to be back. :)


On 9/22/2014 2:09 AM, Sebastian Huber wrote:
> Do not rely on Newlib <stdint.h> provided __have_longlong64,
> __have_long64 and __have_long32 since in case GCC <stdint.h> is used
> these defines are not available.
>
> newlib/ChangeLog
> 2014-09-22  Sebastian Huber  <sebastian.huber@embedded-brains.de>
>
> 	* libc/include/inttypes.h: Add and
> 	use __INTTYPES_HAVE_LONGLONG64, __INTTYPES_HAVE_LONG64 and
> 	__INTTYPES_HAVE_LONG32.
> ---
>  newlib/libc/include/inttypes.h | 26 ++++++++++++++++++++------
>  1 file changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/newlib/libc/include/inttypes.h b/newlib/libc/include/inttypes.h
> index 1631e21..bfa5c9d 100644
> --- a/newlib/libc/include/inttypes.h
> +++ b/newlib/libc/include/inttypes.h
> @@ -27,6 +27,19 @@
>    #include <limits.h>
>  #endif
>  
> +/* Check if "long long" is 64bit wide */
> +#if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \
> +  || ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) )
> +#define __INTTYPES_HAVE_LONGLONG64 1
> +#endif
> +
> +/* Check if "long" is 64bit or 32bit wide */
> +#if __INTTYPES_EXP(LONG_MAX) > 0x7fffffff
> +#define __INTTYPES_HAVE_LONG64 1
> +#elif __INTTYPES_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__)
> +#define __INTTYPES_HAVE_LONG32 1
> +#endif
> +
>  #define __STRINGIFY(a) #a
>  
>  /* 8-bit types */
> @@ -122,7 +135,7 @@
>  #define SCNxFAST16	__SCN16(x)
>  
>  /* 32-bit types */
> -#if __have_long32
> +#if __INTTYPES_HAVE_LONG32
>  #define __PRI32(x) __STRINGIFY(l##x)
>  #define __SCN32(x) __STRINGIFY(l##x)
>  #else
> @@ -173,10 +186,10 @@
>  
>  
>  /* 64-bit types */
> -#if __have_long64
> +#if __INTTYPES_HAVE_LONG64
>  #define __PRI64(x) __STRINGIFY(l##x)
>  #define __SCN64(x) __STRINGIFY(l##x)
> -#elif __have_longlong64
> +#elif __INTTYPES_HAVE_LONGLONG64
>  #define __PRI64(x) __STRINGIFY(ll##x)
>  #define __SCN64(x) __STRINGIFY(ll##x)
>  #else
> @@ -227,10 +240,10 @@
>  #endif
>  
>  /* max-bit types */
> -#if __have_long64
> +#if __INTTYPES_HAVE_LONG64
>  #define __PRIMAX(x) __STRINGIFY(l##x)
>  #define __SCNMAX(x) __STRINGIFY(l##x)
> -#elif __have_longlong64
> +#elif __INTTYPES_HAVE_LONGLONG64
>  #define __PRIMAX(x) __STRINGIFY(ll##x)
>  #define __SCNMAX(x) __STRINGIFY(ll##x)
>  #else
> @@ -255,7 +268,8 @@
>  #if PTRDIFF_MAX <= __INTTYPES_EXP(INT_MAX)
>  # define __PRIPTR(x) __STRINGIFY(x)
>  # define __SCNPTR(x) __STRINGIFY(x)
> -#elif PTRDIFF_MAX <= __INTTYPES_EXP(LONG_MAX) || !defined(__have_longlong64)
> +#elif PTRDIFF_MAX <= __INTTYPES_EXP(LONG_MAX) \
> +  || !defined(__INTTYPES_HAVE_LONGLONG64)
>  # define __PRIPTR(x) __STRINGIFY(l##x)
>  # define __SCNPTR(x) __STRINGIFY(l##x)
>  #else

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill@OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]