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] |
On 24/07/15 11:49, Corinna Vinschen wrote:
On Jul 24 11:21, Andre Vieira wrote:On 23/07/15 20:43, Corinna Vinschen wrote:Hi Andre, On Jul 23 11:28, Andre Vieira wrote:The PRI and SCN macro's were producing formats that did not match their target types set by GCC. This patch uses the types defined for __INTxx_TYPE__, __INT_FASTxx_TYPE__ and __INT_LEASTxx_TYPE__ to define their corresponding macros. newlib/ChangeLog: 2015-07-23 Andre Vieira <...> * libc/include/sys/_intsup.h: Defined new __INTxx, __FASTxx and _LEASTxx macro's to hold information regarding the respective types print and scan formats. * libc/include/inttypes.h: Defined LEAST and FAST specific PRI and SCN macro's as these are not always the same as the INT variants. Used the new __INTxx, __FASTxx and __LEASTxx macro's in their corresponding PRI and SCN macros.I gave your patch a quick glance and it looks basically ok to me. I'll review it more thorougly tomorrow (I hope), but I have a question: How did you test your patch? Thanks, CorinnaHi Corinna, That is a very good question. To be honest with you I ran gcc and newlib regression tests and did a manual test on one machine. As I was about to send you the manual patch I noticed I forgot to change the SCN16(x) define. So I'll respin this patch for you and I'll also give testing a bit more thinking. There is no straightforward way of testing this I think. Though I will try to create a sensible sscanf/sprintf test and get back to you. Suggestions are welcome.Some simple testcase which allows easy manual inspection of the results would do, I guess. You know, output in rows, kind of like typename basetype printf macro scanf macro int32_t int "d" "d" int16fast_t long "ld" "ld" If you have a chance to test on, say, 2 platforms, I'd add inspection on 32 and 64 bit Cygwin. That should allow to be reasonable sure that the patch doesn't break any platform. Thanks, Corinna
Sorry for the delay.As Kevin reported on Launchpad (https://answers.launchpad.net/gcc-arm-embedded/+question/269083), the PRI and SCN macro's were producing formats that did not match their target types set by GCC. This patch uses the types defined for __INTxx_TYPE__, __INT_FASTxx_TYPE__ and __INT_LEASTxx_TYPE__ to define their corresponding macros. Attached you can find the file used for manual testing and the results of running this test for compiled versions for arm-none-eabi(32 bit) and aarch64-none-elf(64 bit), named arm.run and aarch64.run respectively.
newlib/ChangeLog: 2015-07-23 Andre Vieira <andre.simoesdiasvieira@arm.com>* libc/include/sys/_intsup.h: Defined new __INTxx, __FASTxx and __LEASTxx
macro's to hold information regarding the respective types print and scan formats. * libc/include/inttypes.h: Defined LEAST and FAST specific PRI and SCNmacro's as these are not always the same as the INT variants. Used the new __INTxx, __FASTxx and __LEASTxx macro's in their corresponding PRI and SCN
macros.
From d529cfa9f693c64c2a0cc9c380e9546cf69d59b6 Mon Sep 17 00:00:00 2001 From: Andre Simoes Dias Vieira <andsim01@arm.com> Date: Thu, 13 Aug 2015 14:06:16 +0100 Subject: [PATCH] Fix for pri and scn formats --- newlib/libc/include/inttypes.h | 235 ++++++++++++++++++++------------------ newlib/libc/include/sys/_intsup.h | 155 ++++++++++++++++++++++--- 2 files changed, 263 insertions(+), 127 deletions(-) diff --git a/newlib/libc/include/inttypes.h b/newlib/libc/include/inttypes.h index 7158cc6674b20c78b35a3875bf04e0bfa6d46649..25c6e99faf010d8517736ebb03c3a13b57d82266 100644 --- a/newlib/libc/include/inttypes.h +++ b/newlib/libc/include/inttypes.h @@ -23,7 +23,9 @@ #define __STRINGIFY(a) #a /* 8-bit types */ -#define __PRI8(x) __STRINGIFY(x) +#define __PRI8(x) __INT8 __STRINGIFY(x) +#define __PRI8LEAST(x) __LEAST8 __STRINGIFY(x) +#define __PRI8FAST(x) __FAST8 __STRINGIFY(x) /* NOTICE: scanning 8-bit types requires use of the hh specifier * which is only supported on newlib platforms that @@ -36,7 +38,9 @@ */ #if defined(_WANT_IO_C99_FORMATS) - #define __SCN8(x) __STRINGIFY(hh##x) + #define __SCN8(x) __INT8 __STRINGIFY(x) + #define __SCN8LEAST(x) __LEAST8 __STRINGIFY(x) + #define __SCN8FAST(x) __FAST8 __STRINGIFY(x) #endif /* _WANT_IO_C99_FORMATS */ @@ -59,45 +63,49 @@ #endif /* _WANT_IO_C99_FORMATS */ -#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 PRIdLEAST8 __PRI8LEAST(d) +#define PRIiLEAST8 __PRI8LEAST(i) +#define PRIoLEAST8 __PRI8LEAST(o) +#define PRIuLEAST8 __PRI8LEAST(u) +#define PRIxLEAST8 __PRI8LEAST(x) +#define PRIXLEAST8 __PRI8LEAST(X) /* Macros below are only enabled for a newlib built with C99 I/O format support. */ #if defined(_WANT_IO_C99_FORMATS) - #define SCNdLEAST8 __SCN8(d) - #define SCNiLEAST8 __SCN8(i) - #define SCNoLEAST8 __SCN8(o) - #define SCNuLEAST8 __SCN8(u) - #define SCNxLEAST8 __SCN8(x) + #define SCNdLEAST8 __SCN8LEAST(d) + #define SCNiLEAST8 __SCN8LEAST(i) + #define SCNoLEAST8 __SCN8LEAST(o) + #define SCNuLEAST8 __SCN8LEAST(u) + #define SCNxLEAST8 __SCN8LEAST(x) #endif /* _WANT_IO_C99_FORMATS */ -#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 PRIdFAST8 __PRI8FAST(d) +#define PRIiFAST8 __PRI8FAST(i) +#define PRIoFAST8 __PRI8FAST(o) +#define PRIuFAST8 __PRI8FAST(u) +#define PRIxFAST8 __PRI8FAST(x) +#define PRIXFAST8 __PRI8FAST(X) /* Macros below are only enabled for a newlib built with C99 I/O format support. */ #if defined(_WANT_IO_C99_FORMATS) - #define SCNdFAST8 __SCN8(d) - #define SCNiFAST8 __SCN8(i) - #define SCNoFAST8 __SCN8(o) - #define SCNuFAST8 __SCN8(u) - #define SCNxFAST8 __SCN8(x) + #define SCNdFAST8 __SCN8FAST(d) + #define SCNiFAST8 __SCN8FAST(i) + #define SCNoFAST8 __SCN8FAST(o) + #define SCNuFAST8 __SCN8FAST(u) + #define SCNxFAST8 __SCN8FAST(x) #endif /* _WANT_IO_C99_FORMATS */ /* 16-bit types */ -#define __PRI16(x) __STRINGIFY(x) -#define __SCN16(x) __STRINGIFY(h##x) +#define __PRI16(x) __INT16 __STRINGIFY(x) +#define __PRI16LEAST(x) __LEAST16 __STRINGIFY(x) +#define __PRI16FAST(x) __FAST16 __STRINGIFY(x) +#define __SCN16(x) __INT16 __STRINGIFY(x) +#define __SCN16LEAST(x) __LEAST16 __STRINGIFY(x) +#define __SCN16FAST(x) __FAST16 __STRINGIFY(x) #define PRId16 __PRI16(d) @@ -114,41 +122,40 @@ #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 PRIdLEAST16 __PRI16LEAST(d) +#define PRIiLEAST16 __PRI16LEAST(i) +#define PRIoLEAST16 __PRI16LEAST(o) +#define PRIuLEAST16 __PRI16LEAST(u) +#define PRIxLEAST16 __PRI16LEAST(x) +#define PRIXLEAST16 __PRI16LEAST(X) -#define SCNdLEAST16 __SCN16(d) -#define SCNiLEAST16 __SCN16(i) -#define SCNoLEAST16 __SCN16(o) -#define SCNuLEAST16 __SCN16(u) -#define SCNxLEAST16 __SCN16(x) +#define SCNdLEAST16 __SCN16LEAST(d) +#define SCNiLEAST16 __SCN16LEAST(i) +#define SCNoLEAST16 __SCN16LEAST(o) +#define SCNuLEAST16 __SCN16LEAST(u) +#define SCNxLEAST16 __SCN16LEAST(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 PRIdFAST16 __PRI16FAST(d) +#define PRIiFAST16 __PRI16FAST(i) +#define PRIoFAST16 __PRI16FAST(o) +#define PRIuFAST16 __PRI16FAST(u) +#define PRIxFAST16 __PRI16FAST(x) +#define PRIXFAST16 __PRI16FAST(X) -#define SCNdFAST16 __SCN16(d) -#define SCNiFAST16 __SCN16(i) -#define SCNoFAST16 __SCN16(o) -#define SCNuFAST16 __SCN16(u) -#define SCNxFAST16 __SCN16(x) +#define SCNdFAST16 __SCN16FAST(d) +#define SCNiFAST16 __SCN16FAST(i) +#define SCNoFAST16 __SCN16FAST(o) +#define SCNuFAST16 __SCN16FAST(u) +#define SCNxFAST16 __SCN16FAST(x) /* 32-bit types */ -#if defined (_INT32_EQ_LONG) -#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 __PRI32(x) __INT32 __STRINGIFY(x) +#define __SCN32(x) __INT32 __STRINGIFY(x) +#define __PRI32LEAST(x) __LEAST32 __STRINGIFY(x) +#define __SCN32LEAST(x) __LEAST32 __STRINGIFY(x) +#define __PRI32FAST(x) __FAST32 __STRINGIFY(x) +#define __SCN32FAST(x) __FAST32 __STRINGIFY(x) #define PRId32 __PRI32(d) #define PRIi32 __PRI32(i) @@ -164,46 +171,44 @@ #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 PRIdLEAST32 __PRI32LEAST(d) +#define PRIiLEAST32 __PRI32LEAST(i) +#define PRIoLEAST32 __PRI32LEAST(o) +#define PRIuLEAST32 __PRI32LEAST(u) +#define PRIxLEAST32 __PRI32LEAST(x) +#define PRIXLEAST32 __PRI32LEAST(X) -#define SCNdLEAST32 __SCN32(d) -#define SCNiLEAST32 __SCN32(i) -#define SCNoLEAST32 __SCN32(o) -#define SCNuLEAST32 __SCN32(u) -#define SCNxLEAST32 __SCN32(x) +#define SCNdLEAST32 __SCN32LEAST(d) +#define SCNiLEAST32 __SCN32LEAST(i) +#define SCNoLEAST32 __SCN32LEAST(o) +#define SCNuLEAST32 __SCN32LEAST(u) +#define SCNxLEAST32 __SCN32LEAST(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 PRIdFAST32 __PRI32FAST(d) +#define PRIiFAST32 __PRI32FAST(i) +#define PRIoFAST32 __PRI32FAST(o) +#define PRIuFAST32 __PRI32FAST(u) +#define PRIxFAST32 __PRI32FAST(x) +#define PRIXFAST32 __PRI32FAST(X) -#define SCNdFAST32 __SCN32(d) -#define SCNiFAST32 __SCN32(i) -#define SCNoFAST32 __SCN32(o) -#define SCNuFAST32 __SCN32(u) -#define SCNxFAST32 __SCN32(x) +#define SCNdFAST32 __SCN32FAST(d) +#define SCNiFAST32 __SCN32FAST(i) +#define SCNoFAST32 __SCN32FAST(o) +#define SCNuFAST32 __SCN32FAST(u) +#define SCNxFAST32 __SCN32FAST(x) /* 64-bit types */ -#if __have_long64 -#define __PRI64(x) __STRINGIFY(l##x) -#define __SCN64(x) __STRINGIFY(l##x) -#elif __have_longlong64 -#define __PRI64(x) __STRINGIFY(ll##x) -#define __SCN64(x) __STRINGIFY(ll##x) -#else -#define __PRI64(x) __STRINGIFY(x) -#define __SCN64(x) __STRINGIFY(x) -#endif +#define __PRI64(x) __INT64 __STRINGIFY(x) +#define __SCN64(x) __INT64 __STRINGIFY(x) +#define __PRI64LEAST(x) __LEAST64 __STRINGIFY(x) +#define __SCN64LEAST(x) __LEAST64 __STRINGIFY(x) +#define __PRI64FAST(x) __FAST64 __STRINGIFY(x) +#define __SCN64FAST(x) __FAST64 __STRINGIFY(x) + +#if __int64_t_defined #define PRId64 __PRI64(d) #define PRIi64 __PRI64(i) #define PRIo64 __PRI64(o) @@ -216,34 +221,36 @@ #define SCNo64 __SCN64(o) #define SCNu64 __SCN64(u) #define SCNx64 __SCN64(x) +#endif -#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) +#if __int_least64_t_defined +#define PRIdLEAST64 __PRI64LEAST(d) +#define PRIiLEAST64 __PRI64LEAST(i) +#define PRIoLEAST64 __PRI64LEAST(o) +#define PRIuLEAST64 __PRI64LEAST(u) +#define PRIxLEAST64 __PRI64LEAST(x) +#define PRIXLEAST64 __PRI64LEAST(X) + +#define SCNdLEAST64 __SCN64LEAST(d) +#define SCNiLEAST64 __SCN64LEAST(i) +#define SCNoLEAST64 __SCN64LEAST(o) +#define SCNuLEAST64 __SCN64LEAST(u) +#define SCNxLEAST64 __SCN64LEAST(x) +#endif + +#if __int_fast64_t_defined +#define PRIdFAST64 __PRI64FAST(d) +#define PRIiFAST64 __PRI64FAST(i) +#define PRIoFAST64 __PRI64FAST(o) +#define PRIuFAST64 __PRI64FAST(u) +#define PRIxFAST64 __PRI64FAST(x) +#define PRIXFAST64 __PRI64FAST(X) + +#define SCNdFAST64 __SCN64FAST(d) +#define SCNiFAST64 __SCN64FAST(i) +#define SCNoFAST64 __SCN64FAST(o) +#define SCNuFAST64 __SCN64FAST(u) +#define SCNxFAST64 __SCN64FAST(x) #endif /* max-bit types */ diff --git a/newlib/libc/include/sys/_intsup.h b/newlib/libc/include/sys/_intsup.h index 6c53641a562b52a2834f4037acdb71c5e2dd15b4..547e9ddd1a66a3843f5260e16c019d34fe61fa48 100644 --- a/newlib/libc/include/sys/_intsup.h +++ b/newlib/libc/include/sys/_intsup.h @@ -33,39 +33,168 @@ #define __have_long32 1 #endif -/* Determine how intptr_t and int32_t are defined by gcc for this target. This - is used to determine the correct printf() constant in inttypes.h and other - constants in stdint.h. */ +/* Determine how intptr_t and intN_t fastN_t and leastN_t are defined by gcc + for this target. This is used to determine the correct printf() constant in + inttypes.h and other constants in stdint.h. + So we end up with + ?(signed|unsigned) char == 0 + ?(signed|unsigned) short == 1 + ?(signed|unsigned) int == 2 + ?(signed|unsigned) short int == 3 + ?(signed|unsigned) long == 4 + ?(signed|unsigned) long int == 6 + ?(signed|unsigned) long long == 8 + ?(signed|unsigned) long long int == 10 + */ #pragma push_macro("signed") +#pragma push_macro("unsigned") +#pragma push_macro("char") +#pragma push_macro("short") #pragma push_macro("int") #pragma push_macro("long") #undef signed +#undef unsigned +#undef char +#undef short #undef int #undef long #define signed +0 -#define int +0 -#define long +1 -#if __INTPTR_TYPE__ == 2 +#define unsigned +0 +#define char +0 +#define short +1 +#define int +2 +#define long +4 +#if (__INTPTR_TYPE__ == 8 || __INTPTR_TYPE__ == 10) #define _INTPTR_EQ_LONGLONG -#elif __INTPTR_TYPE__ == 1 +#elif (__INTPTR_TYPE__ == 4 || __INTPTR_TYPE__ == 6) #define _INTPTR_EQ_LONG -#elif __INTPTR_TYPE__ == 0 +#elif __INTPTR_TYPE__ == 2 /* Nothing to define because intptr_t is safe to print as an int. */ #else #error "Unable to determine type definition of intptr_t" #endif -#if __INT32_TYPE__ == 1 +#if (__INT32_TYPE__ == 4 || __INT32_TYPE__ == 6) #define _INT32_EQ_LONG -#elif __INT32_TYPE__ == 0 +#elif __INT32_TYPE__ == 2 /* Nothing to define because int32_t is safe to print as an int. */ #else #error "Unable to determine type definition of int32_t" #endif -#undef long -#undef int + +#if (__INT8_TYPE__ == 0) +#define __INT8 "hh" +#elif (__INT8_TYPE__ == 1 || __INT8_TYPE__ == 3) +#define __INT8 "h" +#elif (__INT8_TYPE__ == 2) +#define __INT8 +#elif (__INT8_TYPE__ == 4 || __INT8_TYPE__ == 6) +#define __INT8 "l" +#elif (__INT8_TYPE__ == 8 || __INT8_TYPE__ == 10) +#define __INT8 "ll" +#endif +#if (__INT16_TYPE__ == 1 || __INT16_TYPE__ == 3) +#define __INT16 "h" +#elif (__INT16_TYPE__ == 2) +#define __INT16 +#elif (__INT16_TYPE__ == 4 || __INT16_TYPE__ == 6) +#define __INT16 "l" +#elif (__INT16_TYPE__ == 8 || __INT16_TYPE__ == 10) +#define __INT16 "ll" +#endif +#if (__INT32_TYPE__ == 2) +#define __INT32 +#elif (__INT32_TYPE__ == 4 || __INT32_TYPE__ == 6) +#define __INT32 "l" +#elif (__INT32_TYPE__ == 8 || __INT32_TYPE__ == 10) +#define __INT32 "ll" +#endif +#if (__INT64_TYPE__ == 2) +#define __INT64 +#elif (__INT64_TYPE__ == 4 || __INT64_TYPE__ == 6) +#define __INT64 "l" +#elif (__INT64_TYPE__ == 8 || __INT64_TYPE__ == 10) +#define __INT64 "ll" +#endif +#if (__INT_FAST8_TYPE__ == 0) +#define __FAST8 "hh" +#elif (__INT_FAST8_TYPE__ == 1 || __INT_FAST8_TYPE__ == 3) +#define __FAST8 "h" +#elif (__INT_FAST8_TYPE__ == 2) +#define __FAST8 +#elif (__INT_FAST8_TYPE__ == 4 || __INT_FAST8_TYPE__ == 6) +#define __FAST8 "l" +#elif (__INT_FAST8_TYPE__ == 8 || __INT_FAST8_TYPE__ == 10) +#define __FAST8 "ll" +#endif +#if (__INT_FAST16_TYPE__ == 1 || __INT_FAST16_TYPE__ == 3) +#define __FAST16 "h" +#elif (__INT_FAST16_TYPE__ == 2) +#define __FAST16 +#elif (__INT_FAST16_TYPE__ == 4 || __INT_FAST16_TYPE__ == 6) +#define __FAST16 "l" +#elif (__INT_FAST16_TYPE__ == 8 || __INT_FAST16_TYPE__ == 10) +#define __FAST16 "ll" +#endif +#if (__INT_FAST32_TYPE__ == 2) +#define __FAST32 +#elif (__INT_FAST32_TYPE__ == 4 || __INT_FAST32_TYPE__ == 6) +#define __FAST32 "l" +#elif (__INT_FAST32_TYPE__ == 8 || __INT_FAST32_TYPE__ == 10) +#define __FAST32 "ll" +#endif +#if (__INT_FAST64_TYPE__ == 2) +#define __FAST64 +#elif (__INT_FAST64_TYPE__ == 4 || __INT_FAST64_TYPE__ == 6) +#define __FAST64 "l" +#elif (__INT_FAST64_TYPE__ == 8 || __INT_FAST64_TYPE__ == 10) +#define __FAST64 "ll" +#endif + +#if (__INT_LEAST8_TYPE__ == 0) +#define __LEAST8 "hh" +#elif (__INT_LEAST8_TYPE__ == 1 || __INT_LEAST8_TYPE__ == 3) +#define __LEAST8 "h" +#elif (__INT_LEAST8_TYPE__ == 2) +#define __LEAST8 +#elif (__INT_LEAST8_TYPE__ == 4 || __INT_LEAST8_TYPE__ == 6) +#define __LEAST8 "l" +#elif (__INT_LEAST8_TYPE__ == 8 || __INT_LEAST8_TYPE__ == 10) +#define __LEAST8 "ll" +#endif +#if (__INT_LEAST16_TYPE__ == 1 || __INT_LEAST16_TYPE__ == 3) +#define __LEAST16 "h" +#elif (__INT_LEAST16_TYPE__ == 2) +#define __LEAST16 +#elif (__INT_LEAST16_TYPE__ == 4 || __INT_LEAST16_TYPE__ == 6) +#define __LEAST16 "l" +#elif (__INT_LEAST16_TYPE__ == 8 || __INT_LEAST16_TYPE__ == 10) +#define __LEAST16 "ll" +#endif +#if (__INT_LEAST32_TYPE__ == 2) +#define __LEAST32 +#elif (__INT_LEAST32_TYPE__ == 4 || __INT_LEAST32_TYPE__ == 6) +#define __LEAST32 "l" +#elif (__INT_LEAST32_TYPE__ == 8 || __INT_LEAST32_TYPE__ == 10) +#define __LEAST32 "ll" +#endif +#if (__INT_LEAST64_TYPE__ == 2) +#define __LEAST64 +#elif (__INT_LEAST64_TYPE__ == 4 || __INT_LEAST64_TYPE__ == 6) +#define __LEAST64 "l" +#elif (__INT_LEAST64_TYPE__ == 8 || __INT_LEAST64_TYPE__ == 10) +#define __LEAST64 "ll" +#endif #undef signed +#undef unsigned +#undef char +#undef short +#undef int +#undef long #pragma pop_macro("signed") +#pragma pop_macro("unsigned") +#pragma pop_macro("char") +#pragma pop_macro("short") #pragma pop_macro("int") -#pragma pop_macro("long") +#pragma pop_macro("long") #endif /* _SYS__INTSUP_H */ -- 1.9.1
Attachment:
aarch64.run
Description: Text document
Attachment:
arm.run
Description: Text document
/* Copyright (c) 2015 ARM Ltd. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the company may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdio.h> #include <inttypes.h> #include <stdint.h> #define xstr(s) str(s) #define str(s) #s int main (void) { printf ("Signed types\n"); printf ("typename\tbasetype\t\t\tprintf macro\tscanf macro\n"); #if defined(_WANT_IO_C99_FORMATS) printf ("int8_t\t\t" xstr (__INT8_TYPE__) "\t\t\t" PRId8 "\t\t" SCNd8 "\n"); printf ("int_least8_t\t" xstr (__INT_LEAST8_TYPE__) "\t\t\t" PRIdLEAST8 "\t\t" SCNdLEAST8 "\n"); printf ("int_fast8_t\t" xstr (__INT_FAST8_TYPE__) "\t\t\t\t" PRIdFAST8 "\t\t" SCNdFAST8 "\n"); #endif printf ("int16_t\t\t" xstr (__INT16_TYPE__) "\t\t\t" PRId16 "\t\t" SCNd16 "\n"); printf ("int_least16_t\t" xstr (__INT_LEAST16_TYPE__) "\t\t\t" PRIdLEAST16 "\t\t" SCNdLEAST16 "\n"); printf ("int_fast16_t\t" xstr (__INT_FAST16_TYPE__) "\t\t\t\t" PRIdFAST16 "\t\t" SCNdFAST16 "\n"); printf ("int32_t\t\t" xstr (__INT32_TYPE__) "\t\t\t" PRId32 "\t\t" SCNd32 "\n"); printf ("int_least32_t\t" xstr (__INT_LEAST32_TYPE__) "\t\t\t" PRIdLEAST32 "\t\t" SCNdLEAST32 "\n"); printf ("int_fast32_t\t" xstr (__INT_FAST32_TYPE__) "\t\t\t\t" PRIdFAST32 "\t\t" SCNdFAST32 "\n"); printf ("int64_t\t\t" xstr (__INT64_TYPE__) "\t\t\t" PRId64 "\t\t" SCNd64 "\n"); printf ("int_least64_t\t" xstr (__INT_LEAST64_TYPE__) "\t\t\t" PRIdLEAST64 "\t\t" SCNdLEAST64 "\n"); printf ("int_fast64_t\t" xstr (__INT_FAST64_TYPE__) "\t\t\t" PRIdFAST64 "\t\t" SCNdFAST64 "\n"); printf ("\n\nUnsigned types\n"); printf ("typename\tbasetype\t\t\tprintf macro\tscanf macro\n"); #if defined(_WANT_IO_C99_FORMATS) printf ("uint8_t\t\t" xstr (__UINT8_TYPE__) "\t\t\t" PRIu8 "\t\t" SCNu8 "\n"); printf ("uint_least8_t\t" xstr (__UINT_LEAST8_TYPE__) "\t\t\t" PRIuLEAST8 "\t\t" SCNuLEAST8 "\n"); printf ("uint_fast8_t\t" xstr (__UINT_FAST8_TYPE__) "\t\t\t" PRIuFAST8 "\t\t" SCNuFAST8 "\n"); #endif printf ("uint16_t\t" xstr (__UINT16_TYPE__) "\t\t" PRIu16 "\t\t" SCNu16 "\n"); printf ("uint_least16_t\t" xstr (__UINT_LEAST16_TYPE__) "\t\t" PRIuLEAST16 "\t\t" SCNuLEAST16 "\n"); printf ("uint_fast16_t\t" xstr (__UINT_FAST16_TYPE__) "\t\t\t" PRIuFAST16 "\t\t" SCNuFAST16 "\n"); printf ("uint32_t\t" xstr (__UINT32_TYPE__) "\t\t" PRIu32 "\t\t" SCNu32 "\n"); printf ("uint_least32_t\t" xstr (__UINT_LEAST32_TYPE__) "\t\t" PRIuLEAST32 "\t\t" SCNuLEAST32 "\n"); printf ("uint_fast32_t\t" xstr (__UINT_FAST32_TYPE__) "\t\t\t" PRIuFAST32 "\t\t" SCNuFAST32 "\n"); printf ("uint64_t\t" xstr (__UINT64_TYPE__) "\t\t" PRIu64 "\t\t" SCNu64 "\n"); printf ("uint_least64_t\t" xstr (__UINT_LEAST64_TYPE__) "\t\t" PRIuLEAST64 "\t\t" SCNuLEAST64 "\n"); printf ("uint_fast64_t\t" xstr (__UINT_FAST64_TYPE__) "\t\t" PRIuFAST64 "\t\t" SCNuFAST64 "\n"); return 0; }
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |