summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2019-05-28 18:24:42 -0700
committerCommit Bot <commit-bot@chromium.org>2019-11-06 22:11:55 +0000
commit091a4b8b702a7cc686457efaebdc431e790b85d4 (patch)
treea46c86c9d1784ec845a7f420825c79d0f96f9aee
parent09fc255bb504d474ccfc93686c0da176fd2e2b32 (diff)
downloadchrome-ec-091a4b8b702a7cc686457efaebdc431e790b85d4.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=none TEST=buildall 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> (cherry picked from commit a5c17b44c506979a56cf7ebcaf03ef86f406a3c4) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1902097 Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Wai-Hong Tam <waihong@google.com> Tested-by: Wai-Hong Tam <waihong@google.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 dac0bf2f00..3293918dcb 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))