mirror of
https://github.com/schoebel/mars
synced 2024-12-22 06:40:52 +00:00
infra: add CONFIG_MARS_CHECKS
This commit is contained in:
parent
b0c09061e9
commit
54a8eb31f5
@ -9,11 +9,27 @@ config MARS
|
||||
---help---
|
||||
Experimental storage System. Only compile as a module!
|
||||
|
||||
config MARS_CHECKS
|
||||
bool "enable simple runtime checks in MARS"
|
||||
depends on MARS
|
||||
default y
|
||||
---help---
|
||||
These checks should be rather lightweight. Use them
|
||||
for beta testing and for production systems where
|
||||
safety is more important than performance.
|
||||
In case of bugs in the reference counting, an automatic repair
|
||||
is attempted, which lowers the risk of memory corruptions.
|
||||
Disable only if you need the absolutely last grain of
|
||||
performance.
|
||||
If unsure, say Y here.
|
||||
|
||||
config MARS_DEBUG
|
||||
bool "enable runtime checks in MARS"
|
||||
bool "enable full runtime checks and some tracing in MARS"
|
||||
depends on MARS
|
||||
default n
|
||||
---help---
|
||||
Some of these checks and some additional error tracing may
|
||||
consume noticable amounts of memory.
|
||||
OFF for production systems. ON for testing!
|
||||
|
||||
config MARS_DEBUG_DEFAULT
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
// checking
|
||||
|
||||
#ifdef CONFIG_MARS_DEBUG
|
||||
#if defined(CONFIG_MARS_DEBUG) || defined(CONFIG_MARS_CHECKS)
|
||||
#define BRICK_CHECKING true
|
||||
#else
|
||||
#define BRICK_CHECKING false
|
||||
@ -16,7 +16,7 @@
|
||||
do { \
|
||||
if (BRICK_CHECKING) { \
|
||||
int __test = atomic_read(atom); \
|
||||
if (__test OP (minval)) { \
|
||||
if (unlikely(__test OP (minval))) { \
|
||||
atomic_set(atom, minval); \
|
||||
BRICK_ERR("%d: atomic " #atom " " #OP " " #minval " (%d)\n", __LINE__, __test); \
|
||||
} \
|
||||
@ -34,6 +34,7 @@ do { \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef CONFIG_MARS_DEBUG_MEM
|
||||
#define CHECK_PTR_DEAD(ptr,label) \
|
||||
do { \
|
||||
if (BRICK_CHECKING && unlikely((ptr) == (void*)0x5a5a5a5a5a5a5a5a)) { \
|
||||
@ -41,6 +42,9 @@ do { \
|
||||
goto label; \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define CHECK_PTR_DEAD(ptr,label) /*empty*/
|
||||
#endif
|
||||
|
||||
#define CHECK_PTR_NULL(ptr,label) \
|
||||
do { \
|
||||
@ -51,6 +55,7 @@ do { \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef CONFIG_MARS_DEBUG
|
||||
#define CHECK_PTR(ptr,label) \
|
||||
do { \
|
||||
CHECK_PTR_NULL(ptr, label); \
|
||||
@ -59,6 +64,9 @@ do { \
|
||||
goto label; \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define CHECK_PTR(ptr,label) CHECK_PTR_NULL(ptr,label)
|
||||
#endif
|
||||
|
||||
#define CHECK_ASPECT(a_ptr, o_ptr,label) \
|
||||
do { \
|
||||
|
Loading…
Reference in New Issue
Block a user