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

Stefan Roese sr at denx.de
Wed Jul 22 07:13:21 CEST 2009


Hi Dirk,

On Tuesday 21 July 2009 20:32:01 Dirk Behme wrote:
> 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.

I have no "better" idea as well. It's still an improvement to the current 
implementation. So I suggest you prepare a patch (IIRC, Simon is on vacation 
right now).

Thanks.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================


More information about the U-Boot mailing list