[U-Boot] [PATCH] [OLT-M68K] Avoid 64bit division in print_size
Signed-off-by: Luigi 'Comio' Mantellini luigi.mantell...@idf-hit.com --- lib/display_options.c | 15 --- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/display_options.c b/lib/display_options.c index 86df05d..eca5415 100644 --- a/lib/display_options.c +++ b/lib/display_options.c @@ -45,14 +45,14 @@ int display_options (void) */ void print_size(unsigned long long size, const char *s) { - unsigned long m = 0, n; + unsigned long m = 0, n, rem; static const char names[] = {'E', 'P', 'T', 'G', 'M', 'K'}; - unsigned long long d = 1ULL (10 * ARRAY_SIZE(names)); + unsigned int d_shift = 10 * ARRAY_SIZE(names); char c = 0; unsigned int i; - for (i = 0; i ARRAY_SIZE(names); i++, d = 10) { - if (size = d) { + for (i = 0; i ARRAY_SIZE(names); i++, d_shift -= 10) { + if (size = (1ULL d_shift)) { c = names[i]; break; } @@ -63,11 +63,12 @@ void print_size(unsigned long long size, const char *s) return; } - n = size / d; + n = size d_shift; + rem = size - (n d_shift); /* If there's a remainder, deal with it */ - if(size % d) { - m = (10 * (size - (n * d)) + (d / 2) ) / d; + if(rem) { + m = (10 * rem + (1ULL (d_shift -1 ))) d_shift; if (m = 10) { m -= 10; -- 1.7.0.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] [OLT-M68K] Avoid 64bit division in print_size
On Wed, May 26, 2010 at 9:01 AM, Luigi 'Comio' Mantellini luigi.mantell...@idf-hit.com wrote: Signed-off-by: Luigi 'Comio' Mantellini luigi.mantell...@idf-hit.com --- You're a little late: http://git.denx.de/?p=u-boot.git;a=commit;h=f2d76ae4fdde180e120ea2d29d6ef881360b3cba -- Timur Tabi Linux kernel developer at Freescale ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] [OLT-M68K] Avoid 64bit division in print_size
I'm sorry! my tree is out of date (2010/05/15) :) I'm using the toolchain coldfire-4.4 from Codesourcery (Sourcery G++ Lite 4.4-217) Today I tried to build the cf547x_8x target and I noticed a div by 0 issue on the __udivdi3 (n = size / d) ... I checked the operands that were ok, but I wasn't able to understand the real problem. In order to avoid the (bugged?) __udivdi3 call I wrote this workaroud. Any idea regarding this issue? Of course, avoiding the __udivdi3 call, the u-boot works fine. best regards, luigi mercoledì 26 maggio 2010 17:32 Timur Tabi timur.t...@gmail.com ha scritto: On Wed, May 26, 2010 at 9:01 AM, Luigi 'Comio' Mantellini luigi.mantell...@idf-hit.com wrote: Signed-off-by: Luigi 'Comio' Mantellini luigi.mantell...@idf-hit.com --- You're a little late: http://git.denx.de/?p=u-boot.git;a=commit;h=f2d76ae4fdde180e120ea2d29d6ef88 1360b3cba -- Luigi 'Comio' Mantellini RD - Software Industrie Dial Face S.p.A. Via Canzo, 4 20068 Peschiera Borromeo (MI) Italy Tel.: +39 02 5167 2813 Fax: +39 02 5167 2459 E-mail: luigi.mantell...@idf-hit.com Website: http://www.idf-hit.com Questo messaggio e i suoi allegati sono indirizzati esclusivamente alle persone indicate. La diffusione, copia o qualsiasi altra azione derivante dalla conoscenza di queste informazioni sono rigorosamente vietate. Qualora abbiate ricevuto questo documento per errore siete cortesemente pregati di darne immediata comunicazione al mittente e di provvedere alla sua distruzione, Grazie. Rispetta l'ambiente. Non stampare questa mail se non è realmente necessario. This e-mail and any attachments is confidential and may contain privileged information intended for the addressee(s) only. Dissemination, copying, printing or use by anybody else is unauthorized. If you are not the intended recipient, please delete this message and any attachments and advise the sender by return e-mail, Thanks. Help the environment. Please do not print this email unless it is absolutely necessary. idf_logo.png signature.asc Description: This is a digitally signed message part. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot