[U-Boot] CFG_64BIT_xxx and friends
Haavard Skinnemoen
haavard.skinnemoen at atmel.com
Mon Sep 8 14:23:26 CEST 2008
Haavard Skinnemoen <haavard.skinnemoen at atmel.com> wrote:
> That's a bit more than expected. Is this with or without --gc-sections?
> Linking with --gc-sections should make simple_strtoull() go away unless
> it's actually used.
That's assuming the fdt and image code doesn't interpret
CFG_64BIT_VSPRINTF as CFG_BLOAT_ME_HARDER, which it does. So enabling
CFG_64BIT_VSPRINTF does increase the code size even with --gc-sections.
I think fdt and common/image.c should stop abusing CFG_64BIT_VSPRINTF
and get its own symbol instead, e.g. CFG_64BIT_PHYS_ADDR, and perhaps a
nice str_to_addr() wrapper which selects between strtoul and strtoull
based on this symbol.
> Another thing that might hurt is that lib_generic/vsprintf.c reinvents
> do_div() without the out-of-line __div_64_32() bit. Converting it to
> use do_div() from include/div64.h should help.
It does. A lot. Here are some numbers from avr32:
vanilla:
text data bss dec hex filename
96232 7528 216208 319968 4e1e0 ./u-boot
with CFG_64BIT_VSPRINTF:
text data bss dec hex filename
98100 7528 216208 321836 4e92c ./u-boot
with CFG_64BIT_VSPRINTF and generic do_div():
text data bss dec hex filename
96396 7528 216208 320132 4e284 ./u-boot
So I highly recommend applying the patch below before killing
CFG_64BIT_VSPRINTF.
> In fact, enabling CFG_64BIT_VSPRINTF unconditionally without fixing
> this first will probably break all architectures that don't link with
> libgcc.
I was sort of expecting avr32 to break because of this, but it didn't.
Apparently, the top-level Makefile adds -lgcc unconditionally...which
makes it quite hard to catch undesired bloat like this.
Haavard
From: Haavard Skinnemoen <haavard.skinnemoen at atmel.com>
Subject: vsprintf: Use generic do_div()
lib_generic/vsprintf.c uses its own reimplementation of do_div().
Switch it over to use the generic implementation from include/div64.h.
This saves 2K of .text on avr32 with CFG_64BIT_VSPRINTF enabled.
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen at atmel.com>
diff --git a/lib_generic/vsprintf.c b/lib_generic/vsprintf.c
index 7c9cfe1..a4f8a83 100644
--- a/lib_generic/vsprintf.c
+++ b/lib_generic/vsprintf.c
@@ -15,6 +15,7 @@
#include <linux/ctype.h>
#include <common.h>
+#include <div64.h>
#if !defined (CONFIG_PANIC_HANG)
#include <command.h>
/*cmd_boot.c*/
@@ -106,22 +107,6 @@ static int skip_atoi(const char **s)
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
#ifdef CFG_64BIT_VSPRINTF
-#define do_div(n,base) ({ \
- unsigned int __res; \
- __res = ((unsigned long long) n) % base; \
- n = ((unsigned long long) n) / base; \
- __res; \
-})
-#else
-#define do_div(n,base) ({ \
- int __res; \
- __res = ((unsigned long) n) % base; \
- n = ((unsigned long) n) / base; \
- __res; \
-})
-#endif
-
-#ifdef CFG_64BIT_VSPRINTF
static char * number(char * str, long long num, unsigned int base, int size, int precision ,int type)
#else
static char * number(char * str, long num, unsigned int base, int size, int precision ,int type)
More information about the U-Boot
mailing list