summaryrefslogtreecommitdiff
path: root/include/common.h
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2019-05-28 18:24:42 -0700
committerCommit Bot <commit-bot@chromium.org>2019-06-03 17:09:06 +0000
commita5c17b44c506979a56cf7ebcaf03ef86f406a3c4 (patch)
tree8787e0ab6785a051a62b2e708330a3d0d70b6181 /include/common.h
parent14d045636d4a6902490b7f9795f19738e90fefe7 (diff)
downloadchrome-ec-a5c17b44c506979a56cf7ebcaf03ef86f406a3c4.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>
Diffstat (limited to 'include/common.h')
-rw-r--r--include/common.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h
index 388d3f413f..1f01652909 100644
--- a/include/common.h
+++ b/include/common.h
@@ -232,6 +232,33 @@ enum ec_error_list {
#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))
+
+/*
* Mark functions that collide with stdlib so they can be hidden when linking
* against libraries that require stdlib. HIDE_EC_STDLIB should be defined
* before including common.h from code that links to cstdlib.