summaryrefslogtreecommitdiff
path: root/include/hooks.h
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2014-11-25 15:13:24 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-12-02 01:57:31 +0000
commit8fa4947f7681aac58937395610ed204fa34b6d5a (patch)
tree01bcfa11b84c2e45118f513c60bc76f9dfc9db0a /include/hooks.h
parent975cb11ca193a8783ad53950dad5a01013d3d770 (diff)
downloadchrome-ec-8fa4947f7681aac58937395610ed204fa34b6d5a.tar.gz
Hooks: Use CONCAT and STRINGIFY macros in hook definitions
Previosuly raw pre-processor string processing was used which prevented the definition of hooks with macro parameters. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: I56b373b1b272eebef2e83108059183ed88eb328b Reviewed-on: https://chromium-review.googlesource.com/232365 Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'include/hooks.h')
-rw-r--r--include/hooks.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/include/hooks.h b/include/hooks.h
index c691c19044..579aa0470f 100644
--- a/include/hooks.h
+++ b/include/hooks.h
@@ -222,8 +222,8 @@ int hook_call_deferred(void (*routine)(void), int us);
* order in which hooks are called.
*/
#define DECLARE_HOOK(hooktype, routine, priority) \
- const struct hook_data __hook_##hooktype##_##routine \
- __attribute__((section(".rodata." #hooktype))) \
+ const struct hook_data CONCAT4(__hook_, hooktype, _, routine) \
+ __attribute__((section(".rodata." STRINGIFY(hooktype)))) \
= {routine, priority}
@@ -247,13 +247,15 @@ struct deferred_data {
* @param routine Function pointer, with prototype void routine(void)
*/
#define DECLARE_DEFERRED(routine) \
- const struct deferred_data __deferred_##routine \
+ const struct deferred_data CONCAT2(__deferred_, routine) \
__attribute__((section(".rodata.deferred"))) \
= {routine}
#else /* CONFIG_COMMON_RUNTIME */
-#define DECLARE_HOOK(t, func, p) void unused_hook_##func(void) { func(); }
-#define DECLARE_DEFERRED(func) void unused_deferred_##func(void) { func(); }
+#define DECLARE_HOOK(t, func, p) \
+ void CONCAT2(unused_hook_, func)(void) { func(); }
+#define DECLARE_DEFERRED(func) \
+ void CONCAT2(unused_deferred_, func)(void) { func(); }
#endif /* CONFIG_COMMON_RUNTIME */
#endif /* __CROS_EC_HOOKS_H */