[coreboot] filo-0.5 compilation issues
Ken.Fuchs at bench.com
Ken.Fuchs at bench.com
Wed Jun 11 18:23:09 CEST 2008
ron minnich wrote:
> gcc -m32 -Wall -Os -fomit-frame-pointer -fno-common -ffreestanding
> -fno-strict-aliasing -Wno-unused -nostdinc -imacros ../config.h
> -I../include -I/usr/lib/gcc/i486-linux-gnu/4.1.2/include -MD
> -c printf.c
> -o printf.o
>
> What does this with -E show? This is really weird.
With -E, the compilation produces (without warnings or errors)
the following preprocessor output appended below my sig.
Thanks,
Ken Fuchs
------
# 1 "printf.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "./../config.h" 1
# 1 "<command line>" 2
# 1 "printf.c"
# 16 "printf.c"
# 1 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stdarg.h" 1
# 43 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stdarg.h"
typedef __builtin_va_list __gnuc_va_list;
# 105 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stdarg.h"
typedef __gnuc_va_list va_list;
# 17 "printf.c" 2
# 1 "../include/lib.h" 1
# 1 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stddef.h" 1
# 152 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stddef.h"
typedef int ptrdiff_t;
# 214 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stddef.h"
typedef unsigned int size_t;
# 326 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/stddef.h"
typedef int wchar_t;
# 5 "../include/lib.h" 2
# 1 "../include/arch/stdint.h" 1
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef signed long long int64_t;
# 6 "../include/lib.h" 2
void vga_init(void);
void vga_putchar(unsigned int c);
int kbd_havekey(void);
int kbd_havechar(void);
int kbd_getchar(void);
void serial_init(void);
void serial_putchar(unsigned char c);
int serial_havechar(void);
int serial_getchar(void);
void console_init(void);
int putchar(int c);
int puts(const char *s);
int printf(const char *fmt, ...) __attribute__ ((format (printf, 1,
2)));
int havekey(void);
int havechar(void);
int getchar(void);
int getline(char *buf, int max);
extern int last_putchar;
void *malloc(size_t size);
void free(void *ptr);
void *calloc(size_t nmemb, size_t size);
void *realloc(void *ptr, size_t size);
void malloc_check(void);
void malloc_diag(void);
void *allot2(size_t size, unsigned int alignment);
void forget2(void *ptr);
size_t strnlen(const char *src, size_t max);
size_t strlen(const char *src);
int strcmp(const char *s1, const char *s2);
int memcmp(const void *s1, const void *s2, size_t n);
void *memcpy(void *dest, const void *src, size_t n);
void *memset(void *s, int c, size_t n);
void *memmove(void *dest, const void *src, size_t n);
int isspace(int c);
int isdigit(int c);
int tolower(int c);
char *strdup(const char *s);
char *strchr(const char *s, int c);
char *strncpy(char *to, const char *from, int count);
char * strcpy (char *dest, const char *src);
char * strstr (const char *s1, const char *s2);
int strncat (char *s1, const char *s2, int n);
int sprintf(char * buf, const char *fmt, ...);
unsigned long long simple_strtoull(const char *cp,char **endp,unsigned
int base);
unsigned long long strtoull_with_suffix(const char *cp,char
**endp,unsigned int base);
unsigned int get_le32(const unsigned char *);
unsigned int get_le16(const unsigned char *);
void hexdump(const void *p, unsigned int len);
long long simple_strtoll(const char *cp,char **endp,unsigned int base);
void halt(void) __attribute__((noreturn));
struct sys_info;
int elf_load(struct sys_info *, const char *filename, const char
*cmdline);
int linux_load(struct sys_info *, const char *filename, const char
*cmdline);
# 18 "printf.c" 2
# 26 "printf.c"
static inline unsigned char __toupper(unsigned char c)
{
if (((c) >= 'a' && (c) <= 'z'))
c -= 'a'-'A';
return c;
}
unsigned long long simple_strtoull(const char *cp,char **endp,unsigned
int base)
{
unsigned long long result = 0,value;
if (!base) {
base = 10;
if (*cp == '0') {
base = 8;
cp++;
if ((*cp == 'x') && (((cp[1]) >= '0' && (cp[1]) <= '9') || ((cp[1])
>= 'a' && (cp[1]) <= 'f') || ((cp[1]) >= 'A' && (cp[1]) <= 'F'))) {
cp++;
base = 16;
}
}
}
while ((((*cp) >= '0' && (*cp) <= '9') || ((*cp) >= 'a' && (*cp) <=
'f') || ((*cp) >= 'A' && (*cp) <= 'F')) && (value = ((*cp) >= '0' &&
(*cp) <= '9') ? *cp-'0' : (((*cp) >= 'a' && (*cp) <= 'z')
? __toupper(*cp) : *cp)-'A'+10) < base) {
result = result*base + value;
cp++;
}
if (endp)
*endp = (char *)cp;
return result;
}
long long simple_strtoll(const char *cp,char **endp,unsigned int base)
{
if(*cp=='-')
return -simple_strtoull(cp+1,endp,base);
return simple_strtoull(cp,endp,base);
}
unsigned long long strtoull_with_suffix(const char *cp,char
**endp,unsigned int base)
{
unsigned long long result;
if (!endp) {
printf("%s must be called with endp\n", __FUNCTION__);
return 0;
}
result = simple_strtoull(cp, endp, base);
switch (__toupper(**endp)) {
case 'K':
result <<= 10;
++*endp;
break;
case 'M':
result <<= 20;
++*endp;
break;
case 'G':
result <<= 30;
++*endp;
break;
}
return result;
}
static int skip_atoi(const char **s)
{
int i=0;
while (((**s) >= '0' && (**s) <= '9'))
i = i*10 + *((*s)++) - '0';
return i;
}
# 116 "printf.c"
static int number(int (*tx_byte)(int byte), long long num, int base, int
size, int precision
,int type)
{
char c,sign,tmp[66];
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
int i;
int count = 0;
if (type & 64)
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (type & 16)
type &= ~1;
if (base < 2 || base > 36)
return 0;
c = (type & 1) ? '0' : ' ';
sign = 0;
if (type & 2) {
if (num < 0) {
sign = '-';
num = -num;
size--;
} else if (type & 4) {
sign = '+';
size--;
} else if (type & 8) {
sign = ' ';
size--;
}
}
if (type & 32) {
if (base == 16)
size -= 2;
else if (base == 8)
size--;
}
i = 0;
if (num == 0)
tmp[i++]='0';
else while (num != 0)
tmp[i++] = digits[({ int __res; __res = ((unsigned long long) num) %
(unsigned) base; num = ((unsigned long long) num) / (unsigned) base;
__res; })];
if (i > precision)
precision = i;
size -= precision;
if (!(type&(1 +16)))
while(size-->0)
tx_byte(' '), count++;
if (sign)
tx_byte(sign), count++;
if (type & 32) {
if (base==8)
tx_byte('0'), count++;
else if (base==16) {
tx_byte('0'), count++;
tx_byte(digits[33]), count++;
}
}
if (!(type & 16))
while (size-- > 0)
tx_byte(c), count++;
while (i < precision--)
tx_byte('0'), count++;
while (i-- > 0)
tx_byte(tmp[i]), count++;
while (size-- > 0)
tx_byte(' '), count++;
return count;
}
int vtxprintf(int (*tx_byte)(int byte), const char *fmt, va_list args)
{
int len;
unsigned long long num;
int i, base;
const char *s;
int flags;
int field_width;
int precision;
int qualifier; se + value;
cp++;
}
if (endp)
*endp = (char *)cp;
return result;
}
long long simple_strtoll(const char *cp,char **endp,unsigned int base)
{
if(*cp=='-')
return -simple_strtoull(cp+1,endp,base);
return simple_strtoull(cp,endp flags |= 16; goto repeat;
case '+': flags |= 4; goto repeat;
case ' ': flags |= 8; goto repeat;
case '#': flags |= 32; goto repeat;
case '0': flags |= 1; goto repeat;
}
field_width = -1;
if (((*fmt) >= '0' && (*fmt) <= '9'))
field_width = skip_atoi(&fmt);
else if (*fmt == '*') {
++fmt;
field_width = __builtin_va_arg(args,int);
if (field_width < 0) {
field_width = -field_width;
flags |= 16;
}
}
precision = -1;
if (*fmt == '.') {
++fmt;
if (((*fmt) >= '0' && (*fmt) <= '9'))
precision = skip_atoi(&fmt);
else if (*fmt == '*') {
++fmt;
precision = __builtin_va_arg(args,int);
}
if (precision < 0)
precision = 0;
}
qualifier = -1;
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
qualifier = *fmt;
++fmt;
}
base = 10;
switch (*fmt) {
case 'c':
if (!(flags & 16))
while (--field_width > 0)
tx_byte(' '), count++;
tx_byte((unsigned char) __builtin_va_arg(args,int)), count++;
while (--field_width > 0)
tx_byte(' '), count++;
continue;
case 's':
s = __builtin_va_arg(args,char *);
if (!s)
s = "<NULL>";
len = strnlen(s, precision);
if (!(flags & 16))
while (len < field_width--)
tx_byte(' '), count++;
for (i = 0; i < len; ++i)
tx_byte(*s++), count++;
while (len < field_width--)
tx_byte(' '), count++;
continue;
case 'p':
if (field_width == -1) {
field_width = 2*sizeof(void *);
flags |= 1;
}
count += number(tx_byte,
(unsigned long) __builtin_va_arg(args,void *), 16,
field_width, precision, flags);
continue;
case 'n':
if (qualifier == 'l') {
long * ip = __builtin_va_arg(args,long *);
*ip = count;
} else {
int * ip = __builtin_va_arg(args,int *);
*ip = count;
}
continue;
case '%':
tx_byte('%'), count++;
continue;
case 'o':
base = 8;
break;
case 'X':
flags |= 64;
case 'x':
base = 16;
break;
case 'd':
case 'i':
flags |= 2;
case 'u':
break;
default:
tx_byte('%'), count++;
if (*fmt)
tx_byte(*fmt), count++;
else
--fmt;
continue;
}
if (qualifier == 'L')
num = __builtin_va_arg(args,unsigned long long);
else if (qualifier == 'l')
num = __builtin_va_arg(args,unsigned long);
else if (qualifier == 'h') {
num = (unsigned short) __builtin_va_arg(args,int);
if (flags & 2)
num = (short) num;
} else if (flags & 2)
num = __builtin_va_arg(args,int);
else
num = __builtin_va_arg(args,unsigned int);
count += number(tx_byte, num, base, field_width, precision, flags);
}
return count;
}
static char *str_buf;
static int str_tx_byte(int byte)
{
*str_buf = byte;
str_buf++;
return byte;
}
int vsprintf(char * buf, const char *fmt, va_list args)
{
int i;
str_buf = buf;
i = vtxprintf(str_tx_byte, fmt, args);
*str_buf = '\0';
return i;
}
int sprintf(char * buf, const char *fmt, ...)
{
va_list args;
int i;
__builtin_va_start(args,fmt);
i=vsprintf(buf,fmt,args);
__builtin_va_end(args);
return i;
}
int printf(const char *fmt, ...)
{
va_list args;
int i;
__builtin_va_start(args,fmt);
i = vtxprintf(putchar, fmt, args);
__builtin_va_end(args);
return i;
}
More information about the coreboot
mailing list