From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1K7Hip-0002JU-Cc for mharc-grub-devel@gnu.org; Fri, 13 Jun 2008 18:26:15 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K7Him-0002J2-Ji for grub-devel@gnu.org; Fri, 13 Jun 2008 18:26:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K7Hik-0002Ie-Ol for grub-devel@gnu.org; Fri, 13 Jun 2008 18:26:11 -0400 Received: from [199.232.76.173] (port=34644 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K7Hik-0002Ib-K7 for grub-devel@gnu.org; Fri, 13 Jun 2008 18:26:10 -0400 Received: from c60.cesmail.net ([216.154.195.49]:10711) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1K7HiY-0006Qw-VU for grub-devel@gnu.org; Fri, 13 Jun 2008 18:26:10 -0400 Received: from unknown (HELO relay.cesmail.net) ([192.168.1.81]) by c60.cesmail.net with ESMTP; 13 Jun 2008 18:25:59 -0400 Received: from [192.168.0.21] (static-72-92-88-10.phlapa.fios.verizon.net [72.92.88.10]) by relay.cesmail.net (Postfix) with ESMTP id A9029619058 for ; Fri, 13 Jun 2008 18:25:57 -0400 (EDT) From: Pavel Roskin To: The development of GRUB 2 Content-Type: multipart/mixed; boundary="=-3477Eoa3ggAibsY3QJvH" Date: Fri, 13 Jun 2008 18:25:56 -0400 Message-Id: <1213395956.22425.50.camel@dv> Mime-Version: 1.0 X-Mailer: Evolution 2.22.2 (2.22.2-2.fc9) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [RFC PATCH] remove all floating point operations X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jun 2008 22:26:12 -0000 --=-3477Eoa3ggAibsY3QJvH Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hello! This patch should remove all dependency of floating point support in GRUB. The patch makes sure that all rounding is done to the nearest integer.  include/grub/powerpc/libgcc.h will be cleaned up separately. -- Regards, Pavel Roskin --=-3477Eoa3ggAibsY3QJvH Content-Disposition: attachment; filename=no-float.patch Content-Type: text/x-patch; name=no-float.patch; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 7bit diff --git a/commands/ls.c b/commands/ls.c index 77af426..4257e02 100644 --- a/commands/ls.c +++ b/commands/ls.c @@ -108,21 +108,25 @@ grub_ls_list_files (char *dirname, int longlist, int all, int human) grub_printf ("%-12llu", (unsigned long long) file->size); else { - float fsize = file->size; + grub_uint64_t fsize = file->size * 100ULL; int fsz = file->size; int units = 0; char buf[20]; while (fsz / 1024) { - fsize /= 1024; + fsize = (fsize + 512) / 1024; fsz /= 1024; units++; } if (units) { - grub_sprintf (buf, "%0.2f%c", fsize, grub_human_sizes[units]); + grub_uint32_t whole, fraction; + + whole = grub_divmod64 (fsize, 100, &fraction); + grub_sprintf (buf, "%u.%02u%c", whole, fraction, + grub_human_sizes[units]); grub_printf ("%-12s", buf); } else diff --git a/kern/misc.c b/kern/misc.c index 444ce2e..c662c96 100644 --- a/kern/misc.c +++ b/kern/misc.c @@ -655,24 +655,6 @@ grub_lltoa (char *str, int c, unsigned long long n) return p; } -static char * -grub_ftoa (char *str, double f, int round) -{ - unsigned int intp; - unsigned int fractp; - unsigned int power = 1; - int i; - - for (i = 0; i < round; i++) - power *= 10; - - intp = f; - fractp = (f - (float) intp) * power; - - grub_sprintf (str, "%d.%d", intp, fractp); - return str; -} - int grub_vsprintf (char *str, const char *fmt, va_list args) { @@ -807,19 +789,6 @@ grub_vsprintf (char *str, const char *fmt, va_list args) write_char (n & 0xff); break; - case 'f': - { - float f; - f = va_arg (args, double); - grub_ftoa (tmp, f, format2); - if (!rightfill && grub_strlen (tmp) < format1) - write_fill (zerofill, format1 - grub_strlen (tmp)); - write_str (tmp); - if (rightfill && grub_strlen (tmp) < format1) - write_fill (zerofill, format1 - grub_strlen (tmp)); - break; - } - case 'C': { grub_uint32_t code = va_arg (args, grub_uint32_t); --=-3477Eoa3ggAibsY3QJvH--