[U-Boot] [PATCH 5/8]: Use do_div from div64.h for vsprintf

Dirk Behme dirk.behme at googlemail.com
Tue Jul 21 20:32:01 CEST 2009


Wolfgang Denk wrote:
> Dear Simon Kagstrom,
> 
> In message <20090720214252.B0B6E832E416 at gemini.denx.de> I wrote:
>> Dear Simon Kagstrom,
>>
>> In message <20090707155927.78e75333 at marrow.netinsight.se> you wrote:
>>> Signed-off-by: Simon Kagstrom <simon.kagstrom at netinsight.net>
>>> ---
>>>  lib_generic/vsprintf.c |    7 +------
>>>  1 files changed, 1 insertions(+), 6 deletions(-)
>> Applied, thanks.
> 
> Sorry, I had to back out your patch. as it is causing compile problems:
> 
> -> ./MAKEALL voiceblue
> Configuring for voiceblue board...
> vsprintf.c: In function 'put_dec':
> vsprintf.c:237: warning: comparison of distinct pointer types lacks a cast
> vsprintf.c:237: warning: right shift count >= width of type
> vsprintf.c:237: warning: passing argument 1 of '__div64_32' from incompatible pointer type
>    text    data     bss     dec     hex filename
>  142099    5196   23304  170599   29a67 ./u-boot
> 
> Please fix and resubmit.

:(

This is because do_div() in div64.h only likes a 64bit value as first 
parameter.

So something like

--- a/lib_generic/vsprintf.c
+++ b/lib_generic/vsprintf.c
@@ -22,18 +22,19 @@ extern int do_reset (cmd_tbl_t *cmdtp, i
  #endif

  #ifdef CONFIG_SYS_64BIT_VSPRINTF
+#include <div64.h>
  # define NUM_TYPE long long
  #else
  # define NUM_TYPE long
-#endif
-#define noinline __attribute__((noinline))
-
  #define do_div(n, base) ({ \
  	unsigned int __res; \
  	__res = ((unsigned NUM_TYPE) n) % base; \
  	n = ((unsigned NUM_TYPE) n) / base; \
  	__res; \
  })
+#endif
+#define noinline __attribute__((noinline))
+

would do the trick. I don't know any clean way how to do this, though.

Best regards

Dirk


More information about the U-Boot mailing list