[PATCH] fix printf "%p" output on 64-bit platform

Atsushi Nemoto anemo at mba.ocn.ne.jp
Tue Nov 7 08:31:20 UTC 2006


On Tue, 7 Nov 2006 03:19:55 -0500, Mike Frysinger <vapier at gentoo.org> wrote:
> > Well, I suppose "__PA_INTMASK" means "integer", not "int". :)
> 
> if so, does your patch work ?  you'd be loading a long long via int
> ... i dont really know our stdio layer as it's [mostly] just worked

Yes, the patch works for me.

Here is a excerpt from printf.h:

enum
{				/* C type: */
  PA_INT,			/* int */
  PA_CHAR,			/* int, cast to char */
  PA_WCHAR,			/* wide char */
  PA_STRING,			/* const char *, a '\0'-terminated string */
  PA_WSTRING,			/* const wchar_t *, wide character string */
  PA_POINTER,			/* void * */
  PA_FLOAT,			/* float */
  PA_DOUBLE,			/* double */
  __PA_NOARG,			/* non-glibc -- signals non-arg width or prec */
  PA_LAST
};

#define PA_FLAG_MASK		(0xff00)
#define __PA_FLAG_CHAR		(0x0100) /* non-gnu -- to deal with hh */
#define PA_FLAG_SHORT		(0x0200)
#define PA_FLAG_LONG		(0x0400)
#define PA_FLAG_LONG_LONG	(0x0800)
#define PA_FLAG_LONG_DOUBLE	PA_FLAG_LONG_LONG
#define PA_FLAG_PTR		(0x1000) /* TODO -- make dynamic??? */

#define __PA_INTMASK		(0x0f00) /* non-gnu -- all int flags */


The problem seems *argtype value is PA_POINTER for "%p" and not
contains PA_FLAG_LONG bit.  It might be possible to change *argtype
calculation for "%p", but I could not see where to change ...

---
Atsushi Nemoto



More information about the uClibc mailing list