summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.toolchain8
-rw-r--r--include/ec_commands.h21
2 files changed, 22 insertions, 7 deletions
diff --git a/Makefile.toolchain b/Makefile.toolchain
index 1a3e47e010..f1a5a4d3a2 100644
--- a/Makefile.toolchain
+++ b/Makefile.toolchain
@@ -100,6 +100,7 @@ CPPFLAGS+=-Ibuiltin/
else
CPPFLAGS+=-Og
endif
+CPPFLAGS+= -DCHROMIUM_EC=$(EMPTY)
CFLAGS=$(CPPFLAGS) $(CFLAGS_CPU) $(CFLAGS_DEBUG) $(COMMON_WARN) $(CFLAGS_y)
CFLAGS+= -ffunction-sections -fshort-wchar
CFLAGS+= -fno-delete-null-pointer-checks
@@ -107,7 +108,6 @@ ifneq ($(cc-name),clang)
CFLAGS+= -ffat-lto-objects
CFLAGS+= -fconserve-stack
endif
-CFLAGS+= -DCHROMIUM_EC=$(EMPTY)
CXXFLAGS+=-DPROTOBUF_INLINE_NOT_IN_HEADERS=0
FTDIVERSION:=$(shell $(PKG_CONFIG) --modversion libftdi1 2>/dev/null)
@@ -130,11 +130,13 @@ LIBPROTOBUF_MUTATOR_LDLIBS:=$(shell $(PKG_CONFIG) --libs libprotobuf-mutator) \
${LIBPROTOBUF_LDLIBS}
endif
-BUILD_CFLAGS = $(LIBFTDIUSB_CFLAGS) $(BUILD_CPPFLAGS) -O3 $(CFLAGS_DEBUG)
-BUILD_CFLAGS += $(CFLAGS_WARN)
+BUILD_CFLAGS=$(LIBFTDIUSB_CFLAGS) $(BUILD_CPPFLAGS) -O3 $(CFLAGS_DEBUG)
+BUILD_CFLAGS+=$(CFLAGS_WARN)
+BUILD_CFLAGS+=-DCHROMIUM_EC=$(EMPTY)
HOST_CFLAGS=$(HOST_CPPFLAGS) -O3 $(CFLAGS_DEBUG) $(CFLAGS_WARN) \
-DHOST_TOOLS_BUILD=$(EMPTY)
HOST_CFLAGS+=$(LIBFTDIUSB_CFLAGS)
+HOST_CFLAGS+=-DCHROMIUM_EC=$(EMPTY)
ifneq (${SYSROOT},)
LDFLAGS_EXTRA+=--sysroot=${SYSROOT}
endif
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 12ce2cd4d5..206d88f195 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -16,6 +16,11 @@
extern "C"{
#endif
+/*
+ * CHROMIUM_EC is defined by the Makefile system of Chromium EC repository.
+ * It is used to not include macros that may cause conflicts in foreign
+ * projects (refer to crbug.com/984623).
+ */
#ifdef CHROMIUM_EC
/*
* Include common.h for CONFIG_HOSTCMD_ALIGNED, if it's defined. This
@@ -23,14 +28,22 @@ extern "C"{
* ARM Cortex-M if the structures are guaranteed 32-bit aligned.
*/
#include "common.h"
-#endif
+#include "compile_time_macros.h"
-#ifdef __KERNEL__
-#define BUILD_ASSERT(_cond)
#else
-#include "compile_time_macros.h"
+
+#define BUILD_ASSERT(_cond)
+
+#ifndef BIT
+#define BIT(nr) (1UL << (nr))
#endif
+#ifndef BIT_ULL
+#define BIT_ULL(nr) (1ULL << (nr))
+#endif
+
+#endif /* CHROMIUM_EC */
+
/*
* Current version of this protocol
*