mirror of
https://github.com/espressif/openthread.git
synced 2026-08-15 07:07:46 +00:00
[debug] prefer user provided assert to system assert (#5624)
This allows users to enable OT_ASSERT in release builds on posix systems.
This commit is contained in:
@@ -41,13 +41,7 @@
|
||||
|
||||
#if OPENTHREAD_CONFIG_ASSERT_ENABLE
|
||||
|
||||
#if defined(__APPLE__) || defined(__linux__)
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#define OT_ASSERT(cond) assert(cond)
|
||||
|
||||
#elif OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
|
||||
#if OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
|
||||
|
||||
#include "openthread/platform/misc.h"
|
||||
|
||||
@@ -71,6 +65,12 @@
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#elif defined(__APPLE__) || defined(__linux__)
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#define OT_ASSERT(cond) assert(cond)
|
||||
|
||||
#else // OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
|
||||
|
||||
#define OT_ASSERT(cond) \
|
||||
|
||||
@@ -76,6 +76,14 @@ otError otPlatSetMcuPowerState(otInstance *aInstance, otPlatMcuPowerState aState
|
||||
return error;
|
||||
}
|
||||
|
||||
void otPlatAssertFail(const char *aFilename, int aLineNumber)
|
||||
{
|
||||
otLogCritPlat("assert failed at %s:%d", aFilename, aLineNumber);
|
||||
// For debug build, use assert to genreate a core dump
|
||||
assert(false);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
otPlatMcuPowerState otPlatGetMcuPowerState(otInstance *aInstance)
|
||||
{
|
||||
OT_UNUSED_VARIABLE(aInstance);
|
||||
|
||||
Reference in New Issue
Block a user