This is the mail archive of the newlib@sources.redhat.com 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: stdint.h


Shaun Jackman wrote:
Well, now that the stdbool.h thread has died, I'd like to look at the
original reason for that thread in the first place. gcc does not provide
stdint.h (since it's target dependent), which would suggest it's a good
candidate for newlib to provide. The not-so-pretty list of symbols that
stdint.h is supposed to provide follows. libc provides an implementation
of stdint.h. Perhaps we could use that as a starting point.


Disregarding the whole issue of whether gcc should provide this header file:


If you are referring to copying glibc as a starting-point, you cannot do that.  That code is
LGPL'd and newlib does not place LGPL'd code in directories that are shared among platforms.

Although tedious, it should be reasonably straighforward to add one to
newlib.

My thoughts are that stdint.h would start by including <sys/types.h>.
This provides the base __intx_t and __unintx_t definitions.  We would need to add
default __ least/fast types to <sys/types.h> which could default to be the intx/uintx types.
Any platform that wanted to change these definitions could do so by overriding
the definitions in <machine/types.h>.  Obviously, we would need to protect
the type definitions with flags and ensure that things were
defined after <machine/types.h> was included by <sys/types.h>.

For the MAX/MIN values, we can code the constant values as __ values with
checks to ensure they are not already defined.  stdint.h would then map the
external names to their __ counterparts.  Any platform can again override using <machine/types.h>.

-- Jeff J.

Cheers,
Shaun


[Excerpt from C99, Annex B.17] B.17 Integer types <stdint.h>

               int8_t           INT32_MIN        UINT_FAST8_MAX
               int16_t          INT64_MIN        UINT_FAST16_MAX
               int32_t          INT8_MAX         UINT_FAST32_MAX
               int64_t          INT16_MAX        UINT_FAST64_MAX
               uint8_t          INT32_MAX        INTPTR_MIN
               uint16_t         INT64_MAX        INTPTR_MAX
               uint32_t         UINT8_MAX        UINTPTR_MAX
               uint64_t         UINT16_MAX       INTMAX_MIN
               int_least8_t     UINT32_MAX       INTMAX_MAX
               int_least16_t    UINT64_MAX       UINTMAX_MAX
               int_least32_t    INT_LEAST8_MIN   PTRDIFF_MIN
               int_least64_t    INT_LEAST16_MIN  PTRDIFF_MAX
               uint_least8_t    INT_LEAST32_MIN  SIG_ATOMIC_MIN
               uint_least16_t   INT_LEAST64_MIN  SIG_ATOMIC_MAX
               uint_least32_t   INT_LEAST8_MAX   SIZE_MAX
               uint_least64_t   INT_LEAST16_MAX  WCHAR_MIN
               int_fast8_t      INT_LEAST32_MAX  WCHAR_MAX
               int_fast16_t     INT_LEAST64_MAX  WINT_MIN
               int_fast32_t     UINT_LEAST8_MAX  WINT_MAX
               int_fast64_t     UINT_LEAST16_MAX INT8_C(value)
               uint_fast8_t     UINT_LEAST32_MAX INT16_C(value)
               uint_fast16_t    UINT_LEAST64_MAX INT32_C(value)
               uint_fast32_t    INT_FAST8_MIN    INT64_C(value)
               uint_fast64_t    INT_FAST16_MIN   UINT8_C(value)
               intptr_t         INT_FAST32_MIN   UINT16_C(value)
               uintptr_t        INT_FAST64_MIN   UINT32_C(value)
               intmax_t         INT_FAST8_MAX    UINT64_C(value)
               uintmax_t        INT_FAST16_MAX   INTMAX_C(value)
               INT8_MIN         INT_FAST32_MAX   UINTMAX_C(value)
               INT16_MIN        INT_FAST64_MAX





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