libpayload: Don't sneak in compiler includes

The way we got to include the compiler includes was kind of whacky.
Instead of mixing in potentially problematic headers, make libpayload
self-contained by adding some missing header files. Also clean up
conflicting definitions of size_t throughout the tree.

Signed-off-by: Stefan Reinauer <reinauer@google.com>

Change-Id: I0ad1194de1a00b7133c5477c00eb167d63a2ee85
Reviewed-on: https://gerrit.chromium.org/gerrit/47608
Reviewed-by: Ronald G. Minnich <rminnich@chromium.org>
Commit-Queue: Stefan Reinauer <reinauer@google.com>
Tested-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/3058
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
This commit is contained in:
Stefan Reinauer 2013-04-08 16:55:47 -07:00 committed by Ronald G. Minnich
parent ba7ed4b6a1
commit 6ceed0929d
6 changed files with 25 additions and 11 deletions

View File

@ -53,9 +53,7 @@ subdirs-$(CONFIG_CURSES) += curses
subdirs-$(CONFIG_CBFS) += libcbfs subdirs-$(CONFIG_CBFS) += libcbfs
subdirs-$(CONFIG_LZMA) += liblzma subdirs-$(CONFIG_LZMA) += liblzma
CC_INCLUDE = $(shell $(CC) -print-search-dirs | head -n 1 | cut -d' ' -f2)include INCLUDES := -Iinclude -Iinclude/$(ARCHDIR-y) -I$(obj)
INCLUDES := -Iinclude -Iinclude/$(ARCHDIR-y) -I$(obj) -I$(CC_INCLUDE)
CFLAGS = $(EXTRA_CFLAGS) $(INCLUDES) -Os -pipe -nostdinc CFLAGS = $(EXTRA_CFLAGS) $(INCLUDES) -Os -pipe -nostdinc
CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs

View File

@ -53,9 +53,6 @@ typedef signed long long s64;
typedef long time_t; typedef long time_t;
typedef long suseconds_t; typedef long suseconds_t;
typedef unsigned long size_t;
typedef long ssize_t;
#ifndef NULL #ifndef NULL
#define NULL ((void *)0) #define NULL ((void *)0)
#endif #endif

View File

@ -31,7 +31,20 @@
#define _LIBPAYLOAD_STDARG_H #define _LIBPAYLOAD_STDARG_H
#include <stddef.h> #include <stddef.h>
/* With GCC we use -nostdinc -ffreestanding to keep out system includes.
* Unfortunately this also gets us rid of the _compiler_ includes, like
* stdarg.h. To work around the issue, we define varargs directly here.
* On LLVM we can still just include stdarg.h.
*/
#ifdef __GNUC__
#define va_start(v,l) __builtin_va_start(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_arg(v,l) __builtin_va_arg(v,l)
typedef __builtin_va_list va_list;
#else
#include_next <stdarg.h> #include_next <stdarg.h>
#endif
/** /**
* @defgroup vprintf Varargs print functions * @defgroup vprintf Varargs print functions

View File

@ -0,0 +1,11 @@
#include <arch/types.h>
#ifndef __SIZE_TYPE__
#define __SIZE_TYPE__ unsigned long
#endif
typedef __SIZE_TYPE__ size_t;
typedef long ssize_t;
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)

View File

@ -32,8 +32,6 @@
#include <stddef.h> #include <stddef.h>
typedef ptrdiff_t ssize_t;
int getpagesize(void); int getpagesize(void);
#endif #endif

View File

@ -53,9 +53,6 @@ typedef signed long long s64;
typedef long time_t; typedef long time_t;
typedef long suseconds_t; typedef long suseconds_t;
typedef unsigned long size_t;
typedef long ssize_t;
#ifndef NULL #ifndef NULL
#define NULL ((void *)0) #define NULL ((void *)0)
#endif #endif