summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorYu-Ping Wu <yupingso@chromium.org>2019-07-01 16:52:09 +0800
committerCommit Bot <commit-bot@chromium.org>2019-08-21 18:51:55 +0000
commit0393557c98a015318c13452650b657ac173ecd07 (patch)
tree7f8b78ea656ec7bf29182e615a4a0dd6125c10e2 /include
parentfb08e0bf9dd370fc4ae1ce75dad890aa14be668e (diff)
downloadchrome-ec-0393557c98a015318c13452650b657ac173ecd07.tar.gz
ec_commands: Make importing ec_commands.h easier for foreign projects
There are many projects (e.g., kernel, coreboot, flashrom, mosys) having their own copy of the ec_commands.h header file. To reduce the effort of synchronization, this file should be maintained so that it can be copied and included without modification whenever possible. Currently ec_commands.h includes compile_time_macros.h only if __KERNEL__ is not defined. However, there are many macros defined in the latter file (e.g., ARRAY_SIZE) that are already defined in other projects, leading to a redefinition error. To resolve this issue, ec_commands.h is modified in this CL so that compile_time_macros.h is only included when inside the Chromium EC repository, which is controlled by the macro CHROMIUM_EC. Option '-DCHROMIUM_EC' is also added to CPPFLAGS to avoid redefinition error of macro 'BUILD_ASSERT'. BUG=b:109900671,b:118654976,chromium:984623 BRANCH=none TEST=make buildall -j Cq-Depend:chromium:1760656 Change-Id: I38c77f0233ff5962b6f90f25ba96802d05e706d7 Signed-off-by: Yu-Ping Wu <yupingso@chromium.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1535086 Tested-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/ec_commands.h21
1 files changed, 17 insertions, 4 deletions
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
*