Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions kernel/os/include/os/check.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2019 Intel Corporation
* Copyright (c) 2025 Codecoup
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef OS_CHECK_H_
#define OS_CHECK_H_

#include <assert.h>
#include <syscfg/syscfg.h>

#if MYNEWT_VAL(OS_ASSERT_ON_ERRORS)
#define M_CHECKIF(expr) \
assert(!(expr)); \
if (0)
#elif MYNEWT_VAL(OS_NO_RUNTIME_CHECKS)
#define M_CHECKIF(expr) if (0 && (expr))
#else
#define M_CHECKIF(expr) if (expr)
#endif

#endif /* OS_CHECK_H_ */
9 changes: 9 additions & 0 deletions kernel/os/syscfg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ syscfg.defs:
If set, run time is measured in cpu time ticks rather than OS time
ticks.
value: 0
OS_ASSERT_ON_ERRORS:
description: >
Assert on errors covered with the M_CHECKIF() macro.
value: 0
OS_NO_RUNTIME_CHECKS:
description: >
Do not do any runtime checks or asserts when using the M_CHECKIF()
macro.
value: 0

syscfg.vals.OS_DEBUG_MODE:
OS_CRASH_STACKTRACE: 1
Expand Down
Loading