From f209f7b1e871c2aa4ae812122c2aec0ec0490538 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sat, 2 Jun 2007 00:05:35 +0000 Subject: [PATCH] For platforms that don't have them, provide for common models. Apparently, some platforms (*cough* MSVC *cough*) haven't figured out what year it is and are behind the curve. Provide for common memory models. We can add more if there are odd platforms which don't have "long long" for 64 bits, too. --- inttypes/i16l32/inttypes.h | 103 +++++++++++++++++++++++++++++++++++++ inttypes/i32l32/inttypes.h | 103 +++++++++++++++++++++++++++++++++++++ inttypes/i32l64/inttypes.h | 103 +++++++++++++++++++++++++++++++++++++ 3 files changed, 309 insertions(+) create mode 100644 inttypes/i16l32/inttypes.h create mode 100644 inttypes/i32l32/inttypes.h create mode 100644 inttypes/i32l64/inttypes.h diff --git a/inttypes/i16l32/inttypes.h b/inttypes/i16l32/inttypes.h new file mode 100644 index 00000000..6242e192 --- /dev/null +++ b/inttypes/i16l32/inttypes.h @@ -0,0 +1,103 @@ +/* + * i16l32/inttypes.h + * + * Small subset of + * for the int 16, long 32, long long 64 model. + */ + +#ifndef INTTYPES_H +#define INTTYPES_H + +typedef signed char int8_t; +typedef signed int int16_t; +typedef signed long int32_t; +typedef signed long long int64_t; + +typedef unsigned char uint8_t; +typedef unsigned int uint16_t; +typedef unsigned long uint32_t; +typedef unsigned long long uint64_t; + +#define _scn8 "hh" +#define _scn16 "" +#define _scn32 "l" +#define _scn64 "ll" + +#define _pri8 "" +#define _pri16 "" +#define _pri32 "l" +#define _pri64 "ll" + +#define _c8 "" +#define _c16 "" +#define _c32 "L" +#define _c64 "LL" + +/* The rest of this is common to all models */ + +#define INT8_C(x) x ## _c8 +#define INT16_C(x) x ## _c16 +#define INT32_C(x) x ## _c32 +#define INT64_C(x) x ## _c64 + +#define UINT8_C(x) x ## U ## _c8 +#define UINT16_C(x) x ## U ## _c16 +#define UINT32_C(x) x ## U ## _c32 +#define UINT64_C(x) x ## U ## _c64 + +#define PRId8 _pri8 "d" +#define PRId16 _pri16 "d" +#define PRId32 _pri32 "d" +#define PRId64 _pri64 "d" + +#define PRIi8 _pri8 "i" +#define PRIi16 _pri16 "i" +#define PRIi32 _pri32 "i" +#define PRIi64 _pri64 "i" + +#define PRIo8 _pri8 "o" +#define PRIo16 _pri16 "o" +#define PRIo32 _pri32 "o" +#define PRIo64 _pri64 "o" + +#define PRIu8 _pri8 "u" +#define PRIu16 _pri16 "u" +#define PRIu32 _pri32 "u" +#define PRIu64 _pri64 "u" + +#define PRIx8 _pri8 "x" +#define PRIx16 _pri16 "x" +#define PRIx32 _pri32 "x" +#define PRIx64 _pri64 "x" + +#define PRIX8 _pri8 "X" +#define PRIX16 _pri16 "X" +#define PRIX32 _pri32 "X" +#define PRIX64 _pri64 "X" + +#define SCNd8 _scn8 "d" +#define SCNd16 _scn16 "d" +#define SCNd32 _scn32 "d" +#define SCNd64 _scn64 "d" + +#define SCNi8 _scn8 "i" +#define SCNi16 _scn16 "i" +#define SCNi32 _scn32 "i" +#define SCNi64 _scn64 "i" + +#define SCNo8 _scn8 "o" +#define SCNo16 _scn16 "o" +#define SCNo32 _scn32 "o" +#define SCNo64 _scn64 "o" + +#define SCNu8 _scn8 "u" +#define SCNu16 _scn16 "u" +#define SCNu32 _scn32 "u" +#define SCNu64 _scn64 "u" + +#define SCNx8 _scn8 "x" +#define SCNx16 _scn16 "x" +#define SCNx32 _scn32 "x" +#define SCNx64 _scn64 "x" + +#endif /* INTTYPES_H */ diff --git a/inttypes/i32l32/inttypes.h b/inttypes/i32l32/inttypes.h new file mode 100644 index 00000000..2e5760e8 --- /dev/null +++ b/inttypes/i32l32/inttypes.h @@ -0,0 +1,103 @@ +/* + * i32l32/inttypes.h + * + * Small subset of + * for the short 16, int 32, long long 64 model. + */ + +#ifndef INTTYPES_H +#define INTTYPES_H + +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +typedef signed long long int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long long uint64_t; + +#define _scn8 "hh" +#define _scn16 "h" +#define _scn32 "" +#define _scn64 "ll" + +#define _pri8 "" +#define _pri16 "" +#define _pri32 "" +#define _pri64 "ll" + +#define _c8 "" +#define _c16 "" +#define _c32 "" +#define _c64 "LL" + +/* The rest of this is common to all models */ + +#define INT8_C(x) x ## _c8 +#define INT16_C(x) x ## _c16 +#define INT32_C(x) x ## _c32 +#define INT64_C(x) x ## _c64 + +#define UINT8_C(x) x ## U ## _c8 +#define UINT16_C(x) x ## U ## _c16 +#define UINT32_C(x) x ## U ## _c32 +#define UINT64_C(x) x ## U ## _c64 + +#define PRId8 _pri8 "d" +#define PRId16 _pri16 "d" +#define PRId32 _pri32 "d" +#define PRId64 _pri64 "d" + +#define PRIi8 _pri8 "i" +#define PRIi16 _pri16 "i" +#define PRIi32 _pri32 "i" +#define PRIi64 _pri64 "i" + +#define PRIo8 _pri8 "o" +#define PRIo16 _pri16 "o" +#define PRIo32 _pri32 "o" +#define PRIo64 _pri64 "o" + +#define PRIu8 _pri8 "u" +#define PRIu16 _pri16 "u" +#define PRIu32 _pri32 "u" +#define PRIu64 _pri64 "u" + +#define PRIx8 _pri8 "x" +#define PRIx16 _pri16 "x" +#define PRIx32 _pri32 "x" +#define PRIx64 _pri64 "x" + +#define PRIX8 _pri8 "X" +#define PRIX16 _pri16 "X" +#define PRIX32 _pri32 "X" +#define PRIX64 _pri64 "X" + +#define SCNd8 _scn8 "d" +#define SCNd16 _scn16 "d" +#define SCNd32 _scn32 "d" +#define SCNd64 _scn64 "d" + +#define SCNi8 _scn8 "i" +#define SCNi16 _scn16 "i" +#define SCNi32 _scn32 "i" +#define SCNi64 _scn64 "i" + +#define SCNo8 _scn8 "o" +#define SCNo16 _scn16 "o" +#define SCNo32 _scn32 "o" +#define SCNo64 _scn64 "o" + +#define SCNu8 _scn8 "u" +#define SCNu16 _scn16 "u" +#define SCNu32 _scn32 "u" +#define SCNu64 _scn64 "u" + +#define SCNx8 _scn8 "x" +#define SCNx16 _scn16 "x" +#define SCNx32 _scn32 "x" +#define SCNx64 _scn64 "x" + +#endif /* INTTYPES_H */ diff --git a/inttypes/i32l64/inttypes.h b/inttypes/i32l64/inttypes.h new file mode 100644 index 00000000..1a4cbb79 --- /dev/null +++ b/inttypes/i32l64/inttypes.h @@ -0,0 +1,103 @@ +/* + * i32l64/inttypes.h + * + * Small subset of + * for the short 16, int 32, long 64 model. + */ + +#ifndef INTTYPES_H +#define INTTYPES_H + +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +typedef signed long int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef unsigned long uint64_t; + +#define _scn8 "hh" +#define _scn16 "h" +#define _scn32 "" +#define _scn64 "l" + +#define _pri8 "" +#define _pri16 "" +#define _pri32 "" +#define _pri64 "l" + +#define _c8 "" +#define _c16 "" +#define _c32 "" +#define _c64 "L" + +/* The rest of this is common to all models */ + +#define INT8_C(x) x ## _c8 +#define INT16_C(x) x ## _c16 +#define INT32_C(x) x ## _c32 +#define INT64_C(x) x ## _c64 + +#define UINT8_C(x) x ## U ## _c8 +#define UINT16_C(x) x ## U ## _c16 +#define UINT32_C(x) x ## U ## _c32 +#define UINT64_C(x) x ## U ## _c64 + +#define PRId8 _pri8 "d" +#define PRId16 _pri16 "d" +#define PRId32 _pri32 "d" +#define PRId64 _pri64 "d" + +#define PRIi8 _pri8 "i" +#define PRIi16 _pri16 "i" +#define PRIi32 _pri32 "i" +#define PRIi64 _pri64 "i" + +#define PRIo8 _pri8 "o" +#define PRIo16 _pri16 "o" +#define PRIo32 _pri32 "o" +#define PRIo64 _pri64 "o" + +#define PRIu8 _pri8 "u" +#define PRIu16 _pri16 "u" +#define PRIu32 _pri32 "u" +#define PRIu64 _pri64 "u" + +#define PRIx8 _pri8 "x" +#define PRIx16 _pri16 "x" +#define PRIx32 _pri32 "x" +#define PRIx64 _pri64 "x" + +#define PRIX8 _pri8 "X" +#define PRIX16 _pri16 "X" +#define PRIX32 _pri32 "X" +#define PRIX64 _pri64 "X" + +#define SCNd8 _scn8 "d" +#define SCNd16 _scn16 "d" +#define SCNd32 _scn32 "d" +#define SCNd64 _scn64 "d" + +#define SCNi8 _scn8 "i" +#define SCNi16 _scn16 "i" +#define SCNi32 _scn32 "i" +#define SCNi64 _scn64 "i" + +#define SCNo8 _scn8 "o" +#define SCNo16 _scn16 "o" +#define SCNo32 _scn32 "o" +#define SCNo64 _scn64 "o" + +#define SCNu8 _scn8 "u" +#define SCNu16 _scn16 "u" +#define SCNu32 _scn32 "u" +#define SCNu64 _scn64 "u" + +#define SCNx8 _scn8 "x" +#define SCNx16 _scn16 "x" +#define SCNx32 _scn32 "x" +#define SCNx64 _scn64 "x" + +#endif /* INTTYPES_H */