Message ID | 1413442450-12532-1-git-send-email-bala.manoharan@linaro.org |
---|---|
State | Accepted |
Commit | 59bdddc183e3ec790bd264950023c1e3059d53b0 |
Headers | show |
On 16 October 2014 02:54, Balasubramanian Manoharan < bala.manoharan@linaro.org> wrote: > Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> > Reviewed-by: Mike Holmes <mike.holmes@linaro.org> --- > V4: This patch incorporates previous review comments > and enhancements to ODP debug internal file description. > > platform/linux-generic/include/api/odp_debug.h | 54 > ++++++++++++++++++---- > .../linux-generic/include/api/odp_debug_internal.h | 35 ++++++++++++++ > 2 files changed, 79 insertions(+), 10 deletions(-) > create mode 100644 platform/linux-generic/include/api/odp_debug_internal.h > > diff --git a/platform/linux-generic/include/api/odp_debug.h > b/platform/linux-generic/include/api/odp_debug.h > index 344b0a9..e850bf3 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 0000000..a87552f > --- /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 > -- > 2.0.1.472.g6f92e5f > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp >
Merged! Maxim. On 10/16/2014 10:54 AM, Balasubramanian Manoharan wrote: > Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> > --- > V4: This patch incorporates previous review comments > and enhancements to ODP debug internal file description. > > platform/linux-generic/include/api/odp_debug.h | 54 ++++++++++++++++++---- > .../linux-generic/include/api/odp_debug_internal.h | 35 ++++++++++++++ > 2 files changed, 79 insertions(+), 10 deletions(-) > create mode 100644 platform/linux-generic/include/api/odp_debug_internal.h > > diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h > index 344b0a9..e850bf3 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 0000000..a87552f > --- /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
diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h index 344b0a9..e850bf3 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 0000000..a87552f --- /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
Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> --- V4: This patch incorporates previous review comments and enhancements to ODP debug internal file description. platform/linux-generic/include/api/odp_debug.h | 54 ++++++++++++++++++---- .../linux-generic/include/api/odp_debug_internal.h | 35 ++++++++++++++ 2 files changed, 79 insertions(+), 10 deletions(-) create mode 100644 platform/linux-generic/include/api/odp_debug_internal.h