diff options
author | Anders Roxell <anders.roxell@linaro.org> | 2014-08-21 02:03:02 +0200 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2014-08-22 12:42:02 +0400 |
commit | 7fd717d8ffdff7f09e4824a28bedaa9829f80cff (patch) | |
tree | 25383be1bb49718dab43478d84631ab0e4437242 /platform/linux-generic/include/api/odp_debug.h | |
parent | 3ee9b44a2824457992bcafe7705b61d8e3be2b0c (diff) |
Move includes back into linux-generic
To much linux-generic specific details.
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Reviewed-and-Tested-by: Mike Holmes <mike.holmes@linaro.org>
Reviewed-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
Diffstat (limited to 'platform/linux-generic/include/api/odp_debug.h')
-rw-r--r-- | platform/linux-generic/include/api/odp_debug.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/platform/linux-generic/include/api/odp_debug.h b/platform/linux-generic/include/api/odp_debug.h new file mode 100644 index 000000000..e8f600368 --- /dev/null +++ b/platform/linux-generic/include/api/odp_debug.h @@ -0,0 +1,86 @@ +/* Copyright (c) 2013, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +/** + * @file + * + * ODP debug + */ + +#ifndef ODP_DEBUG_H_ +#define ODP_DEBUG_H_ + +#include <stdio.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __GNUC__ + +/** + * Indicate deprecated variables, functions or types + */ +#define ODP_DEPRECATED __attribute__((__deprecated__)) + +/** + * Intentionally unused variables ot functions + */ +#define ODP_UNUSED __attribute__((__unused__)) + +#if __GNUC__ < 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ < 6)) + +/** + * _Static_assert was only added in GCC 4.6. Provide a weak replacement + * for previous versions. + */ +#define _Static_assert(e, s) extern int (*static_assert_checker (void)) \ + [sizeof (struct { unsigned int error_if_negative: (e) ? 1 : -1; })] + +#endif + +#else + +#define ODP_DEPRECATED +#define ODP_UNUSED + +#endif + +/** + * Runtime assertion-macro - aborts if 'cond' is false. + */ +#ifndef ODP_NO_DEBUG +#define ODP_ASSERT(cond, msg) \ + do { if (!(cond)) {ODP_ERR("%s\n", msg); abort(); } } while (0) +#else +#define ODP_ASSERT(cond, msg) +#endif + +/** + * Compile time assertion-macro - fail compilation if cond is false. + * @note This macro has zero runtime overhead + */ +#define ODP_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg) + +/** + * 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) + +/** + * Print output to stderr (file, line and function). + */ +#define ODP_ERR(fmt, ...) \ + fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \ + __LINE__, __func__, ##__VA_ARGS__) + +#ifdef __cplusplus +} +#endif + +#endif |