From 6109eadff58d1fb7052e45c9d44ebc256a9bc5d1 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 29 Apr 2015 13:06:45 +0200 Subject: 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 --- newlib/libc/include/sys/_intsup.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'newlib/libc/include/sys/_intsup.h') 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 */ -- cgit v1.2.3