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: __PRIPTR for 32-bit archs


On Mon, Feb 06, 2012 at 12:01:54PM +0100, Corinna Vinschen wrote:
> Hang on, that wouldn't work either for systems with sizeof(int) == 2 and
> sizeof (long) == sizeof (void*) == 4.  One example is old default m68k
> or current XStormy16 with -m32bit-pointers.
> 
> I think the right thing to do is to rely on the pointer size in relation
> to the base types only, in the order int -> long -> long long.  If long long
> is not defined, use long, like this:
> 
>   #if __STDINT_EXP(PTRDIFF_MAX) <= __STDINT_EXP(INT_MAX)
>   # define __PRIPTR(x) __STRINGIFY(x)
>   # define __SCNPTR(x) __STRINGIFY(x)
>   #elif __STDINT_EXP(PTRDIFF_MAX) <= __STDINT_EXP(LONG_MAX) || \
> 	!defined(__have_longlong64)
>   # define __PRIPTR(x) __STRINGIFY(l##x)
>   # define __SCNPTR(x) __STRINGIFY(l##x)
>   #else
>   # define __PRIPTR(x) __STRINGIFY(ll##x)
>   # define __SCNPTR(x) __STRINGIFY(ll##x)
>   #endif
> 
> Comments?

Looks OK to me.

cheers,
Kornilios.

-- 
Kornilios Kourtis


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