__PRIPTR for 32-bit archs
Corinna Vinschen
vinschen@redhat.com
Tue Feb 7 16:44:00 GMT 2012
On Feb 6 19:23, Kornilios Kourtis wrote:
> 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.
I've applied this patch with a change. Instead of __STDINT_EXP(PTRDIFF_MAX)
it's now using PTRDIFF_MAX directly, since that's already defined in
stdint.h anyway.
Corinna
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat
More information about the Newlib
mailing list