Avoid long division on MIPS
The 64 bit division function is not readily available from the MIPS toolchain inside chroot. This causes link failures when building upcoming MIPS coreboot targets. It turns out that the only place using the 64 bit division is the printf formatter when processing the '%L' format specification. Further examining of the source code has shown that so far the '%L' format specification is used only in x86 code. The suggested fix is to suppress %L support for MIPS. BUG=chromium:406038 TEST=with this patch the upcoming MIPS platforms build successfully. Change-Id: Iec0123620ac84a1697892f995235511b3288d4b2 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/214174 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
fcc0d934d7
commit
9c0978d944
1 changed files with 24 additions and 5 deletions
|
|
@ -8,6 +8,18 @@
|
|||
#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
|
||||
|
|
@ -31,7 +43,8 @@ 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 long long num, int base, int size, int precision, int type)
|
||||
unsigned_longest_int num, int base,
|
||||
int size, int precision, int type)
|
||||
{
|
||||
char c,sign,tmp[66];
|
||||
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
|
|
@ -47,7 +60,7 @@ static int number(void (*tx_byte)(unsigned char byte),
|
|||
c = (type & ZEROPAD) ? '0' : ' ';
|
||||
sign = 0;
|
||||
if (type & SIGN) {
|
||||
if ((signed long long)num < 0) {
|
||||
if ((longest_int)num < 0) {
|
||||
sign = '-';
|
||||
num = -num;
|
||||
size--;
|
||||
|
|
@ -104,7 +117,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 long long num;
|
||||
unsigned_longest_int num;
|
||||
int i, base;
|
||||
const char *s;
|
||||
|
||||
|
|
@ -220,10 +233,13 @@ repeat:
|
|||
continue;
|
||||
|
||||
case 'n':
|
||||
#ifdef SUPPORT_64BIT_INTS
|
||||
if (qualifier == 'L') {
|
||||
long long *ip = va_arg(args, long long *);
|
||||
*ip = count;
|
||||
} else if (qualifier == 'l') {
|
||||
} else
|
||||
#endif
|
||||
if (qualifier == 'l') {
|
||||
long * ip = va_arg(args, long *);
|
||||
*ip = count;
|
||||
} else {
|
||||
|
|
@ -261,9 +277,12 @@ repeat:
|
|||
--fmt;
|
||||
continue;
|
||||
}
|
||||
#ifdef SUPPORT_64BIT_INTS
|
||||
if (qualifier == 'L') {
|
||||
num = va_arg(args, unsigned long long);
|
||||
} else if (qualifier == 'l') {
|
||||
} else
|
||||
#endif
|
||||
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