diff mbox

[4/5] api: init_global: allow abort fn to be overidden

Message ID 1422571952-5132-4-git-send-email-mike.holmes@linaro.org
State Superseded
Headers show

Commit Message

Mike Holmes Jan. 29, 2015, 10:52 p.m. UTC
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 include/odp/api/init.h            | 14 ++++++++++----
 platform/linux-generic/odp_init.c |  2 ++
 2 files changed, 12 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/include/odp/api/init.h b/include/odp/api/init.h
index c5b4e9b..6af032d 100644
--- a/include/odp/api/init.h
+++ b/include/odp/api/init.h
@@ -78,11 +78,16 @@  int odp_override_log(odp_log_level_e level, const char *fmt, ...);
  * Instead of directly calling abort, all abort calls in the implementation
  * should be done via this function or its wrappers.
  *
- * An Application can override the ODP implementation default abort function
- * odp_override_abort() by providing an alternative to this weak symbol.
+ * The application can provide this function to the ODP implementation in two
+ * ways:
+ *
+ * - A callback passed in via odp_init_t and odp_init_global()
+ * - By overriding the ODP implementation default abort function
+ *   odp_override_abort().
  *
- * @warning The override option is not portable and GNU linker dependent
- * (utilizes function attribute "weak").
+ * @warning The latter option is less portable and GNU linker dependent
+ * (utilizes function attribute "weak"). If both are defined, the odp_init_t
+ * function pointer has priority over the override function.
  *
  * @warning this function shall not return
  */
@@ -101,6 +106,7 @@  typedef void (*odp_abort_func_t)(void) ODP_NORETURN;
  */
 typedef struct odp_init_t {
 	odp_log_func_t log_fn;
+	odp_abort_func_t abort_fn;
 } odp_init_t;
 
 /** ODP platform initialization data.
diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c
index e91e910..74c893f 100644
--- a/platform/linux-generic/odp_init.c
+++ b/platform/linux-generic/odp_init.c
@@ -19,6 +19,8 @@  int odp_init_global(odp_init_t *params  ODP_UNUSED,
 	if (params != NULL) {
 		if (params->log_fn != NULL)
 			odp_global_data.log_fn = params->log_fn;
+		if (params->abort_fn != NULL)
+			odp_global_data.abort_fn = params->abort_fn;
 	}