From 541c0837dd685a541c820847cb06ae7376640f59 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Sat, 29 Nov 2014 21:55:44 -0800 Subject: [PATCH] Revert "Avoid long division on MIPS" This reverts commit 9c0978d944ca02d1249b67a2900f119d73df12d8. The underlying assumption was that the only format specification which required 64 bit division was '%L', and it was used on x86 only. It turns out, that '%ll' also uses 64 bit division, and this format specification is more popular in the code, which in turn results in incorrect values printed when the caller passes in 64 bit numbers. An alternative solution will be presented in the next patch. BRANCH=none BUG=none TEST=none Change-Id: Ie671d49a5026eb3b0c3c250f365d725e3b19bb25 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/232293 Reviewed-by: Aaron Durbin --- src/console/vtxprintf.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/src/console/vtxprintf.c b/src/console/vtxprintf.c index 872b48996f..4fc6f35bd1 100644 --- a/src/console/vtxprintf.c +++ b/src/console/vtxprintf.c @@ -8,18 +8,6 @@ #include #include -#if !CONFIG_ARCH_MIPS -#define SUPPORT_64BIT_INTS -#endif - -#ifdef SUPPORT_64BIT_INTS -typedef unsigned long long unsigned_longest_int; -typedef long long longest_int; -#else -typedef unsigned long unsigned_longest_int; -typedef long longest_int; -#endif - /* haha, don't need ctype.c */ #define isdigit(c) ((c) >= '0' && (c) <= '9') #define is_digit isdigit @@ -43,8 +31,7 @@ static int skip_atoi(const char **s) #define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ static int number(void (*tx_byte)(unsigned char byte), - unsigned_longest_int num, int base, - int size, int precision, int type) + unsigned long long num, int base, int size, int precision, int type) { char c,sign,tmp[66]; const char *digits="0123456789abcdefghijklmnopqrstuvwxyz"; @@ -60,7 +47,7 @@ static int number(void (*tx_byte)(unsigned char byte), c = (type & ZEROPAD) ? '0' : ' '; sign = 0; if (type & SIGN) { - if ((longest_int)num < 0) { + if ((signed long long)num < 0) { sign = '-'; num = -num; size--; @@ -117,7 +104,7 @@ static int number(void (*tx_byte)(unsigned char byte), int vtxprintf(void (*tx_byte)(unsigned char byte), const char *fmt, va_list args) { int len; - unsigned_longest_int num; + unsigned long long num; int i, base; const char *s; @@ -233,13 +220,10 @@ repeat: continue; case 'n': -#ifdef SUPPORT_64BIT_INTS if (qualifier == 'L') { long long *ip = va_arg(args, long long *); *ip = count; - } else -#endif - if (qualifier == 'l') { + } else if (qualifier == 'l') { long * ip = va_arg(args, long *); *ip = count; } else { @@ -277,12 +261,9 @@ repeat: --fmt; continue; } -#ifdef SUPPORT_64BIT_INTS if (qualifier == 'L') { num = va_arg(args, unsigned long long); - } else -#endif - if (qualifier == 'l') { + } else if (qualifier == 'l') { num = va_arg(args, unsigned long); } else if (qualifier == 'z') { num = va_arg(args, size_t);