@@ -76,6 +76,8 @@ typedef enum odp_log_level {
extern int odp_override_log(odp_log_level_e level, const char *fmt, ...);
+/** Replaceable logging function */
+typedef int (*odp_log_func_t)(odp_log_level_e level, const char *fmt, ...);
/**
* @}
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <odp_debug.h>
+#include <odp_internal.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -60,7 +61,7 @@ extern "C" {
* This macro is used to indicate when a given function is not implemented
*/
#define ODP_UNIMPLEMENTED() \
- odp_override_log(ODP_LOG_UNIMPLEMENTED, \
+ odp_global_data.log_fn(ODP_LOG_UNIMPLEMENTED, \
"%s:%d:The function %s() is not implemented\n", \
__FILE__, __LINE__, __func__)
/**
@@ -92,7 +93,7 @@ extern "C" {
* ODP LOG macro.
*/
#define ODP_LOG(level, fmt, ...) \
- odp_override_log(level, "%s:%d:%s():" fmt, __FILE__, \
+ odp_global_data.log_fn(level, "%s:%d:%s():" fmt, __FILE__, \
__LINE__, __func__, ##__VA_ARGS__)
/**
@@ -100,7 +101,7 @@ extern "C" {
* specifically for dumping internal data.
*/
#define ODP_PRINT(fmt, ...) \
- odp_override_log(ODP_LOG_PRINT, " " fmt, ##__VA_ARGS__)
+ odp_global_data.log_fn(ODP_LOG_PRINT, " " fmt, ##__VA_ARGS__)
#ifdef __cplusplus
}
@@ -18,6 +18,11 @@
extern "C" {
#endif
+#include <odp_debug.h>
+
+struct odp_global_data {
+ odp_log_func_t log_fn;
+} odp_global_data;
int odp_system_info_init(void);
@@ -13,6 +13,8 @@
int odp_init_global(odp_init_t *params ODP_UNUSED,
odp_platform_init_t *platform_params ODP_UNUSED)
{
+ odp_global_data.log_fn = odp_override_log;
+
odp_system_info_init();
if (odp_shm_init_global()) {
To allow init_global to replace the default logging function without the need to use weak symbols a global location is needed to hold the current logging function pointer. Signed-off-by: Mike Holmes <mike.holmes@linaro.org> --- platform/linux-generic/include/api/odp_debug.h | 2 ++ platform/linux-generic/include/odp_debug_internal.h | 7 ++++--- platform/linux-generic/include/odp_internal.h | 5 +++++ platform/linux-generic/odp_init.c | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-)