On Tue, Aug 26, 2014 at 05:14:17PM -0600, Simon Glass wrote: > Hi Thierry, > > On 26 August 2014 09:33, Thierry Reding <thierry.red...@gmail.com> wrote: > > > > From: Thierry Reding <tred...@nvidia.com> > > > > Provide a new modifier to vsprintf() to print phys_addr_t variables to > > avoid having to cast or #ifdef when printing them out. The %pa modifier > > is used for this purpose, so phys_addr_t variables need to be passed by > > reference, like so: > > > > phys_addr_t start = 0; > > > > printf("start: %pa\n", &start); > > > > Depending on the size of phys_addr_t this will print out the address > > with 8 or 16 hexadecimal digits following a 0x prefix. > > Would it be better to use %#pa to get the 0x prefix so we have the > option? Hex is the default in U-Boot.
Yeah, that's very confusing since there's no way to tell apart a hexadecimal number from a decimal one since there's no decimal equivalent of the 0x prefix. If you insist I can change that (it should be a simple matter of dropping the SPECIAL flag in the 'a' case). > > Signed-off-by: Thierry Reding <tred...@nvidia.com> > > --- > > lib/vsprintf.c | 16 ++++++++++++++-- > > 1 file changed, 14 insertions(+), 2 deletions(-) > > > > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > > index 7ec758e40fc5..044d5551bdd0 100644 > > --- a/lib/vsprintf.c > > +++ b/lib/vsprintf.c > > @@ -518,6 +518,8 @@ static char *ip4_addr_string(char *buf, char *end, u8 > > *addr, int field_width, > > static char *pointer(const char *fmt, char *buf, char *end, void *ptr, > > int field_width, int precision, int flags) > > { > > + u64 num = (uintptr_t)ptr; > > + > > Will this impact code size much? I suppose it is vsprintf() so it > doesn't matter too much? Doing only this change and the corresponding change in the call to number() results in the exact sizes: $ size build/jetson-tk1.{before,after}/u-boot text data bss dec hex filename 310434 10872 309184 630490 99eda build/jetson-tk1.before/u-boot 310434 10872 309184 630490 99eda build/jetson-tk1.after/u-boot Given that the num parameter of the number() function is already a u64 the compiler will presumably automatically handle the ptr argument as a 64-bit value. Thierry
pgpLONVnzIA18.pgp
Description: PGP signature
_______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot