diff mbox series

[2.0,v1,1/3] frameworks: modular: add static walk through function template

Message ID 1510822807-12483-2-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [2.0,v1,1/3] frameworks: modular: add static walk through function template | expand

Commit Message

Github ODP bot Nov. 16, 2017, 9 a.m. UTC
From: Bogdan Pricope <bogdan.pricope@linaro.org>


SUBSYSTEM_FOREACH_TEMPLATE() generates static walk through
functions to invoke subsystem's modules initialization or
termination methods.
Those functions may be used by a subsystem initialization or
termination function if it needs to perform additional
operations than subsystem's modules method invocation.

Signed-off-by: Bogdan Pricope <bogdan.pricope@linaro.org>

---
/** Email created from pull request 297 (bogdanPricope:2_0_ops_alloc_pr)
 ** https://github.com/Linaro/odp/pull/297
 ** Patch: https://github.com/Linaro/odp/pull/297.patch
 ** Base sha: 6cd43041e55bd73a02ca202f835e590b3ad5c354
 ** Merge commit sha: 9a2195f21322cf4bcf5f0b7b2fb827746597d8a1
 **/
 frameworks/modular/odp_module.h | 37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/frameworks/modular/odp_module.h b/frameworks/modular/odp_module.h
index b20501eb2..0514bf5e1 100644
--- a/frameworks/modular/odp_module.h
+++ b/frameworks/modular/odp_module.h
@@ -202,16 +202,7 @@  struct odp_module_base {
 	static void __attribute__((constructor(102)))		\
 		odp_ ## name ## _module_constructor(void)
 
-/* All subsystems' initialization and termination routines are
- * the same, provide template to help generate similar routines
- * automatically, examples:
- *
- * ODP_SUBSYSTEM_FOREACH_TEMPLATE(subsystem, init_global, DBG)
- * will generate a function walk through all the modules of the
- * subsystem and invoke init_global method for each.
- */
-#define ODP_SUBSYSTEM_FOREACH_TEMPLATE(subs, method, print)	\
-int odp_ ## subs ##_## method(bool continue_on_errors)		\
+#define _SUBSYSTEM_FOREACH_TEMPLATE(subs, method, print)	\
 {								\
 	int result = 0;						\
 	ODP_MODULE_CLASS(subs) * mod = NULL;			\
@@ -237,6 +228,32 @@  done:								\
 	return result;						\
 }
 
+/* ODP_SUBSYSTEM_FOREACH_TEMPLATE() generates subsystems
+ * initialization and termination routines automatically,
+ * examples:
+ *
+ * ODP_SUBSYSTEM_FOREACH_TEMPLATE(subsystem, init_global, DBG)
+ * will generate a function walk through all the modules of the
+ * subsystem and invoke init_global method for each.
+ */
+
+#define ODP_SUBSYSTEM_FOREACH_TEMPLATE(subs, method, print)	\
+int odp_ ## subs ##_## method(bool continue_on_errors)		\
+_SUBSYSTEM_FOREACH_TEMPLATE(subs, method, print)
+
+/* SUBSYSTEM_FOREACH_TEMPLATE() generates static walk through
+ * functions to invoke subsystem's modules initialization or
+ * termination methods, examples:
+ *
+ * SUBSYSTEM_FOREACH_TEMPLATE(subsystem, init_global, DBG)
+ * will generate a function walk through all the modules of the
+ * subsystem and invoke init_global method for each.
+ */
+
+#define SUBSYSTEM_FOREACH_TEMPLATE(subs, method, print)	\
+static int subs ##_## method(bool continue_on_errors)		\
+_SUBSYSTEM_FOREACH_TEMPLATE(subs, method, print)
+
 /* Subsystem Modules Registration
  *
  * odp_subsystem_register_module() are called by all modules in their