7#ifndef ZEPHYR_INCLUDE_SYS___ASSERT_H_
8#define ZEPHYR_INCLUDE_SYS___ASSERT_H_
15#ifdef CONFIG_ASSERT_LEVEL
16#define __ASSERT_ON CONFIG_ASSERT_LEVEL
21#ifdef CONFIG_FORCE_NO_ASSERT
41#if defined(CONFIG_ASSERT_VERBOSE)
42#define __ASSERT_PRINT(fmt, ...) assert_print(fmt, ##__VA_ARGS__)
44#define __ASSERT_PRINT(fmt, ...)
47#ifdef CONFIG_ASSERT_NO_MSG_INFO
48#define __ASSERT_MSG_INFO(fmt, ...)
50#define __ASSERT_MSG_INFO(fmt, ...) __ASSERT_PRINT("\t" fmt "\n", ##__VA_ARGS__)
53#if !defined(CONFIG_ASSERT_NO_COND_INFO) && !defined(CONFIG_ASSERT_NO_FILE_INFO)
54#define __ASSERT_LOC(test) \
55 __ASSERT_PRINT("ASSERTION FAIL [%s] @ %s:%d\n", \
60#if defined(CONFIG_ASSERT_NO_COND_INFO) && !defined(CONFIG_ASSERT_NO_FILE_INFO)
61#define __ASSERT_LOC(test) \
62 __ASSERT_PRINT("ASSERTION FAIL @ %s:%d\n", \
66#if !defined(CONFIG_ASSERT_NO_COND_INFO) && defined(CONFIG_ASSERT_NO_FILE_INFO)
67#define __ASSERT_LOC(test) \
68 __ASSERT_PRINT("ASSERTION FAIL [%s]\n", \
72#if defined(CONFIG_ASSERT_NO_COND_INFO) && defined(CONFIG_ASSERT_NO_FILE_INFO)
73#define __ASSERT_LOC(test) \
74 __ASSERT_PRINT("ASSERTION FAIL\n")
78#if (__ASSERT_ON < 0) || (__ASSERT_ON > 2)
79#error "Invalid __ASSERT() level: must be between 0 and 2"
88#ifdef CONFIG_ASSERT_NO_FILE_INFO
89void assert_post_action(
void);
90#define __ASSERT_POST_ACTION() assert_post_action()
92void assert_post_action(
const char *file,
unsigned int line);
93#define __ASSERT_POST_ACTION() assert_post_action(__FILE__, __LINE__)
101#ifdef CONFIG_ASSERT_TEST
102#define __ASSERT_UNREACHABLE
104#define __ASSERT_UNREACHABLE CODE_UNREACHABLE
111#define __ASSERT_NO_MSG(test) \
114 __ASSERT_LOC(test); \
115 __ASSERT_POST_ACTION(); \
116 __ASSERT_UNREACHABLE; \
120#define __ASSERT(test, fmt, ...) \
123 __ASSERT_LOC(test); \
124 __ASSERT_MSG_INFO(fmt, ##__VA_ARGS__); \
125 __ASSERT_POST_ACTION(); \
126 __ASSERT_UNREACHABLE; \
130#define __ASSERT_EVAL(expr1, expr2, test, fmt, ...) \
133 __ASSERT(test, fmt, ##__VA_ARGS__); \
136#if (__ASSERT_ON == 1)
137#warning "__ASSERT() statements are ENABLED"
140#define __ASSERT(test, fmt, ...) { }
141#define __ASSERT_EVAL(expr1, expr2, test, fmt, ...) expr1
142#define __ASSERT_NO_MSG(test) { }
143#define __ASSERT_POST_ACTION() { }
146#define __ASSERT(test, fmt, ...) { }
147#define __ASSERT_EVAL(expr1, expr2, test, fmt, ...) expr1
148#define __ASSERT_NO_MSG(test) { }
149#define __ASSERT_POST_ACTION() { }
void assert_print(const char *fmt,...)