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] Introduce <sys/_intsup.h>


Patch applied.

-- Jeff J.

----- Original Message -----
> From: "Sebastian Huber" <sebastian.huber@embedded-brains.de>
> To: newlib@sourceware.org
> Cc: "Sebastian Huber" <sebastian.huber@embedded-brains.de>
> Sent: Thursday, October 9, 2014 10:08:31 AM
> Subject: [PATCH] Introduce <sys/_intsup.h>
> 
> Do not rely on Newlib <stdint.h> provided __have_longlong64,
> __have_long64 and __have_long32 in <inttypes.h> since in case GCC
> <stdint.h> is used these defines are not available.  Instead use new
> file <sys/_intsup.h>.  Use it also for <stdint.h>.
> 
> newlib/ChangeLog
> 2014-10-09  Sebastian Huber  <sebastian.huber@embedded-brains.de>
> 
> 	* libc/include/stdint.h: Include <sys/_intsup.h>.
> 	(__STDINT_EXP): Delete.
> 	(__have_long32): Likewise.
> 	(__have_long64): Likewise.
> 	(__have_longlong64): Likewise.
> 	* libc/include/sys/_intsup.h: New file.
> 	(__STDINT_EXP): Move from libc/include/stdint.h.
> 	(__have_long32): Likewise.
> 	(__have_long64): Likewise.
> 	(__have_longlong64): Likewise.
> 	* libc/include/inttypes.h: Include <sys/_intsup.h>.
> 	(__INTTYPES_EXP): Delete and use __STDINT_EXP() instead.
> ---
>  newlib/libc/include/inttypes.h    | 15 +++------------
>  newlib/libc/include/stdint.h      | 23 +----------------------
>  newlib/libc/include/sys/_intsup.h | 36 ++++++++++++++++++++++++++++++++++++
>  3 files changed, 40 insertions(+), 34 deletions(-)
>  create mode 100644 newlib/libc/include/sys/_intsup.h
> 
> diff --git a/newlib/libc/include/inttypes.h b/newlib/libc/include/inttypes.h
> index 1631e21..2470b09 100644
> --- a/newlib/libc/include/inttypes.h
> +++ b/newlib/libc/include/inttypes.h
> @@ -13,20 +13,11 @@
>  #ifndef _INTTYPES_H
>  #define _INTTYPES_H
>  
> -#include <sys/features.h>
> +#include <sys/_intsup.h>
>  #include <stdint.h>
>  #define __need_wchar_t
>  #include <stddef.h>
>  
> -/* Don't use __STDINT_EXP test since GCC's stdint.h provides different
> -   macros than newlib's stdint.h. */
> -#if __GNUC_PREREQ(3, 2)
> -  #define __INTTYPES_EXP(x) __##x##__
> -#else
> -  #define __INTTYPES_EXP(x) x
> -  #include <limits.h>
> -#endif
> -
>  #define __STRINGIFY(a) #a
>  
>  /* 8-bit types */
> @@ -252,10 +243,10 @@
>  #define SCNxMAX		__SCNMAX(x)
>  
>  /* ptr types */
> -#if PTRDIFF_MAX <= __INTTYPES_EXP(INT_MAX)
> +#if PTRDIFF_MAX <= __STDINT_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 <= __STDINT_EXP(LONG_MAX) || !defined(__have_longlong64)
>  # define __PRIPTR(x) __STRINGIFY(l##x)
>  # define __SCNPTR(x) __STRINGIFY(l##x)
>  #else
> diff --git a/newlib/libc/include/stdint.h b/newlib/libc/include/stdint.h
> index 77431c7..7386164 100644
> --- a/newlib/libc/include/stdint.h
> +++ b/newlib/libc/include/stdint.h
> @@ -10,33 +10,12 @@
>  #define _STDINT_H
>  
>  #include <machine/_default_types.h>
> +#include <sys/_intsup.h>
>  
>  #ifdef __cplusplus
>  extern "C" {
>  #endif
>  
> -#if __GNUC_PREREQ (3, 2)
> -/* gcc > 3.2 implicitly defines the values we are interested */
> -#define __STDINT_EXP(x) __##x##__
> -#else
> -#define __STDINT_EXP(x) x
> -#include <limits.h>
> -#endif
> -
> -/* Check if "long long" is 64bit wide */
> -/* Modern GCCs provide __LONG_LONG_MAX__, SUSv3 wants LLONG_MAX */
> -#if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \
> -  || ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) )
> -#define __have_longlong64 1
> -#endif
> -
> -/* Check if "long" is 64bit or 32bit wide */
> -#if __STDINT_EXP(LONG_MAX) > 0x7fffffff
> -#define __have_long64 1
> -#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__)
> -#define __have_long32 1
> -#endif
> -
>  #ifdef ___int8_t_defined
>  typedef __int8_t int8_t ;
>  typedef __uint8_t uint8_t ;
> diff --git a/newlib/libc/include/sys/_intsup.h
> b/newlib/libc/include/sys/_intsup.h
> new file mode 100644
> index 0000000..7c3bc01
> --- /dev/null
> +++ b/newlib/libc/include/sys/_intsup.h
> @@ -0,0 +1,36 @@
> +/*
> + * Copyright (c) 2004, 2005 by
> + * Ralf Corsepius, Ulm/Germany. All rights reserved.
> + *
> + * Permission to use, copy, modify, and distribute this software
> + * is freely granted, provided that this notice is preserved.
> + */
> +
> +#ifndef _SYS__INTSUP_H
> +#define _SYS__INTSUP_H
> +
> +#include <sys/features.h>
> +
> +#if __GNUC_PREREQ (3, 2)
> +/* gcc > 3.2 implicitly defines the values we are interested */
> +#define __STDINT_EXP(x) __##x##__
> +#else
> +#define __STDINT_EXP(x) x
> +#include <limits.h>
> +#endif
> +
> +/* Check if "long long" is 64bit wide */
> +/* Modern GCCs provide __LONG_LONG_MAX__, SUSv3 wants LLONG_MAX */
> +#if ( defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) ) \
> +  || ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) )
> +#define __have_longlong64 1
> +#endif
> +
> +/* Check if "long" is 64bit or 32bit wide */
> +#if __STDINT_EXP(LONG_MAX) > 0x7fffffff
> +#define __have_long64 1
> +#elif __STDINT_EXP(LONG_MAX) == 0x7fffffff && !defined(__SPU__)
> +#define __have_long32 1
> +#endif
> +
> +#endif /* _SYS__INTSUP_H */
> --
> 1.8.4.5
> 
> 


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