Hi,

As agreed in the call today, it's better to remove API dependency to 
non-standard weak symbol feature of GCC. Instead we'll define these two as 
callback functions for odp_init_global()...

typedef struct odp_init_t {

 int (*odp_log)(odp_log_level_e level, const char *fmt, ...);
 void (*odp_abort)(void);

} odp_init_t;


NULL would mean default log/abort implementation (with those user could still 
override default implementation at his own risk of non-portability).


-Petri




> -----Original Message-----
> From: [email protected] [mailto:lng-odp-
> [email protected]] On Behalf Of ext Mike Holmes
> Sent: Tuesday, January 06, 2015 10:07 PM
> To: [email protected]
> Subject: [lng-odp] [PATCH] api: odp_debug: make ODP_ABORT a weak symbol
> 
> Add a weak definition of ODP_ABORT so that it may be overridden by an
> application.
> 
> Signed-off-by: Mike Holmes <[email protected]>
> ---
>  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
> [email protected]
> http://lists.linaro.org/mailman/listinfo/lng-odp

_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to