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]

Re: Patch: Change from configure time to compile time probe for intptr_t, definition.


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

Attachment: pgplqeEOVY0TY.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]