summaryrefslogtreecommitdiffstats
path: root/newlib/libc/include/sys/_intsup.h
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-04-29 13:06:45 +0200
committerCorinna Vinschen <corinna@vinschen.de>2015-04-29 13:07:17 +0200
commit6109eadff58d1fb7052e45c9d44ebc256a9bc5d1 (patch)
tree90624bfe00e4dc3be0ed8311870c6baa6d936a02 /newlib/libc/include/sys/_intsup.h
parent49c051c13352cd2fd2131a379d51a4a63c09283e (diff)
downloadcygnal-6109eadff58d1fb7052e45c9d44ebc256a9bc5d1.tar.gz
cygnal-6109eadff58d1fb7052e45c9d44ebc256a9bc5d1.tar.bz2
cygnal-6109eadff58d1fb7052e45c9d44ebc256a9bc5d1.zip
Improve check for int32_t being long or int
* libc/include/sys/config.h: Move evaluation of _UINTPTR_EQ_ULONG and _UINTPTR_EQ_ULONGLONG from here... * libc/include/sys/_intsup.h: ...to here. Rename to _INTPTR_EQ_LONG and _INTPTR_EQ_LONGLONG to refer to signed base type. Add test for base type of int32_t and set _INT32_EQ_LONG accordingly. * libc/include/stdint.h: Change checks for __have_long32 to checks for _INT32_EQ_LONG. * libc/include/inttypes.h: Ditto. Accommodate aforementioned name change. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'newlib/libc/include/sys/_intsup.h')
-rw-r--r--newlib/libc/include/sys/_intsup.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/newlib/libc/include/sys/_intsup.h b/newlib/libc/include/sys/_intsup.h
index 7c3bc01cb..6c53641a5 100644
--- a/newlib/libc/include/sys/_intsup.h
+++ b/newlib/libc/include/sys/_intsup.h
@@ -33,4 +33,39 @@
#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. */
+#pragma push_macro("signed")
+#pragma push_macro("int")
+#pragma push_macro("long")
+#undef signed
+#undef int
+#undef long
+#define signed +0
+#define int +0
+#define long +1
+#if __INTPTR_TYPE__ == 2
+#define _INTPTR_EQ_LONGLONG
+#elif __INTPTR_TYPE__ == 1
+#define _INTPTR_EQ_LONG
+#elif __INTPTR_TYPE__ == 0
+/* 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
+#define _INT32_EQ_LONG
+#elif __INT32_TYPE__ == 0
+/* 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
+#undef signed
+#pragma pop_macro("signed")
+#pragma pop_macro("int")
+#pragma pop_macro("long")
+
#endif /* _SYS__INTSUP_H */