Add config option and otPlat API to govern assert behavior. (#1193)

This commit is contained in:
pvanhorn
2017-01-23 17:19:48 -08:00
committed by Jonathan Hui
parent b4051781ea
commit 7c177492f3
3 changed files with 30 additions and 0 deletions
+9
View File
@@ -80,6 +80,15 @@ typedef enum
*/
otPlatResetReason otPlatGetResetReason(otInstance *aInstance);
/**
* This function provides a platform specific implementation for assert.
*
* @param[in] aFilename The name of the file where the assert occurred.
* @param[in] aLineNumber The line number in the file where the assert occurred.
*
*/
void otPlatAssertFail(const char *aFilename, int aLineNumber);
#ifdef __cplusplus
} // extern "C"
#endif
+11
View File
@@ -34,6 +34,7 @@
#ifndef DEBUG_HPP_
#define DEBUG_HPP_
#include <openthread-core-config.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
@@ -55,6 +56,16 @@
#include <assert.h>
#elif OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
#define assert(cond) \
do { \
if (!(cond)) { \
otPlatAssertFail(__FILE__, __LINE__); \
while (1) {} \
} \
} while (0)
#else
#define assert(cond) \
+10
View File
@@ -549,4 +549,14 @@
#define OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE 1500
#endif // OPENTHREAD_CONFIG_NCP_SPI_BUFFER_SIZE
/**
* @def OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
*
* The assert is managed by platform defined logic when this flag is set.
*
*/
#ifndef OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
#define OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT 0
#endif
#endif // OPENTHREAD_CORE_DEFAULT_CONFIG_H_