1 /* Copyright (c) 2022 Nordic Semiconductor ASA 2 * SPDX-License-Identifier: Apache-2.0 3 */ 4 5 #include <zephyr/kernel.h> 6 7 #if defined(CONFIG_BT_ASSERT_VERBOSE) 8 #define BT_ASSERT_PRINT(test) __ASSERT_LOC(test) 9 #define BT_ASSERT_PRINT_MSG(fmt, ...) __ASSERT_MSG_INFO(fmt, ##__VA_ARGS__) 10 #else 11 #define BT_ASSERT_PRINT(test) 12 #define BT_ASSERT_PRINT_MSG(fmt, ...) 13 #endif /* CONFIG_BT_ASSERT_VERBOSE */ 14 15 #if defined(CONFIG_BT_ASSERT_PANIC) 16 #define BT_ASSERT_DIE k_panic 17 #else 18 #define BT_ASSERT_DIE k_oops 19 #endif /* CONFIG_BT_ASSERT_PANIC */ 20 21 #if defined(CONFIG_BT_ASSERT) 22 #define BT_ASSERT(cond) \ 23 do { \ 24 if (!(cond)) { \ 25 BT_ASSERT_PRINT(cond); \ 26 BT_ASSERT_DIE(); \ 27 } \ 28 } while (0) 29 30 #define BT_ASSERT_MSG(cond, fmt, ...) \ 31 do { \ 32 if (!(cond)) { \ 33 BT_ASSERT_PRINT(cond); \ 34 BT_ASSERT_PRINT_MSG(fmt, ##__VA_ARGS__); \ 35 BT_ASSERT_DIE(); \ 36 } \ 37 } while (0) 38 #else 39 #define BT_ASSERT(cond) __ASSERT_NO_MSG(cond) 40 #define BT_ASSERT_MSG(cond, msg, ...) __ASSERT(cond, msg, ##__VA_ARGS__) 41 #endif /* CONFIG_BT_ASSERT*/ 42