Add a weak definition of ODP_ABORT so that it may be overridden by an
application.

Signed-off-by: Mike Holmes <mike.hol...@linaro.org>
---
 platform/linux-generic/include/api/odp_debug.h      | 14 ++++++++++++++
 platform/linux-generic/include/api/odp_hints.h      |  5 +++++
 platform/linux-generic/include/odp_debug_internal.h |  4 ++--
 platform/linux-generic/odp_weak.c                   |  5 +++++
 4 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/platform/linux-generic/include/api/odp_debug.h 
b/platform/linux-generic/include/api/odp_debug.h
index a4ce1d9..dd4eb89 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -12,6 +12,7 @@
 #ifndef ODP_DEBUG_H_
 #define ODP_DEBUG_H_
 
+#include <odp_hints.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -75,6 +76,19 @@ typedef enum odp_log_level {
  */
 extern int odp_override_log(odp_log_level_e level, const char *fmt, ...);
 
+/**
+ * ODP abort function
+ *
+ * Where a fatal event can be identified within the ODP implementation an
+ * ODP_ASSERT may used which can be controlled via ODP_DEBUG. In cases where
+ * an abort must always be called ODP_ABORT may be called directly. In
+ * both cases these macros will call odp_override_abort
+ * ODP platform MUST provide a default *weak* implementation of this function.
+ * Application MAY override the function if needed by providing a strong
+ * function.
+ * @note This function must never return.
+ */
+extern void odp_override_abort(void) ODP_NORETURN;
 
 
 /**
diff --git a/platform/linux-generic/include/api/odp_hints.h 
b/platform/linux-generic/include/api/odp_hints.h
index 7f04886..7eb9e36 100644
--- a/platform/linux-generic/include/api/odp_hints.h
+++ b/platform/linux-generic/include/api/odp_hints.h
@@ -32,6 +32,11 @@ extern "C" {
 #define ODP_WEAK_SYMBOL __attribute__((__weak__))
 
 /**
+ * Function never returns
+ */
+#define ODP_NORETURN    __attribute__((__noreturn__))
+
+/**
  * Hot code section
  */
 #define ODP_HOT_CODE    __attribute__((__hot__))
diff --git a/platform/linux-generic/include/odp_debug_internal.h 
b/platform/linux-generic/include/odp_debug_internal.h
index f6180d1..bbbe591 100644
--- a/platform/linux-generic/include/odp_debug_internal.h
+++ b/platform/linux-generic/include/odp_debug_internal.h
@@ -53,7 +53,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)
 
 /**
@@ -85,7 +85,7 @@ extern "C" {
 #define ODP_ABORT(fmt, ...) \
        do { \
                ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__); \
-               abort(); \
+               odp_override_abort(); \
        } while (0)
 
 /**
diff --git a/platform/linux-generic/odp_weak.c 
b/platform/linux-generic/odp_weak.c
index fccbc3f..ce87119 100644
--- a/platform/linux-generic/odp_weak.c
+++ b/platform/linux-generic/odp_weak.c
@@ -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();
+}
-- 
2.1.0


_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to