summaryrefslogtreecommitdiffstats
path: root/newlib/libc/include/sys/_intsup.h
diff options
context:
space:
mode:
authorAndre Simoes Dias Vieira <andsim01@arm.com>2015-08-27 11:50:25 +0100
committerCorinna Vinschen <corinna@vinschen.de>2015-08-27 12:50:25 +0200
commit892cfcb7c2fbdc3b2b09c95a7a6c2065e5e0cfae (patch)
tree192d9b58a1aa53e6d7ebe8bda1d64124a2451c9e /newlib/libc/include/sys/_intsup.h
parent9074b9b8ad6cc2b352973f183b962dbe91973a72 (diff)
downloadcygnal-892cfcb7c2fbdc3b2b09c95a7a6c2065e5e0cfae.tar.gz
cygnal-892cfcb7c2fbdc3b2b09c95a7a6c2065e5e0cfae.tar.bz2
cygnal-892cfcb7c2fbdc3b2b09c95a7a6c2065e5e0cfae.zip
Fix for pri and scn formats
Diffstat (limited to 'newlib/libc/include/sys/_intsup.h')
-rw-r--r--newlib/libc/include/sys/_intsup.h155
1 files changed, 142 insertions, 13 deletions
diff --git a/newlib/libc/include/sys/_intsup.h b/newlib/libc/include/sys/_intsup.h
index 6c53641a5..ea10431f7 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 */