From 6ceed0929d1e11c9d8807427750bb6e4f14806fd Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Mon, 8 Apr 2013 16:55:47 -0700 Subject: 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 Change-Id: I0ad1194de1a00b7133c5477c00eb167d63a2ee85 Reviewed-on: https://gerrit.chromium.org/gerrit/47608 Reviewed-by: Ronald G. Minnich Commit-Queue: Stefan Reinauer Tested-by: Stefan Reinauer Reviewed-on: http://review.coreboot.org/3058 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich --- payloads/libpayload/Makefile.inc | 4 +--- payloads/libpayload/include/armv7/arch/types.h | 3 --- payloads/libpayload/include/stdarg.h | 13 +++++++++++++ payloads/libpayload/include/stddef.h | 11 +++++++++++ payloads/libpayload/include/unistd.h | 2 -- payloads/libpayload/include/x86/arch/types.h | 3 --- 6 files changed, 25 insertions(+), 11 deletions(-) create mode 100644 payloads/libpayload/include/stddef.h (limited to 'payloads') diff --git a/payloads/libpayload/Makefile.inc b/payloads/libpayload/Makefile.inc index 9e6dc75d1e..7f8889e8da 100644 --- a/payloads/libpayload/Makefile.inc +++ b/payloads/libpayload/Makefile.inc @@ -53,9 +53,7 @@ subdirs-$(CONFIG_CURSES) += curses subdirs-$(CONFIG_CBFS) += libcbfs 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) -I$(CC_INCLUDE) +INCLUDES := -Iinclude -Iinclude/$(ARCHDIR-y) -I$(obj) CFLAGS = $(EXTRA_CFLAGS) $(INCLUDES) -Os -pipe -nostdinc CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs diff --git a/payloads/libpayload/include/armv7/arch/types.h b/payloads/libpayload/include/armv7/arch/types.h index bb4025714f..1bd815bb44 100644 --- a/payloads/libpayload/include/armv7/arch/types.h +++ b/payloads/libpayload/include/armv7/arch/types.h @@ -53,9 +53,6 @@ typedef signed long long s64; typedef long time_t; typedef long suseconds_t; -typedef unsigned long size_t; -typedef long ssize_t; - #ifndef NULL #define NULL ((void *)0) #endif diff --git a/payloads/libpayload/include/stdarg.h b/payloads/libpayload/include/stdarg.h index 077645f227..1d7ac051f4 100644 --- a/payloads/libpayload/include/stdarg.h +++ b/payloads/libpayload/include/stdarg.h @@ -31,7 +31,20 @@ #define _LIBPAYLOAD_STDARG_H #include + +/* 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 +#endif /** * @defgroup vprintf Varargs print functions diff --git a/payloads/libpayload/include/stddef.h b/payloads/libpayload/include/stddef.h new file mode 100644 index 0000000000..91ae78237a --- /dev/null +++ b/payloads/libpayload/include/stddef.h @@ -0,0 +1,11 @@ + +#include + +#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) + diff --git a/payloads/libpayload/include/unistd.h b/payloads/libpayload/include/unistd.h index 1e39aeb058..6b4dcf47e2 100644 --- a/payloads/libpayload/include/unistd.h +++ b/payloads/libpayload/include/unistd.h @@ -32,8 +32,6 @@ #include -typedef ptrdiff_t ssize_t; - int getpagesize(void); #endif diff --git a/payloads/libpayload/include/x86/arch/types.h b/payloads/libpayload/include/x86/arch/types.h index bb4025714f..1bd815bb44 100644 --- a/payloads/libpayload/include/x86/arch/types.h +++ b/payloads/libpayload/include/x86/arch/types.h @@ -53,9 +53,6 @@ typedef signed long long s64; typedef long time_t; typedef long suseconds_t; -typedef unsigned long size_t; -typedef long ssize_t; - #ifndef NULL #define NULL ((void *)0) #endif -- cgit v1.2.3