From a0596b415fa834d5dbc7fe87a01d80fb2b897df9 Mon Sep 17 00:00:00 2001 From: Ralf Corsepius Date: Mon, 8 Nov 2004 16:11:58 +0000 Subject: 2004-11-08 Ralf Corsepius * libcsupport/include/sys/_stdint.h: Remove. * libcsupport/include/sys/_inttypes.h: Remove. * libcsupport/include/stdint.h: Replace with former sys/_stdint.h. Add INT_C, various additions. * libcsupport/include/inttypes.h: Replace with former sys/_inttypes.h. * libcsupport/Makefile.am: Reflect changes above. --- cpukit/libcsupport/include/inttypes.h | 286 +++++++++++++++++++++++++++++++++- cpukit/libcsupport/include/stdint.h | 275 +++++++++++++++++++++++++++++++- 2 files changed, 549 insertions(+), 12 deletions(-) (limited to 'cpukit/libcsupport') diff --git a/cpukit/libcsupport/include/inttypes.h b/cpukit/libcsupport/include/inttypes.h index 73f9716718..c1c69220ea 100644 --- a/cpukit/libcsupport/include/inttypes.h +++ b/cpukit/libcsupport/include/inttypes.h @@ -1,15 +1,291 @@ -/** - * @file inttypes.h - */ - /* + * COPYRIGHT (c) 2004. + * Ralf Corsepius, Ulm/Germany. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * * $Id$ */ +/** + * @file sys/_inttypes.h + */ + #ifndef __INTTYPES_H #define __INTTYPES_H #include -#include + +#define __STRINGIFY(a) #a + +/* 8-bit types */ +#define __PRI8(x) __STRINGIFY(x) +#define __SCN8(x) __STRINGIFY(hh##x) + + +#define PRId8 __PRI8(d) +#define PRIi8 __PRI8(i) +#define PRIo8 __PRI8(o) +#define PRIu8 __PRI8(u) +#define PRIx8 __PRI8(x) +#define PRIX8 __PRI8(X) + +#define SCNd8 __SCN8(d) +#define SCNi8 __SCN8(i) +#define SCNo8 __SCN8(o) +#define SCNu8 __SCN8(u) +#define SCNx8 __SCN8(x) + + +#define PRIdLEAST8 __PRI8(d) +#define PRIiLEAST8 __PRI8(i) +#define PRIoLEAST8 __PRI8(o) +#define PRIuLEAST8 __PRI8(u) +#define PRIxLEAST8 __PRI8(x) +#define PRIXLEAST8 __PRI8(X) + +#define SCNdLEAST8 __SCN8(d) +#define SCNiLEAST8 __SCN8(i) +#define SCNoLEAST8 __SCN8(o) +#define SCNuLEAST8 __SCN8(u) +#define SCNxLEAST8 __SCN8(x) + + +#define PRIdFAST8 __PRI8(d) +#define PRIiFAST8 __PRI8(i) +#define PRIoFAST8 __PRI8(o) +#define PRIuFAST8 __PRI8(u) +#define PRIxFAST8 __PRI8(x) +#define PRIXFAST8 __PRI8(X) + +#define SCNdFAST8 __SCN8(d) +#define SCNiFAST8 __SCN8(i) +#define SCNoFAST8 __SCN8(o) +#define SCNuFAST8 __SCN8(u) +#define SCNxFAST8 __SCN8(x) + +/* 16-bit types */ +#define __PRI16(x) __STRINGIFY(x) +#define __SCN16(x) __STRINGIFY(h##x) + + +#define PRId16 __PRI16(d) +#define PRIi16 __PRI16(i) +#define PRIo16 __PRI16(o) +#define PRIu16 __PRI16(u) +#define PRIx16 __PRI16(x) +#define PRIX16 __PRI16(X) + +#define SCNd16 __SCN16(d) +#define SCNi16 __SCN16(i) +#define SCNo16 __SCN16(o) +#define SCNu16 __SCN16(u) +#define SCNx16 __SCN16(x) + + +#define PRIdLEAST16 __PRI16(d) +#define PRIiLEAST16 __PRI16(i) +#define PRIoLEAST16 __PRI16(o) +#define PRIuLEAST16 __PRI16(u) +#define PRIxLEAST16 __PRI16(x) +#define PRIXLEAST16 __PRI16(X) + +#define SCNdLEAST16 __SCN16(d) +#define SCNiLEAST16 __SCN16(i) +#define SCNoLEAST16 __SCN16(o) +#define SCNuLEAST16 __SCN16(u) +#define SCNxLEAST16 __SCN16(x) + + +#define PRIdFAST16 __PRI16(d) +#define PRIiFAST16 __PRI16(i) +#define PRIoFAST16 __PRI16(o) +#define PRIuFAST16 __PRI16(u) +#define PRIxFAST16 __PRI16(x) +#define PRIXFAST16 __PRI16(X) + +#define SCNdFAST16 __SCN16(d) +#define SCNiFAST16 __SCN16(i) +#define SCNoFAST16 __SCN16(o) +#define SCNuFAST16 __SCN16(u) +#define SCNxFAST16 __SCN16(x) + +/* 32-bit types */ +#if defined(__rtems_long32) +#define __PRI32(x) __STRINGIFY(l##x) +#define __SCN32(x) __STRINGIFY(l##x) +#else +#define __PRI32(x) __STRINGIFY(x) +#define __SCN32(x) __STRINGIFY(x) +#endif + +#define PRId32 __PRI32(d) +#define PRIi32 __PRI32(i) +#define PRIo32 __PRI32(o) +#define PRIu32 __PRI32(u) +#define PRIx32 __PRI32(x) +#define PRIX32 __PRI32(X) + +#define SCNd32 __SCN32(d) +#define SCNi32 __SCN32(i) +#define SCNo32 __SCN32(o) +#define SCNu32 __SCN32(u) +#define SCNx32 __SCN32(x) + + +#define PRIdLEAST32 __PRI32(d) +#define PRIiLEAST32 __PRI32(i) +#define PRIoLEAST32 __PRI32(o) +#define PRIuLEAST32 __PRI32(u) +#define PRIxLEAST32 __PRI32(x) +#define PRIXLEAST32 __PRI32(X) + +#define SCNdLEAST32 __SCN32(d) +#define SCNiLEAST32 __SCN32(i) +#define SCNoLEAST32 __SCN32(o) +#define SCNuLEAST32 __SCN32(u) +#define SCNxLEAST32 __SCN32(x) + + +#define PRIdFAST32 __PRI32(d) +#define PRIiFAST32 __PRI32(i) +#define PRIoFAST32 __PRI32(o) +#define PRIuFAST32 __PRI32(u) +#define PRIxFAST32 __PRI32(x) +#define PRIXFAST32 __PRI32(X) + +#define SCNdFAST32 __SCN32(d) +#define SCNiFAST32 __SCN32(i) +#define SCNoFAST32 __SCN32(o) +#define SCNuFAST32 __SCN32(u) +#define SCNxFAST32 __SCN32(x) + + +/* 64-bit types */ +#if defined(__rtems_longlong64) +#define __PRI64(x) __STRINGIFY(ll##x) +#define __SCN64(x) __STRINGIFY(ll##x) +#elif defined(__rtems_long64) +#define __PRI64(x) __STRINGIFY(l##x) +#define __SCN64(x) __STRINGIFY(l##x) +#else +#define __PRI64(x) __STRINGIFY(x) +#define __SCN64(x) __STRINGIFY(x) +#endif + +#define PRId64 __PRI64(d) +#define PRIi64 __PRI64(i) +#define PRIo64 __PRI64(o) +#define PRIu64 __PRI64(u) +#define PRIx64 __PRI64(x) +#define PRIX64 __PRI64(X) + +#define SCNd64 __SCN64(d) +#define SCNi64 __SCN64(i) +#define SCNo64 __SCN64(o) +#define SCNu64 __SCN64(u) +#define SCNx64 __SCN64(x) + +#if __int64_t_defined +#define PRIdLEAST64 __PRI64(d) +#define PRIiLEAST64 __PRI64(i) +#define PRIoLEAST64 __PRI64(o) +#define PRIuLEAST64 __PRI64(u) +#define PRIxLEAST64 __PRI64(x) +#define PRIXLEAST64 __PRI64(X) + +#define SCNdLEAST64 __SCN64(d) +#define SCNiLEAST64 __SCN64(i) +#define SCNoLEAST64 __SCN64(o) +#define SCNuLEAST64 __SCN64(u) +#define SCNxLEAST64 __SCN64(x) + + +#define PRIdFAST64 __PRI64(d) +#define PRIiFAST64 __PRI64(i) +#define PRIoFAST64 __PRI64(o) +#define PRIuFAST64 __PRI64(u) +#define PRIxFAST64 __PRI64(x) +#define PRIXFAST64 __PRI64(X) + +#define SCNdFAST64 __SCN64(d) +#define SCNiFAST64 __SCN64(i) +#define SCNoFAST64 __SCN64(o) +#define SCNuFAST64 __SCN64(u) +#define SCNxFAST64 __SCN64(x) +#endif + +/* max-bit types */ +#if defined(__rtems_longlong64) +#define __PRIMAX(x) __STRINGIFY(ll##x) +#define __SCNMAX(x) __STRINGIFY(ll##x) +#elif defined(__rtems_long64) +#define __PRIMAX(x) __STRINGIFY(l##x) +#define __SCNMAX(x) __STRINGIFY(l##x) +#else +#define __PRIMAX(x) __STRINGIFY(x) +#define __SCNMAX(x) __STRINGIFY(x) +#endif + +#define PRIdMAX __PRIMAX(d) +#define PRIiMAX __PRIMAX(i) +#define PRIoMAX __PRIMAX(o) +#define PRIuMAX __PRIMAX(u) +#define PRIxMAX __PRIMAX(x) +#define PRIXMAX __PRIMAX(X) + +#define SCNdMAX __SCNMAX(d) +#define SCNiMAX __SCNMAX(i) +#define SCNoMAX __SCNMAX(o) +#define SCNuMAX __SCNMAX(u) +#define SCNxMAX __SCNMAX(x) + +/* ptr types */ +#if defined(__rtems_longlong64) +#define __PRIPTR(x) __STRINGIFY(ll##x) +#define __SCNPTR(x) __STRINGIFY(ll##x) +#elif defined(__rtems_long64) +#define __PRIPTR(x) __STRINGIFY(l##x) +#define __SCNPTR(x) __STRINGIFY(l##x) +#else +#define __PRIPTR(x) __STRINGIFY(x) +#define __SCNPTR(x) __STRINGIFY(x) +#endif + +#define PRIdPTR __PRIPTR(d) +#define PRIiPTR __PRIPTR(i) +#define PRIoPTR __PRIPTR(o) +#define PRIuPTR __PRIPTR(u) +#define PRIxPTR __PRIPTR(x) +#define PRIXPTR __PRIPTR(X) + +#define SCNdPTR __SCNPTR(d) +#define SCNiPTR __SCNPTR(i) +#define SCNoPTR __SCNPTR(o) +#define SCNuPTR __SCNPTR(u) +#define SCNxPTR __SCNPTR(x) + + +typedef struct { + intmax_t quot; + intmax_t rem; +} imaxdiv_t; + +#ifdef __cplusplus +extern "C" { +#endif + +extern intmax_t imaxabs(intmax_t j); +extern imaxdiv_t imaxdiv(intmax_t numer, intmax_t denomer); +extern intmax_t strtoimax(const char *__restrict, char **__restrict, int); +extern uintmax_t strtoumax(const char *__restrict, char **__restrict, int); +extern intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int); +extern uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int); + +#ifdef __cplusplus +} +#endif #endif diff --git a/cpukit/libcsupport/include/stdint.h b/cpukit/libcsupport/include/stdint.h index 52455a79fe..dafc41756f 100644 --- a/cpukit/libcsupport/include/stdint.h +++ b/cpukit/libcsupport/include/stdint.h @@ -1,14 +1,275 @@ -/** - * @file stdint.h +/* + * COPYRIGHT (c) 2004. + * Ralf Corsepius, Ulm/Germany. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + * + * $Id$ */ -/* - * $Id$ +/** @file _stdint.h + * Newlib specific stdint.h + * + * @todo - Add fast_t types. + * @todo - Add support for wint_t types. */ -#ifndef __STDINT_H -#define __STDINT_H +#ifndef _STDINT_H +#define _STDINT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__GNUC__) && (__GNUC__ >= 3 ) \ + && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2 ) +#define __EXP(x) __##x##__ +#else +#define __EXP(x) x +#include +#endif + +#if __EXP(SCHAR_MAX) == 0x7f +typedef signed char int8_t ; +typedef unsigned char uint8_t ; +#define __int8_t_defined 1 +#endif + +#if __int8_t_defined +typedef signed char int_least8_t; +typedef unsigned char uint_least8_t; +#define __int_least8_t_defined 1 +#endif + +#if __EXP(SHRT_MAX) == 0x7fff +typedef signed short int16_t; +typedef unsigned short uint16_t; +#define __int16_t_defined 1 +#elif __EXP(INT_MAX) == 0x7fff +typedef signed int int16_t; +typedef unsigned int uint16_t; +#define __int16_t_defined 1 +#elif __EXP(SCHAR_MAX) == 0x7fff +typedef signed char int16_t; +typedef unsigned char uint16_t; +#define __int16_t_defined 1 +#endif + +#if __int16_t_defined +typedef int16_t int_least16_t; +typedef uint16_t uint_least16_t; +#define __int_least16_t_defined 1 + +#ifndef __int_least8_t_defined +typedef int16_t int_least8_t; +typedef uint16_t uint_least8_t; +#define __int_least8_t_defined 1 +#endif +#endif + +#if __EXP(INT_MAX) == 0x7fffffffL +typedef signed int int32_t; +typedef unsigned int uint32_t; +#define __int32_t_defined 1 +#elif __EXP(LONG_MAX) == 0x7fffffffL +typedef signed long int32_t; +typedef unsigned long uint32_t; +#define __int32_t_defined 1 +#define __rtems_long32 1 +#elif __EXP(SHRT_MAX) == 0x7fffffffL +typedef signed short int32_t; +typedef unsigned short uint32_t; +#define __int32_t_defined 1 +#elif __EXP(SCHAR_MAX) == 0x7fffffffL +typedef signed char int32_t; +typedef unsigned char uint32_t; +#define __int32_t_defined 1 +#endif + +#if __int32_t_defined +typedef int32_t int_least32_t; +typedef uint32_t uint_least32_t; +#define __int_least32_t_defined 1 + +#ifndef __int_least8_t_defined +typedef int32_t int_least8_t; +typedef uint32_t uint_least8_t; +#define __int_least8_t_defined 1 +#endif + +#ifndef __int_least16_t_defined +typedef int32_t int_least16_t; +typedef uint32_t uint_least16_t; +#define __int_least16_t_defined 1 +#endif +#endif + +#if __EXP(LONG_MAX) > 0x7fffffff +typedef signed long int64_t; +typedef unsigned long uint64_t; +#define __int64_t_defined 1 +#define __rtems_long64 1 +#elif defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#define __int64_t_defined 1 +#define __rtems_longlong64 1 +#elif defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#define __int64_t_defined 1 +#define __rtems_longlong64 1 +#elif __EXP(INT_MAX) > 0x7fffffff +typedef signed int int64_t; +typedef unsigned int uint64_t; +#define __int64_t_defined 1 +#endif + +#if __int64_t_defined +typedef int64_t int_least64_t; +typedef uint64_t uint_least64_t; +#define __int_least64_t_defined 1 + +#ifndef __int_least8_t_defined +typedef int64_t int_least8_t; +typedef uint64_t uint_least8_t; +#define __int_least8_t_defined 1 +#endif + +#ifndef __int_least16_t_defined +typedef int64_t int_least16_t; +typedef uint64_t uint_least16_t; +#define __int_least16_t_defined 1 +#endif + +#ifndef __int_least32_t_defined +typedef int64_t int_least32_t; +typedef uint64_t uint_least32_t; +#define __int_least32_t_defined 1 +#endif +#endif + +#if __rtems_longlong64 +typedef signed long long intmax_t; +typedef unsigned long long uintmax_t; +#else +typedef signed long intmax_t; +typedef unsigned long uintmax_t; +#endif + +typedef signed long intptr_t; +typedef unsigned long uintptr_t; + +/* Limits of Specified-Width Integer Types */ + +#if __int8_t_defined +#define INT8_MIN -128 +#define INT8_MAX 127 +#define UINT8_MAX 255 +#endif + +#if __int_least8_t_defined +#define INTLEAST8_MIN -128 +#define INTLEAST8_MAX 127 +#define UINTLEAST8_MAX 255 +#else +#error required type int_least8_t missing +#endif + +#if __int16_t_defined +#define INT16_MIN -32768 +#define INT16_MAX 32767 +#define UINT16_MAX 65535 +#endif -#include +#if __int_least16_t_defined +#define INTLEAST16_MIN -32768 +#define INTLEAST16_MAX 32767 +#define UINTLEAST16_MAX 65535 +#else +#error required type int_least16_t missing +#endif + +#if __int32_t_defined +#define INT32_MIN -2147483648 +#define INT32_MAX 2147483647 +#define UINT32_MAX 4294967295 +#endif + +#if __int_least32_t_defined +#define INTLEAST32_MIN -2147483648 +#define INTLEAST32_MAX 2147483647 +#define UINTLEAST32_MAX 4294967295 +#else +#error required type int_least32_t missing +#endif + +#if __int64_t_defined +#define INT64_MIN -9223372036854775808 +#define INT64_MAX 9223372036854775807 +#define UINT64_MAX 18446744073709551615 +#endif + +#if __int_least64_t_defined +#define INTLEAST64_MIN -9223372036854775808 +#define INTLEAST64_MAX 9223372036854775807 +#define UINTLEAST64_MAX 18446744073709551615 +#endif + +/* This must match size_t in stddef.h, currently long unsigned int */ +#define SIZE_MIN (-__EXP(LONG_MAX) - 1L) +#define SIZE_MAX __EXP(LONG_MAX) + +/* This must match sig_atomic_t in (currently int) */ +#define SIG_ATOMIC_MIN (-__EXP(INT_MAX) - 1) +#define SIG_ATOMIC_MAX __EXP(INT_MAX) + +/* This must match ptrdiff_t in (currently long int) */ +#define PTRDIFF_MIN (-__EXP(LONG_MAX) - 1L) +#define PTHDIFF_MAX __EXT(LONG_MAX) + +#undef __EXP + +/* Macros for minimum-width integer constant expressions */ + +#define INT8_C(x) x +#define UINT8_C(x) x##U + +#define INT16_C(x) x +#define UINT16_C(x) x##U + +#if __rtems_long32 +#define INT32_C(x) x##L +#define UINT32_C(x) x##UL +#else +#define INT32_C(x) x +#define UINT32_C(x) x##U +#endif + +/* Macros for greatest-width integer constant expression */ +#if __int64_t_defined +#if __rtems_longlong64 +#define INT64_C(x) x##LL +#define UINT64_C(x) x##ULL +#else +#define INT64_C(x) x##L +#define UINT64_C(x) x##UL +#endif +#endif + +#if __rtems_longlong64 +#define INTMAX_C(x) x##LL +#define UINTMAX_C(x) x##ULL +#else +#define INTMAX_C(x) x##L +#define UINTMAX_C(x) x##UL +#endif + + +#ifdef __cplusplus +} +#endif #endif -- cgit v1.2.3