aboutsummaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorBalasubramanian Manoharan <bala.manoharan@linaro.org>2014-10-16 12:24:10 +0530
committerMaxim Uvarov <maxim.uvarov@linaro.org>2014-10-17 15:01:14 +0400
commit59bdddc183e3ec790bd264950023c1e3059d53b0 (patch)
treef574c4ee373249b7c60974de2af894ed606ab947 /platform
parent178a0ecff9f2a447ea439d6d7dabb086bb87e50e (diff)
ODP Macro for unimplemented functions
Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> Reviewed-by: Mike Holmes <mike.holmes@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'platform')
-rw-r--r--platform/linux-generic/include/api/odp_debug.h54
-rw-r--r--platform/linux-generic/include/api/odp_debug_internal.h35
2 files changed, 79 insertions, 10 deletions
diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h
index 344b0a937..e850bf3ca 100644
--- a/platform/linux-generic/include/api/odp_debug.h
+++ b/platform/linux-generic/include/api/odp_debug.h
@@ -66,30 +66,64 @@ extern "C" {
#define ODP_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
/**
+ * ODP log level.
+ */
+typedef enum odp_log_level {
+ ODP_LOG_DBG,
+ ODP_LOG_ERR,
+ ODP_LOG_UNIMPLEMENTED,
+ ODP_LOG_ABORT
+} odp_log_level_e;
+
+/**
+ * ODP default LOG macro.
+ */
+#define ODP_LOG(level, fmt, ...) \
+do { \
+ switch (level) { \
+ case ODP_LOG_ERR: \
+ fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \
+ __LINE__, __func__, ##__VA_ARGS__); \
+ break; \
+ case ODP_LOG_DBG: \
+ if (ODP_DEBUG_PRINT == 1) \
+ fprintf(stderr, "%s:%d:%s():" fmt, __FILE__, \
+ __LINE__, __func__, ##__VA_ARGS__); \
+ break; \
+ case ODP_LOG_ABORT: \
+ fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
+ __LINE__, __func__, ##__VA_ARGS__); \
+ abort(); \
+ break; \
+ case ODP_LOG_UNIMPLEMENTED: \
+ fprintf(stderr, \
+ "%s:%d:The function %s() is not implemented\n" \
+ fmt, __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
+ break; \
+ default: \
+ fprintf(stderr, "Unknown LOG level"); \
+ break;\
+ } \
+} while (0)
+
+/**
* Debug printing macro, which prints output when DEBUG flag is set.
*/
#define ODP_DBG(fmt, ...) \
- do { if (ODP_DEBUG_PRINT == 1) \
- printf(fmt, ##__VA_ARGS__); \
- } while (0)
+ ODP_LOG(ODP_LOG_DBG, fmt, ##__VA_ARGS__)
/**
* Print output to stderr (file, line and function).
*/
#define ODP_ERR(fmt, ...) \
-do { fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
- __LINE__, __func__, ##__VA_ARGS__); \
-} while (0)
+ ODP_LOG(ODP_LOG_ERR, fmt, ##__VA_ARGS__)
/**
* Print output to stderr (file, line and function),
* then abort.
*/
#define ODP_ABORT(fmt, ...) \
-do { fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \
- __LINE__, __func__, ##__VA_ARGS__); \
- abort(); \
-} while (0)
+ ODP_LOG(ODP_LOG_ABORT, fmt, ##__VA_ARGS__)
#ifdef __cplusplus
}
diff --git a/platform/linux-generic/include/api/odp_debug_internal.h b/platform/linux-generic/include/api/odp_debug_internal.h
new file mode 100644
index 000000000..a87552f88
--- /dev/null
+++ b/platform/linux-generic/include/api/odp_debug_internal.h
@@ -0,0 +1,35 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+/**
+ * @file
+ *
+ * ODP Debug internal
+ * This file contains implementer support functions for Debug capabilities.
+ *
+ * @warning These definitions are not part of ODP API, they are for
+ * internal use by implementers and should not be called from any other scope.
+ */
+
+#ifndef ODP_DEBUG_INTERNAL_H_
+#define ODP_DEBUG_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp_debug.h>
+
+/**
+ * This macro is used to indicate when a given function is not implemented
+ */
+#define ODP_UNIMPLEMENTED(fmt, ...) \
+ ODP_LOG(ODP_LOG_UNIMPLEMENTED, fmt, ##__VA_ARGS__)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif