summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2019-05-28 18:24:42 -0700
committerCommit Bot <commit-bot@chromium.org>2020-06-25 15:17:16 +0000
commitf2d09a45975cbe50036aa9da572a806c76754ac8 (patch)
tree03e59ae0978f7151727ff391a59038a8ebb2dd18
parentab71e1cdaf0c8ef71bd313209d7834093437dbe6 (diff)
downloadchrome-ec-f2d09a45975cbe50036aa9da572a806c76754ac8.tar.gz
common: Define markers for weak symbols
This patch introduces macros to mark weak symbols. These macros are used to annotate weak definitions, declarations, and overriding definitions. __override_proto: declarations __override: definitions which take precedence __overridable: default (weak) definitions Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=chromium.org/964060 BRANCH=firmware-grunt-11031.B TEST=With other PD Policies patches, flash grunt and run faft_ec&pd Change-Id: I44cec41e0523e285db19a890d084b52337f64a9c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1633911 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Tested-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2213569 Tested-by: Dawid Niedźwiecki <dn@semihalf.com>
-rw-r--r--include/common.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h
index f79128b176..13101fd1f4 100644
--- a/include/common.h
+++ b/include/common.h
@@ -226,6 +226,33 @@ enum ec_error_list {
#define test_export_static static
#endif
+/*
+ * Weak symbol markers
+ *
+ * These macros are used to annotate weak definitions, their declarations, and
+ * overriding definitions.
+ *
+ * __override_proto: declarations
+ * __override: definitions which take precedence
+ * __overridable: default (weak) definitions
+ *
+ * For example, in foo.h:
+ * __override_proto void foo(void);
+ *
+ * and in foo.c:
+ * __overridable void foo(void) {
+ * ...
+ * }
+ *
+ * and in board.c:
+ * __override void foo(void) {
+ * ...
+ * }
+ */
+#define __override_proto
+#define __override
+#define __overridable __attribute__((weak))
+
/* find the most significant bit. Not defined in n == 0. */
#define __fls(n) (31 - __builtin_clz(n))