Revert "Avoid long division on MIPS"
This reverts commit 9c0978d944.
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 <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/232293
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
30f5f64ffc
commit
541c0837dd
1 changed files with 5 additions and 24 deletions
|
|
@ -8,18 +8,6 @@
|
|||
#include <console/console.h>
|
||||
#include <console/vtxprintf.h>
|
||||
|
||||
#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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue