zephyr/subsys/bluetooth/common/assert.h
Théo Battrel 2d1d309936 Bluetooth: Move out BT_ASSERT of common/log.h
Macro that was defined in the `common/log.h` has been moved to the newly
created `common/assert.h` file.

Files that were using those macro has been updated consequently. Also, the
include of `common/log.h` has been removed of files that were actually not
using any logging methods.

Some `#include "common/log.h"` have been removed. Those were required
before when including `hal/debug.h`. With this change, `hal/debug.h` no
longer has this requirement, because the replacement, `common/assert.h`
includes what it uses.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2022-10-25 10:48:17 +02:00

41 lines
1.9 KiB
C

/* Copyright (c) 2022 Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#if defined(CONFIG_BT_ASSERT_VERBOSE)
#define BT_ASSERT_PRINT(test) __ASSERT_LOC(test)
#define BT_ASSERT_PRINT_MSG(fmt, ...) __ASSERT_MSG_INFO(fmt, ##__VA_ARGS__)
#else
#define BT_ASSERT_PRINT(test)
#define BT_ASSERT_PRINT_MSG(fmt, ...)
#endif /* CONFIG_BT_ASSERT_VERBOSE */
#if defined(CONFIG_BT_ASSERT_PANIC)
#define BT_ASSERT_DIE k_panic
#else
#define BT_ASSERT_DIE k_oops
#endif /* CONFIG_BT_ASSERT_PANIC */
#if defined(CONFIG_BT_ASSERT)
#define BT_ASSERT(cond) \
do { \
if (!(cond)) { \
BT_ASSERT_PRINT(cond); \
BT_ASSERT_DIE(); \
} \
} while (0)
#define BT_ASSERT_MSG(cond, fmt, ...) \
do { \
if (!(cond)) { \
BT_ASSERT_PRINT(cond); \
BT_ASSERT_PRINT_MSG(fmt, ##__VA_ARGS__); \
BT_ASSERT_DIE(); \
} \
} while (0)
#else
#define BT_ASSERT(cond) __ASSERT_NO_MSG(cond)
#define BT_ASSERT_MSG(cond, msg, ...) __ASSERT(cond, msg, ##__VA_ARGS__)
#endif /* CONFIG_BT_ASSERT*/