
Wolfgang Denk wrote:
In message 46AF8CF0.7090600@googlemail.com you wrote:
Something like in attachment?
Probably not.
Thanks for commenting!
+/* The unnecessary pointer compare is there
- to check for type safety (n must be 64bit)
- */
+# define do_div(n,base) ({ \
- uint32_t __base = (base); \
- uint32_t __rem; \
- (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
- if (((n) >> 32) == 0) { \
__rem = (uint32_t)(n) % __base; \
(n) = (uint32_t)(n) / __base; \
- } else \
__rem = __div64_32(&(n), __base); \
- __rem; \
- })
CodingStyle: Generally, inline functions are preferable to macros resembling functions.
I know that this is no excuse for bad coding style, but please note that this stuff is already part of U-Boot, see lib_avr32/div64.c and include/asm-avr32/div64.h. My patch only moves the *unmodfied* files to lib_generic for general use, as proposed by HÃ¥vard. Same as U-Boot NG did ;)
Index: uboot/lib_generic/Makefile
--- uboot.orig/lib_generic/Makefile +++ uboot/lib_generic/Makefile @@ -27,7 +27,7 @@ LIB = $(obj)libgeneric.a
COBJS = bzlib.o bzlib_crctable.o bzlib_decompress.o \ bzlib_randtable.o bzlib_huffman.o \
crc32.o ctype.o display_options.o ldiv.o sha1.o \
string.o vsprintf.o zlib.ocrc32.o ctype.o display_options.o div64.o ldiv.o sha1.o \
Why should I link this code and increase the memory footprint for all boards, when 99% of them don't need this?
Sorry if I misunderstood anything here. But with putting do_div/__div64_32 to a *library* boards use it only if they need it? Here, if they explicitly use do_div()? If they don't use do_div(), the memory footprint isn't increased because it simply isn't used?
Please find below some tests with omap5912osk_config which doesn't use do_div/__div64_32. The first numbers are with clean recent git, the second with my patch with div64 stuff moved to lib_generic. As expected, library size increases but image size stays the same. Anything wrong with this?
Rejected.
What's your proposal then with the 64bit division issue in nand_util.c?
Best regards
Dirk
==> Clean recent git:
make omap5912osk_config make ll u-boot.bin
... 100016 ... u-boot.bin
ll lib_generic/libgeneric.a
... 102740 ... lib_generic/libgeneric.a
arm-elf-ar -t lib_generic/libgeneric.a
bzlib.o bzlib_crctable.o bzlib_decompress.o bzlib_randtable.o bzlib_huffman.o crc32.o ctype.o display_options.o ldiv.o sha1.o string.o vsprintf.o zlib.o
==> Clean recent git + div64_generic_patch.txt:
make omap5912osk_config make ll u-boot.bin
... 100016 ... u-boot.bin
ll lib_generic/libgeneric.a
... 106208 ... lib_generic/libgeneric.a
arm-elf-ar -t lib_generic/libgeneric.a
bzlib.o bzlib_crctable.o bzlib_decompress.o bzlib_randtable.o bzlib_huffman.o crc32.o ctype.o display_options.o div64.o ldiv.o sha1.o string.o vsprintf.o zlib.o