Ticket #2038: newlib-rtems4.11-stdint.patch

File newlib-rtems4.11-stdint.patch, 3.2 KB (added by Ralf Corsepius, on 03/14/12 at 05:35:28)

Honor [U]INTPTR_TYPE for [u]intptr_t.

  • newlib/ChangeLog.rtems

    diff --git a/newlib/ChangeLog.rtems b/newlib/ChangeLog.rtems
    index 147e643..9907f79 100644
    a b  
     12012-03-14      Ralf Corsépius  <ralf.corsepius@rtems.org>
     2
     3        * libc/include/stdint.h: Honor __[U]INTPTR_TYPE__ for [u]intptr_t.
     4
    152011-12-16      Ralf Corsépius  <ralf.corsepius@rtems.org>
    26
    37        * libc/include/sys/time.h: Add adjtime.
  • newlib/libc/include/stdint.h

    diff --git a/newlib/libc/include/stdint.h b/newlib/libc/include/stdint.h
    index bf322cf..005c1d6 100644
    a b typedef uint64_t uint_least32_t; 
    235235  typedef unsigned long uintmax_t;
    236236#endif
    237237
    238 /*
    239  * GCC doesn't provide an appropriate macro for [u]intptr_t
    240  * For now, use __PTRDIFF_TYPE__
    241  */
     238/* intptr_t */
     239#if !defined(__INTPTR_TYPE__)
     240 #if defined(__SIZEOF_POINTER__)
     241  #if __SIZEOF_POINTER__ == 8
     242   typedef int64_t __INTPTR_TYPE__;
     243  #elif __SIZEOF_POINTER__ == 4
     244   typedef int32_t __INTPTR_TYPE__;
     245  #elif __SIZEOF_POINTER__ == 2
     246   typedef int16_t __INTPTR_TYPE__;
     247  #else
     248   #error cannot determine intptr_t
     249  #endif
     250 #else
     251  #if defined(__PTRDIFF_TYPE__)
     252   typedef signed __PTRDIFF_TYPE__ __INTPTR_TYPE__;
     253  #else
     254/* Fallback to long */
     255   typedef signed long __INTPTR_TYPE__;
     256  #endif
     257 #endif
     258#endif
     259typedef __INTPTR_TYPE__ intptr_t;
     260
     261/* uintptr_t */
     262#if !defined(__UINTPTR_TYPE__)
     263 #if defined(__SIZEOF_POINTER__)
     264  #if __SIZEOF_POINTER__ == 8
     265   typedef uint64_t __UINTPTR_TYPE__;
     266  #elif __SIZEOF_POINTER__ == 4
     267   typedef uint32_t __UINTPTR_TYPE__;
     268  #elif __SIZEOF_POINTER__ == 2
     269   typedef uint16_t __UINTPTR_TYPE__;
     270  #else
     271  #error cannot determine uintptr_t
     272  #endif
     273 #else
     274  #if defined(__PTRDIFF_TYPE__)
     275   typedef unsigned __PTRDIFF_TYPE__ __UINTPTR_TYPE__;
     276  #else
     277/* Fallback to long */
     278   typedef unsigned long __UINTPTR_TYPE__;
     279  #endif
     280 #endif
     281#endif
     282typedef __UINTPTR_TYPE__ uintptr_t;
     283
     284/* Limits of pointer types */
    242285#if defined(__SIZEOF_POINTER__)
    243286#if __SIZEOF_POINTER__ == 8
    244   typedef int64_t intptr_t;
    245   typedef uint64_t uintptr_t;
    246287#define INTPTR_MAX INT64_MAX
    247288#define INTPTR_MIN INT64_MIN
    248289#define UINTPTR_MAX UINT64_MAX
    249290#elif __SIZEOF_POINTER__ == 4
    250   typedef int32_t intptr_t;
    251   typedef uint32_t uintptr_t;
    252291#define INTPTR_MAX INT32_MAX
    253292#define INTPTR_MIN INT32_MIN
    254293#define UINTPTR_MAX UINT32_MAX
    255294#elif __SIZEOF_POINTER__ == 2
    256   typedef int16_t intptr_t;
    257   typedef uint16_t uintptr_t;
    258295#define INTPTR_MAX INT16_MAX
    259296#define INTPTR_MIN INT16_MIN
    260297#define UINTPTR_MAX UINT16_MAX
    typedef uint64_t uint_least32_t; 
    263300#endif
    264301#else
    265302#if defined(__PTRDIFF_TYPE__)
    266 typedef signed __PTRDIFF_TYPE__ intptr_t;
    267 typedef unsigned __PTRDIFF_TYPE__ uintptr_t;
    268303#define INTPTR_MAX PTRDIFF_MAX
    269304#define INTPTR_MIN PTRDIFF_MIN
    270305#ifdef __UINTPTR_MAX__
    typedef unsigned __PTRDIFF_TYPE__ uintptr_t; 
    273308#define UINTPTR_MAX (2UL * PTRDIFF_MAX + 1)
    274309#endif
    275310#else
    276 /*
    277  * Fallback to hardcoded values,
    278  * should be valid on cpu's with 32bit int/32bit void*
    279  */
    280 typedef signed long intptr_t;
    281 typedef unsigned long uintptr_t;
     311/* Fallback to long */
    282312#define INTPTR_MAX __STDINT_EXP(LONG_MAX)
    283313#define INTPTR_MIN (-__STDINT_EXP(LONG_MAX) - 1)
    284314#define UINTPTR_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)