lib: os: assert: Avoid including printk.h in __assert.h
Create wrapper for printk to avoid including printk.h in __assert.h. __assert.h is used everywhere thus should not have dependency to printk.h. Cleanup assert Kconfig options. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#define ZEPHYR_INCLUDE_SYS___ASSERT_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <sys/printk.h>
|
||||
#include <toolchain.h>
|
||||
|
||||
#ifdef CONFIG_ASSERT
|
||||
#ifndef __ASSERT_ON
|
||||
@@ -21,8 +21,19 @@
|
||||
#define __ASSERT_ON 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Wrapper around printk to avoid including printk.h in assert.h */
|
||||
void assert_print(const char *fmt, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ASSERT_VERBOSE)
|
||||
#define __ASSERT_PRINT(fmt, ...) printk(fmt, ##__VA_ARGS__)
|
||||
#define __ASSERT_PRINT(fmt, ...) assert_print(fmt, ##__VA_ARGS__)
|
||||
#else /* CONFIG_ASSERT_VERBOSE */
|
||||
#define __ASSERT_PRINT(fmt, ...)
|
||||
#endif /* CONFIG_ASSERT_VERBOSE */
|
||||
@@ -64,8 +75,6 @@
|
||||
|
||||
#if __ASSERT_ON
|
||||
|
||||
#include <sys/printk.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/__assert.h>
|
||||
#include <sys/printk.h>
|
||||
#include <zephyr.h>
|
||||
|
||||
|
||||
@@ -41,3 +42,14 @@ __weak void assert_post_action(const char *file, unsigned int line)
|
||||
|
||||
k_panic();
|
||||
}
|
||||
|
||||
void assert_print(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
||||
vprintk(fmt, ap);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
@@ -206,11 +206,20 @@ config ASSERT
|
||||
Disabling this option will cause assertions to compile to nothing,
|
||||
improving performance and system footprint.
|
||||
|
||||
config FORCE_NO_ASSERT
|
||||
bool "Force-disable no assertions"
|
||||
help
|
||||
This boolean option disables Zephyr assertion testing even
|
||||
in circumstances (twister) where it is enabled via
|
||||
CFLAGS and not Kconfig. Added solely to be able to work
|
||||
around compiler bugs for specific tests.
|
||||
|
||||
if ASSERT
|
||||
|
||||
config ASSERT_LEVEL
|
||||
int "__ASSERT() level"
|
||||
default 2
|
||||
range 0 2
|
||||
depends on ASSERT
|
||||
help
|
||||
This option specifies the assertion level used by the __ASSERT()
|
||||
macro. It can be set to one of three possible values:
|
||||
@@ -221,7 +230,6 @@ config ASSERT_LEVEL
|
||||
|
||||
config SPIN_VALIDATE
|
||||
bool "Spinlock validation"
|
||||
depends on ASSERT
|
||||
depends on MULTITHREADING
|
||||
depends on MP_NUM_CPUS <= 4
|
||||
default y if !FLASH || FLASH_SIZE > 32
|
||||
@@ -230,14 +238,6 @@ config SPIN_VALIDATE
|
||||
enabled. It adds a relatively hefty overhead (about 3k or so) to
|
||||
kernel code size, don't use on platforms known to be small.
|
||||
|
||||
config FORCE_NO_ASSERT
|
||||
bool "Force-disable no assertions"
|
||||
help
|
||||
This boolean option disables Zephyr assertion testing even
|
||||
in circumstances (twister) where it is enabled via
|
||||
CFLAGS and not Kconfig. Added solely to be able to work
|
||||
around compiler bugs for specific tests.
|
||||
|
||||
config ASSERT_VERBOSE
|
||||
bool "Verbose assertions"
|
||||
default y
|
||||
@@ -272,6 +272,8 @@ config ASSERT_NO_MSG_INFO
|
||||
before disabling file info since the message can be found in the
|
||||
source using file info.
|
||||
|
||||
endif # ASSERT
|
||||
|
||||
config OVERRIDE_FRAME_POINTER_DEFAULT
|
||||
bool "Override compiler defaults for -fomit-frame-pointer"
|
||||
help
|
||||
|
||||
Reference in New Issue
Block a user