[PATCH] fix printf "%p" output on 64-bit platform
Atsushi Nemoto
anemo at mba.ocn.ne.jp
Mon Jan 29 02:36:27 UTC 2007
On Sat, 27 Jan 2007 10:56:23 -0600, Roman Kononov <roman at xtremedatainc.com> wrote:
> > For the patch itself, I do not think we should care
> > "sizeof(long)!=sizeof(void *)" case.
>
> This is work for the compiler; no run-time overhead. If sizeof(int)==sizeof(void*)
> the compiler should remove everything inside the if () {}, and PA_FLAG_PTR case
> will be handled as if no PA_FLAG_XXX is set. You can remove the case, it will
> not change too much.
>
> > I'm not sure the magic typedef
> > do not confuse any compiler, so I think the magic typedef check is not
> > needed at all.
>
> The typedef is purely compile-time check that sizeof(void*)<=sizeof(uintmax_t).
> Theoretically, this condition does not have to be true. In such case the
> compiled code would be wrong at run-time. The typedef prevents the compiler
> to produce wrong code. AFAIK all modern compilers work fine with this typedef.
> You can remove the typedef, in practice it will not change too much.
It worked fine on 64-bit platform, but on 32-bit platform (mipsel,
mips64el(n32)), I got:
libc/stdio/_load_inttype.c: In function '_load_inttype':
libc/stdio/_load_inttype.c:16: error: size of array 'test_t' is negative
libc/stdio/_load_inttype.c:17: warning: cast from pointer to integer of different size
It seems gcc 4.1.1 optimize the "if" block away _after_ checking.
Maybe you can enclose the "if" block with "#ifdef __WORDSIZE == 64" or
something.
---
Atsushi Nemoto
More information about the uClibc
mailing list