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-07-14 06:13:21 +0000
commit4da4fe67fe616c2f9005e5e8721a48ea465711a2 (patch)
treea785a8a94a88d067d4b414d1534e08ebcfe6a736
parenta768573ff9b1548b420bf9ea5c92626c34c2ff6d (diff)
downloadchrome-ec-4da4fe67fe616c2f9005e5e8721a48ea465711a2.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-nami-10775.B TEST=With other PD Policies patches, flash nami 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/+/2274381 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Dawid Niedźwiecki <dn@semihalf.com> Commit-Queue: Dossym Nurmukhanov <dossym@chromium.org>
-rw-r--r--include/common.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h
index bc1da44433..78dbd4993a 100644
--- a/include/common.h
+++ b/include/common.h
@@ -215,6 +215,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))