Patch: Change from configure time to compile time probe for intptr_t, definition.
Corinna Vinschen
vinschen@redhat.com
Mon Mar 23 11:04:00 GMT 2015
Hi Joel,
The patch looks good... almost. No worries, it's my fault:
> diff --git a/newlib/libc/include/sys/config.h b/newlib/libc/include/sys/config.h
> index 5297bef..a5a57c9 100644
> --- a/newlib/libc/include/sys/config.h
> +++ b/newlib/libc/include/sys/config.h
> @@ -287,4 +287,27 @@
> #define _MB_EXTENDED_CHARSETS_WINDOWS 1
> #endif
>
> +/* Determine how uintptr_t is defined by gcc for this target. This
> + is used to determine the correct printf() constant in inttypes.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 _UINTPTR_EQ_ULONGLONG
> +#elif __INTPTR_TYPE__ == 1
> +#define _UINTPTR_EQ_ULONG
> +#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 uintptr_t"
> +#endif
It occured to me that this is not without danger. Assuming you're using
a compiler ignoring the push_macro/pop_macro pragmas, then the above
macro definitions of signed, int and long will prevail from this point
on. Therefore, to be really sure, another set of #undef's should be
inserted here:
#undef signed
#undef int
#undef long
> +#pragma pop_macro("signed")
> +#pragma pop_macro("int")
> +#pragma pop_macro("long")
> #endif /* __SYS_CONFIG_H__ */
With that change, ok to push.
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20150323/c80c9015/attachment.sig>
More information about the Newlib
mailing list