@@ -29,6 +29,7 @@ extern "C" {
#include <odp/std_types.h>
+#include <odp/hints.h>
/** @defgroup odp_initialization ODP INITIALIZATION
* Initialisation operations.
@@ -71,6 +72,21 @@ typedef enum odp_log_level {
*/
int odp_override_log(odp_log_level_e level, const char *fmt, ...);
+/**
+ * ODP abort function
+ *
+ * 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.
+ *
+ * @warning The override option is not portable and GNU linker dependent
+ * (utilizes function attribute "weak").
+ *
+ * @warning this function shall not return
+ */
+void odp_override_abort(void) ODP_NORETURN;
/** Replaceable logging function */
typedef int (*odp_log_func_t)(odp_log_level_e level, const char *fmt, ...);
@@ -54,7 +54,7 @@ extern "C" {
#define ODP_ASSERT(cond, msg) \
do { if ((ODP_DEBUG == 1) && (!(cond))) { \
ODP_ERR("%s\n", msg); \
- abort(); } \
+ odp_override_abort(); } \
} while (0)
/**
@@ -86,7 +86,7 @@ extern "C" {
#define ODP_ABORT(fmt, ...) \
do { \
ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__); \
- abort(); \
+ odp_override_abort(); \
} while (0)
/**
@@ -21,3 +21,8 @@ ODP_WEAK_SYMBOL int odp_override_log(odp_log_level_e level ODP_UNUSED,
return r;
}
+
+ODP_WEAK_SYMBOL void odp_override_abort(void)
+{
+ abort();
+}
Introduce replaceable abort function using weak symbols. Signed-off-by: Mike Holmes <mike.holmes@linaro.org> --- include/odp/api/init.h | 16 ++++++++++++++++ platform/linux-generic/include/odp_debug_internal.h | 4 ++-- platform/linux-generic/odp_weak.c | 5 +++++ 3 files changed, 23 insertions(+), 2 deletions(-)