__PRIPTR for 32-bit archs
Kornilios Kourtis
kkourt@inf.ethz.ch
Mon Feb 6 18:24:00 GMT 2012
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
More information about the Newlib
mailing list